public interface Animal<T> {
public void eat(T t);
public T search(T t);
}
public class Dog<T> implements Animal<T>{
@Override
public void eat(T t) {
}
@Override
public T search(T t) {
return t;
}
}
public interface Food {
}
public class Meat implements Food{
}
public class Bread {
}
public class TestAnimal {
@Test
public void testEat1(){
Dog<Meat> dog = new Dog<Meat>();
dog.eat(new Meat());
dog.eat(new Bread());
Meat meat = new Meat();
Meat food = dog.search(meat);
}
@Test
public void testEat2(){
Dog<Food> dog = new Dog<Food>();
dog.eat(new Meat());
dog.eat(new Bread());
Meat meat = new Meat();
Food food = dog.search(meat);
}
@Test
public void testEat(){
Dog<Food> dog = new Dog<Food>();
dog.eat(new Meat());
dog.eat(new Bread());
Meat meat = new Meat();
Food food = dog.search(meat);
}
}
public void eat(T t);
public T search(T t);
}
public class Dog<T> implements Animal<T>{
@Override
public void eat(T t) {
}
@Override
public T search(T t) {
return t;
}
}
public interface Food {
}
public class Meat implements Food{
}
public class Bread {
}
public class TestAnimal {
@Test
public void testEat1(){
Dog<Meat> dog = new Dog<Meat>();
dog.eat(new Meat());
dog.eat(new Bread());
Meat meat = new Meat();
Meat food = dog.search(meat);
}
@Test
public void testEat2(){
Dog<Food> dog = new Dog<Food>();
dog.eat(new Meat());
dog.eat(new Bread());
Meat meat = new Meat();
Food food = dog.search(meat);
}
@Test
public void testEat(){
Dog<Food> dog = new Dog<Food>();
dog.eat(new Meat());
dog.eat(new Bread());
Meat meat = new Meat();
Food food = dog.search(meat);
}
}