良い一日!
この投稿は、Java言語で別のAPIに取り組んでいる人、または既存のAPIを改善しようとしている人向けです。 ここで簡単なアドバイスが与えられます。どのように構成体を使用し
? extends T
? extends T
と
? super T
? extends T
し
? super T
? super T
は、インターフェースの使いやすさを大幅に向上させることができます。
ポイントに直行しますソースAPI
たとえば、キータイプ(
K
)と値タイプ(
V
)の2つのタイプでパラメーター化されたオブジェクトの特定のストレージのインターフェースがあるとします。 インターフェイスは、リポジトリ内のデータを操作するための一連のメソッドを定義します。
public interface MyObjectStore<K, V> { void put(K key, V value); @Nullable V get(K key); void putAll(Map<K, V> entries); Map<K, V> getAll(Collection<K> keys); Collection<V> getAll(Predicate<V> p); ...
述語の定義 interface Predicate<E> { boolean apply(E exp); }
インターフェイスは非常に適切で論理的に見え、ユーザーはリポジトリを操作するための簡単なコードを簡単に書くことができます。
MyObjectStore<Long, Car> carsStore = ...; carsStore.put(20334L, new Car("BMW", "X5", 2013)); Car c = carsStore.get(222L); ...
ただし、ささいなケースでは、APIクライアントに不快な制限が発生します。
使用し? super T
? super T
述語を満たす値を読み取る最後のメソッドを使用します。 彼に何が問題なのでしょうか? 私たちは次のように書きます:
Collection<Car> cars = carsStore.getAll(new Predicate<Car>() { @Override public boolean apply(Car exp) { ...
しかし、実際には、私たちのクライアントはすでに車を選ぶための述語を持っています。
Car
クラスではなく、
Car
継承される
Vehicle
クラスによってのみパラメーター化されます。 彼は詰め込もうとするかもしれない
Predicate Predicate, :
no suitable method found for getAll(Predicate<Vehicle>)
, , Vehicle
- Car
. Car
, , , Vehicle
, Car
! Vehicle
Car
. , , , :
final Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(new Predicate<Car>() { @Override public boolean apply(Car exp) { return vp.apply(exp); } });
! :
Collection<V> getAll(Predicate<? super V> p);
Predicate<? super V>
" V V ( Object)". , . Vehicle
:
MyObjectStore<Long, Car> carsStore = ...; Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(vp);
, .
? extends T
, . , , ? extends T
. : MyObjectStore<Long, Vehicle>
, Map<Long, Car>
( Car
- Vehicle
), :
MyObjectStore<Long, Vehicle> carsStore = ...; Map<Long, Car> cars = new HashMap<Long, Car>(2); cars.put(1L, new Car("Audi", "A6", 2011)); cars.put(2L, new Car("Honda", "Civic", 2012)); carsStore.putAll(cars);
Predicate Predicate, :
no suitable method found for getAll(Predicate<Vehicle>)
, , Vehicle
- Car
. Car
, , , Vehicle
, Car
! Vehicle
Car
. , , , :
final Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(new Predicate<Car>() { @Override public boolean apply(Car exp) { return vp.apply(exp); } });
! :
Collection<V> getAll(Predicate<? super V> p);
Predicate<? super V>
" V V ( Object)". , . Vehicle
:
MyObjectStore<Long, Car> carsStore = ...; Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(vp);
, .
? extends T
, . , , ? extends T
. : MyObjectStore<Long, Vehicle>
, Map<Long, Car>
( Car
- Vehicle
), :
MyObjectStore<Long, Vehicle> carsStore = ...; Map<Long, Car> cars = new HashMap<Long, Car>(2); cars.put(1L, new Car("Audi", "A6", 2011)); cars.put(2L, new Car("Honda", "Civic", 2012)); carsStore.putAll(cars);
Predicate Predicate, :
no suitable method found for getAll(Predicate<Vehicle>)
, , Vehicle
- Car
. Car
, , , Vehicle
, Car
! Vehicle
Car
. , , , :
final Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(new Predicate<Car>() { @Override public boolean apply(Car exp) { return vp.apply(exp); } });
! :
Collection<V> getAll(Predicate<? super V> p);
Predicate<? super V>
" V V ( Object)". , . Vehicle
:
MyObjectStore<Long, Car> carsStore = ...; Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(vp);
, .
? extends T
, . , , ? extends T
. : MyObjectStore<Long, Vehicle>
, Map<Long, Car>
( Car
- Vehicle
), :
MyObjectStore<Long, Vehicle> carsStore = ...; Map<Long, Car> cars = new HashMap<Long, Car>(2); cars.put(1L, new Car("Audi", "A6", 2011)); cars.put(2L, new Car("Honda", "Civic", 2012)); carsStore.putAll(cars); // .
, , , , wildcard ? extends T
:
void putAll(Map<? extends K, ? extends V> entries);
Map<? extends K, ? extends V>
" K K V V".
PECS - Producer Extends Consumer Super
, , , .
Joshua Bloch PECS (Producer Extends Consumer Super) , Java Generics and Collections (Maurice Naftalin, Philip Wadler) - Get and Put Principle . PECS, . :
(, Collection Predicate), , - ( producer ), ? extends T
, - ( consumer ), ? super T
.
, ? : , - , , . , , T.
Predicate - ( getAll(Predicate) T), Map<K, V>
- ( putAll(Map<K, V>) T - T K V - ).
, , - , , ( , ) - .
- wildcard- , wildcard- .
PECS-, MyObjectStore
, . put(K, V)
get(K)
(.. ); putAll(Map<? extends K, ? extends V>)
getAll(Predicate<? super V>)
, ;
getAll(Collection) - , .
Map<K, V> getAll(Collection<K> keys);
Map<K, V> getAll(Collection<? extends K> keys);
, API! (, !)
. - :
interface Factory<T> { /** * . * * @param args . * @return . */ T create(Object... args); }
, , , :
interface Cloner<T> { /** * . * * @param obj . * @return . */ T clone(T obj); }
, ouput-, ( Java ).
PECS (Producer Extends Consumer Super) API Java. , , API. , , , PECS , .
Joshua Bloch - Effective Java (2nd Edition) Maurice Naftalin, Philip Wadler - Java Generics and Collections
Predicate Predicate, :
no suitable method found for getAll(Predicate<Vehicle>)
, , Vehicle
- Car
. Car
, , , Vehicle
, Car
! Vehicle
Car
. , , , :
final Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(new Predicate<Car>() { @Override public boolean apply(Car exp) { return vp.apply(exp); } });
! :
Collection<V> getAll(Predicate<? super V> p);
Predicate<? super V>
" V V ( Object)". , . Vehicle
:
MyObjectStore<Long, Car> carsStore = ...; Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(vp);
, .
? extends T
, . , , ? extends T
. : MyObjectStore<Long, Vehicle>
, Map<Long, Car>
( Car
- Vehicle
), :
MyObjectStore<Long, Vehicle> carsStore = ...; Map<Long, Car> cars = new HashMap<Long, Car>(2); cars.put(1L, new Car("Audi", "A6", 2011)); cars.put(2L, new Car("Honda", "Civic", 2012)); carsStore.putAll(cars);
Predicate Predicate, :
no suitable method found for getAll(Predicate<Vehicle>)
, , Vehicle
- Car
. Car
, , , Vehicle
, Car
! Vehicle
Car
. , , , :
final Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(new Predicate<Car>() { @Override public boolean apply(Car exp) { return vp.apply(exp); } });
! :
Collection<V> getAll(Predicate<? super V> p);
Predicate<? super V>
" V V ( Object)". , . Vehicle
:
MyObjectStore<Long, Car> carsStore = ...; Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(vp);
, .
? extends T
, . , , ? extends T
. : MyObjectStore<Long, Vehicle>
, Map<Long, Car>
( Car
- Vehicle
), :
MyObjectStore<Long, Vehicle> carsStore = ...; Map<Long, Car> cars = new HashMap<Long, Car>(2); cars.put(1L, new Car("Audi", "A6", 2011)); cars.put(2L, new Car("Honda", "Civic", 2012)); carsStore.putAll(cars); // .
, , , , wildcard ? extends T
:
void putAll(Map<? extends K, ? extends V> entries);
Map<? extends K, ? extends V>
" K K V V".
PECS - Producer Extends Consumer Super
, , , .
Joshua Bloch PECS (Producer Extends Consumer Super) , Java Generics and Collections (Maurice Naftalin, Philip Wadler) - Get and Put Principle . PECS, . :
(, Collection Predicate), , - ( producer ), ? extends T
, - ( consumer ), ? super T
.
, ? : , - , , . , , T.
Predicate - ( getAll(Predicate) T), Map<K, V>
- ( putAll(Map<K, V>) T - T K V - ).
, , - , , ( , ) - .
- wildcard- , wildcard- .
PECS-, MyObjectStore
, . put(K, V)
get(K)
(.. ); putAll(Map<? extends K, ? extends V>)
getAll(Predicate<? super V>)
, ;
getAll(Collection) - , .
Map<K, V> getAll(Collection<K> keys);
Map<K, V> getAll(Collection<? extends K> keys);
, API! (, !)
. - :
interface Factory<T> { /** * . * * @param args . * @return . */ T create(Object... args); }
, , , :
interface Cloner<T> { /** * . * * @param obj . * @return . */ T clone(T obj); }
, ouput-, ( Java ).
PECS (Producer Extends Consumer Super) API Java. , , API. , , , PECS , .
Joshua Bloch - Effective Java (2nd Edition) Maurice Naftalin, Philip Wadler - Java Generics and Collections
Predicate Predicate, :
no suitable method found for getAll(Predicate<Vehicle>)
, , Vehicle
- Car
. Car
, , , Vehicle
, Car
! Vehicle
Car
. , , , :
final Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(new Predicate<Car>() { @Override public boolean apply(Car exp) { return vp.apply(exp); } });
! :
Collection<V> getAll(Predicate<? super V> p);
Predicate<? super V>
" V V ( Object)". , . Vehicle
:
MyObjectStore<Long, Car> carsStore = ...; Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(vp);
, .
? extends T
, . , , ? extends T
. : MyObjectStore<Long, Vehicle>
, Map<Long, Car>
( Car
- Vehicle
), :
MyObjectStore<Long, Vehicle> carsStore = ...; Map<Long, Car> cars = new HashMap<Long, Car>(2); cars.put(1L, new Car("Audi", "A6", 2011)); cars.put(2L, new Car("Honda", "Civic", 2012)); carsStore.putAll(cars);
Predicate Predicate, :
no suitable method found for getAll(Predicate<Vehicle>)
, , Vehicle
- Car
. Car
, , , Vehicle
, Car
! Vehicle
Car
. , , , :
final Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(new Predicate<Car>() { @Override public boolean apply(Car exp) { return vp.apply(exp); } });
! :
Collection<V> getAll(Predicate<? super V> p);
Predicate<? super V>
" V V ( Object)". , . Vehicle
:
MyObjectStore<Long, Car> carsStore = ...; Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(vp);
, .
? extends T
, . , , ? extends T
. : MyObjectStore<Long, Vehicle>
, Map<Long, Car>
( Car
- Vehicle
), :
MyObjectStore<Long, Vehicle> carsStore = ...; Map<Long, Car> cars = new HashMap<Long, Car>(2); cars.put(1L, new Car("Audi", "A6", 2011)); cars.put(2L, new Car("Honda", "Civic", 2012)); carsStore.putAll(cars); // .
, , , , wildcard ? extends T
:
void putAll(Map<? extends K, ? extends V> entries);
Map<? extends K, ? extends V>
" K K V V".
PECS - Producer Extends Consumer Super
, , , .
Joshua Bloch PECS (Producer Extends Consumer Super) , Java Generics and Collections (Maurice Naftalin, Philip Wadler) - Get and Put Principle . PECS, . :
(, Collection Predicate), , - ( producer ), ? extends T
, - ( consumer ), ? super T
.
, ? : , - , , . , , T.
Predicate - ( getAll(Predicate) T), Map<K, V>
- ( putAll(Map<K, V>) T - T K V - ).
, , - , , ( , ) - .
- wildcard- , wildcard- .
PECS-, MyObjectStore
, . put(K, V)
get(K)
(.. ); putAll(Map<? extends K, ? extends V>)
getAll(Predicate<? super V>)
, ;
getAll(Collection) - , .
Map<K, V> getAll(Collection<K> keys);
Map<K, V> getAll(Collection<? extends K> keys);
, API! (, !)
. - :
interface Factory<T> { /** * . * * @param args . * @return . */ T create(Object... args); }
, , , :
interface Cloner<T> { /** * . * * @param obj . * @return . */ T clone(T obj); }
, ouput-, ( Java ).
PECS (Producer Extends Consumer Super) API Java. , , API. , , , PECS , .
Joshua Bloch - Effective Java (2nd Edition) Maurice Naftalin, Philip Wadler - Java Generics and Collections
Predicate Predicate, :
no suitable method found for getAll(Predicate<Vehicle>)
, , Vehicle
- Car
. Car
, , , Vehicle
, Car
! Vehicle
Car
. , , , :
final Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(new Predicate<Car>() { @Override public boolean apply(Car exp) { return vp.apply(exp); } });
! :
Collection<V> getAll(Predicate<? super V> p);
Predicate<? super V>
" V V ( Object)". , . Vehicle
:
MyObjectStore<Long, Car> carsStore = ...; Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(vp);
, .
? extends T
, . , , ? extends T
. : MyObjectStore<Long, Vehicle>
, Map<Long, Car>
( Car
- Vehicle
), :
MyObjectStore<Long, Vehicle> carsStore = ...; Map<Long, Car> cars = new HashMap<Long, Car>(2); cars.put(1L, new Car("Audi", "A6", 2011)); cars.put(2L, new Car("Honda", "Civic", 2012)); carsStore.putAll(cars);
Predicate Predicate, :
no suitable method found for getAll(Predicate<Vehicle>)
, , Vehicle
- Car
. Car
, , , Vehicle
, Car
! Vehicle
Car
. , , , :
final Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(new Predicate<Car>() { @Override public boolean apply(Car exp) { return vp.apply(exp); } });
! :
Collection<V> getAll(Predicate<? super V> p);
Predicate<? super V>
" V V ( Object)". , . Vehicle
:
MyObjectStore<Long, Car> carsStore = ...; Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(vp);
, .
? extends T
, . , , ? extends T
. : MyObjectStore<Long, Vehicle>
, Map<Long, Car>
( Car
- Vehicle
), :
MyObjectStore<Long, Vehicle> carsStore = ...; Map<Long, Car> cars = new HashMap<Long, Car>(2); cars.put(1L, new Car("Audi", "A6", 2011)); cars.put(2L, new Car("Honda", "Civic", 2012)); carsStore.putAll(cars); // .
, , , , wildcard ? extends T
:
void putAll(Map<? extends K, ? extends V> entries);
Map<? extends K, ? extends V>
" K K V V".
PECS - Producer Extends Consumer Super
, , , .
Joshua Bloch PECS (Producer Extends Consumer Super) , Java Generics and Collections (Maurice Naftalin, Philip Wadler) - Get and Put Principle . PECS, . :
(, Collection Predicate), , - ( producer ), ? extends T
, - ( consumer ), ? super T
.
, ? : , - , , . , , T.
Predicate - ( getAll(Predicate) T), Map<K, V>
- ( putAll(Map<K, V>) T - T K V - ).
, , - , , ( , ) - .
- wildcard- , wildcard- .
PECS-, MyObjectStore
, . put(K, V)
get(K)
(.. ); putAll(Map<? extends K, ? extends V>)
getAll(Predicate<? super V>)
, ;
getAll(Collection) - , .
Map<K, V> getAll(Collection<K> keys);
Map<K, V> getAll(Collection<? extends K> keys);
, API! (, !)
. - :
interface Factory<T> { /** * . * * @param args . * @return . */ T create(Object... args); }
, , , :
interface Cloner<T> { /** * . * * @param obj . * @return . */ T clone(T obj); }
, ouput-, ( Java ).
PECS (Producer Extends Consumer Super) API Java. , , API. , , , PECS , .
Joshua Bloch - Effective Java (2nd Edition) Maurice Naftalin, Philip Wadler - Java Generics and Collections
Predicate Predicate, :
no suitable method found for getAll(Predicate<Vehicle>)
, , Vehicle
- Car
. Car
, , , Vehicle
, Car
! Vehicle
Car
. , , , :
final Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(new Predicate<Car>() { @Override public boolean apply(Car exp) { return vp.apply(exp); } });
! :
Collection<V> getAll(Predicate<? super V> p);
Predicate<? super V>
" V V ( Object)". , . Vehicle
:
MyObjectStore<Long, Car> carsStore = ...; Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(vp);
, .
? extends T
, . , , ? extends T
. : MyObjectStore<Long, Vehicle>
, Map<Long, Car>
( Car
- Vehicle
), :
MyObjectStore<Long, Vehicle> carsStore = ...; Map<Long, Car> cars = new HashMap<Long, Car>(2); cars.put(1L, new Car("Audi", "A6", 2011)); cars.put(2L, new Car("Honda", "Civic", 2012)); carsStore.putAll(cars); // .
, , , , wildcard ? extends T
:
void putAll(Map<? extends K, ? extends V> entries);
Map<? extends K, ? extends V>
" K K V V".
PECS - Producer Extends Consumer Super
, , , .
Joshua Bloch PECS (Producer Extends Consumer Super) , Java Generics and Collections (Maurice Naftalin, Philip Wadler) - Get and Put Principle . PECS, . :
(, Collection Predicate), , - ( producer ), ? extends T
, - ( consumer ), ? super T
.
, ? : , - , , . , , T.
Predicate - ( getAll(Predicate) T), Map<K, V>
- ( putAll(Map<K, V>) T - T K V - ).
, , - , , ( , ) - .
- wildcard- , wildcard- .
PECS-, MyObjectStore
, . put(K, V)
get(K)
(.. ); putAll(Map<? extends K, ? extends V>)
getAll(Predicate<? super V>)
, ;
getAll(Collection) - , .
Map<K, V> getAll(Collection<K> keys);
Map<K, V> getAll(Collection<? extends K> keys);
, API! (, !)
. - :
interface Factory<T> { /** * . * * @param args . * @return . */ T create(Object... args); }
, , , :
interface Cloner<T> { /** * . * * @param obj . * @return . */ T clone(T obj); }
, ouput-, ( Java ).
PECS (Producer Extends Consumer Super) API Java. , , API. , , , PECS , .
Joshua Bloch - Effective Java (2nd Edition) Maurice Naftalin, Philip Wadler - Java Generics and Collections
Predicate Predicate, :
no suitable method found for getAll(Predicate<Vehicle>)
, , Vehicle
- Car
. Car
, , , Vehicle
, Car
! Vehicle
Car
. , , , :
final Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(new Predicate<Car>() { @Override public boolean apply(Car exp) { return vp.apply(exp); } });
! :
Collection<V> getAll(Predicate<? super V> p);
Predicate<? super V>
" V V ( Object)". , . Vehicle
:
MyObjectStore<Long, Car> carsStore = ...; Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(vp);
, .
? extends T
, . , , ? extends T
. : MyObjectStore<Long, Vehicle>
, Map<Long, Car>
( Car
- Vehicle
), :
MyObjectStore<Long, Vehicle> carsStore = ...; Map<Long, Car> cars = new HashMap<Long, Car>(2); cars.put(1L, new Car("Audi", "A6", 2011)); cars.put(2L, new Car("Honda", "Civic", 2012)); carsStore.putAll(cars); // .
, , , , wildcard ? extends T
:
void putAll(Map<? extends K, ? extends V> entries);
Map<? extends K, ? extends V>
" K K V V".
PECS - Producer Extends Consumer Super
, , , .
Joshua Bloch PECS (Producer Extends Consumer Super) , Java Generics and Collections (Maurice Naftalin, Philip Wadler) - Get and Put Principle . PECS, . :
(, Collection Predicate), , - ( producer ), ? extends T
, - ( consumer ), ? super T
.
, ? : , - , , . , , T.
Predicate - ( getAll(Predicate) T), Map<K, V>
- ( putAll(Map<K, V>) T - T K V - ).
, , - , , ( , ) - .
- wildcard- , wildcard- .
PECS-, MyObjectStore
, . put(K, V)
get(K)
(.. ); putAll(Map<? extends K, ? extends V>)
getAll(Predicate<? super V>)
, ;
getAll(Collection) - , .
Map<K, V> getAll(Collection<K> keys);
Map<K, V> getAll(Collection<? extends K> keys);
, API! (, !)
. - :
interface Factory<T> { /** * . * * @param args . * @return . */ T create(Object... args); }
, , , :
interface Cloner<T> { /** * . * * @param obj . * @return . */ T clone(T obj); }
, ouput-, ( Java ).
PECS (Producer Extends Consumer Super) API Java. , , API. , , , PECS , .
Joshua Bloch - Effective Java (2nd Edition) Maurice Naftalin, Philip Wadler - Java Generics and Collections
Predicate Predicate, :
no suitable method found for getAll(Predicate<Vehicle>)
, , Vehicle
- Car
. Car
, , , Vehicle
, Car
! Vehicle
Car
. , , , :
final Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(new Predicate<Car>() { @Override public boolean apply(Car exp) { return vp.apply(exp); } });
! :
Collection<V> getAll(Predicate<? super V> p);
Predicate<? super V>
" V V ( Object)". , . Vehicle
:
MyObjectStore<Long, Car> carsStore = ...; Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(vp);
, .
? extends T
, . , , ? extends T
. : MyObjectStore<Long, Vehicle>
, Map<Long, Car>
( Car
- Vehicle
), :
MyObjectStore<Long, Vehicle> carsStore = ...; Map<Long, Car> cars = new HashMap<Long, Car>(2); cars.put(1L, new Car("Audi", "A6", 2011)); cars.put(2L, new Car("Honda", "Civic", 2012)); carsStore.putAll(cars);
Predicate Predicate, :
no suitable method found for getAll(Predicate<Vehicle>)
, , Vehicle
- Car
. Car
, , , Vehicle
, Car
! Vehicle
Car
. , , , :
final Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(new Predicate<Car>() { @Override public boolean apply(Car exp) { return vp.apply(exp); } });
! :
Collection<V> getAll(Predicate<? super V> p);
Predicate<? super V>
" V V ( Object)". , . Vehicle
:
MyObjectStore<Long, Car> carsStore = ...; Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(vp);
, .
? extends T
, . , , ? extends T
. : MyObjectStore<Long, Vehicle>
, Map<Long, Car>
( Car
- Vehicle
), :
MyObjectStore<Long, Vehicle> carsStore = ...; Map<Long, Car> cars = new HashMap<Long, Car>(2); cars.put(1L, new Car("Audi", "A6", 2011)); cars.put(2L, new Car("Honda", "Civic", 2012)); carsStore.putAll(cars); // .
, , , , wildcard ? extends T
:
void putAll(Map<? extends K, ? extends V> entries);
Map<? extends K, ? extends V>
" K K V V".
PECS - Producer Extends Consumer Super
, , , .
Joshua Bloch PECS (Producer Extends Consumer Super) , Java Generics and Collections (Maurice Naftalin, Philip Wadler) - Get and Put Principle . PECS, . :
(, Collection Predicate), , - ( producer ), ? extends T
, - ( consumer ), ? super T
.
, ? : , - , , . , , T.
Predicate - ( getAll(Predicate) T), Map<K, V>
- ( putAll(Map<K, V>) T - T K V - ).
, , - , , ( , ) - .
- wildcard- , wildcard- .
PECS-, MyObjectStore
, . put(K, V)
get(K)
(.. ); putAll(Map<? extends K, ? extends V>)
getAll(Predicate<? super V>)
, ;
getAll(Collection) - , .
Map<K, V> getAll(Collection<K> keys);
Map<K, V> getAll(Collection<? extends K> keys);
, API! (, !)
. - :
interface Factory<T> { /** * . * * @param args . * @return . */ T create(Object... args); }
, , , :
interface Cloner<T> { /** * . * * @param obj . * @return . */ T clone(T obj); }
, ouput-, ( Java ).
PECS (Producer Extends Consumer Super) API Java. , , API. , , , PECS , .
Joshua Bloch - Effective Java (2nd Edition) Maurice Naftalin, Philip Wadler - Java Generics and Collections
Predicate Predicate, :
no suitable method found for getAll(Predicate<Vehicle>)
, , Vehicle
- Car
. Car
, , , Vehicle
, Car
! Vehicle
Car
. , , , :
final Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(new Predicate<Car>() { @Override public boolean apply(Car exp) { return vp.apply(exp); } });
! :
Collection<V> getAll(Predicate<? super V> p);
Predicate<? super V>
" V V ( Object)". , . Vehicle
:
MyObjectStore<Long, Car> carsStore = ...; Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(vp);
, .
? extends T
, . , , ? extends T
. : MyObjectStore<Long, Vehicle>
, Map<Long, Car>
( Car
- Vehicle
), :
MyObjectStore<Long, Vehicle> carsStore = ...; Map<Long, Car> cars = new HashMap<Long, Car>(2); cars.put(1L, new Car("Audi", "A6", 2011)); cars.put(2L, new Car("Honda", "Civic", 2012)); carsStore.putAll(cars);
Predicate Predicate, :
no suitable method found for getAll(Predicate<Vehicle>)
, , Vehicle
- Car
. Car
, , , Vehicle
, Car
! Vehicle
Car
. , , , :
final Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(new Predicate<Car>() { @Override public boolean apply(Car exp) { return vp.apply(exp); } });
! :
Collection<V> getAll(Predicate<? super V> p);
Predicate<? super V>
" V V ( Object)". , . Vehicle
:
MyObjectStore<Long, Car> carsStore = ...; Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(vp);
, .
? extends T
, . , , ? extends T
. : MyObjectStore<Long, Vehicle>
, Map<Long, Car>
( Car
- Vehicle
), :
MyObjectStore<Long, Vehicle> carsStore = ...; Map<Long, Car> cars = new HashMap<Long, Car>(2); cars.put(1L, new Car("Audi", "A6", 2011)); cars.put(2L, new Car("Honda", "Civic", 2012)); carsStore.putAll(cars); // .
, , , , wildcard ? extends T
:
void putAll(Map<? extends K, ? extends V> entries);
Map<? extends K, ? extends V>
" K K V V".
PECS - Producer Extends Consumer Super
, , , .
Joshua Bloch PECS (Producer Extends Consumer Super) , Java Generics and Collections (Maurice Naftalin, Philip Wadler) - Get and Put Principle . PECS, . :
(, Collection Predicate), , - ( producer ), ? extends T
, - ( consumer ), ? super T
.
, ? : , - , , . , , T.
Predicate - ( getAll(Predicate) T), Map<K, V>
- ( putAll(Map<K, V>) T - T K V - ).
, , - , , ( , ) - .
- wildcard- , wildcard- .
PECS-, MyObjectStore
, . put(K, V)
get(K)
(.. ); putAll(Map<? extends K, ? extends V>)
getAll(Predicate<? super V>)
, ;
getAll(Collection) - , .
Map<K, V> getAll(Collection<K> keys);
Map<K, V> getAll(Collection<? extends K> keys);
, API! (, !)
. - :
interface Factory<T> { /** * . * * @param args . * @return . */ T create(Object... args); }
, , , :
interface Cloner<T> { /** * . * * @param obj . * @return . */ T clone(T obj); }
, ouput-, ( Java ).
PECS (Producer Extends Consumer Super) API Java. , , API. , , , PECS , .
Joshua Bloch - Effective Java (2nd Edition) Maurice Naftalin, Philip Wadler - Java Generics and Collections
Predicate Predicate, :
no suitable method found for getAll(Predicate<Vehicle>)
, , Vehicle
- Car
. Car
, , , Vehicle
, Car
! Vehicle
Car
. , , , :
final Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(new Predicate<Car>() { @Override public boolean apply(Car exp) { return vp.apply(exp); } });
! :
Collection<V> getAll(Predicate<? super V> p);
Predicate<? super V>
" V V ( Object)". , . Vehicle
:
MyObjectStore<Long, Car> carsStore = ...; Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(vp);
, .
? extends T
, . , , ? extends T
. : MyObjectStore<Long, Vehicle>
, Map<Long, Car>
( Car
- Vehicle
), :
MyObjectStore<Long, Vehicle> carsStore = ...; Map<Long, Car> cars = new HashMap<Long, Car>(2); cars.put(1L, new Car("Audi", "A6", 2011)); cars.put(2L, new Car("Honda", "Civic", 2012)); carsStore.putAll(cars); // .
, , , , wildcard ? extends T
:
void putAll(Map<? extends K, ? extends V> entries);
Map<? extends K, ? extends V>
" K K V V".
PECS - Producer Extends Consumer Super
, , , .
Joshua Bloch PECS (Producer Extends Consumer Super) , Java Generics and Collections (Maurice Naftalin, Philip Wadler) - Get and Put Principle . PECS, . :
(, Collection Predicate), , - ( producer ), ? extends T
, - ( consumer ), ? super T
.
, ? : , - , , . , , T.
Predicate - ( getAll(Predicate) T), Map<K, V>
- ( putAll(Map<K, V>) T - T K V - ).
, , - , , ( , ) - .
- wildcard- , wildcard- .
PECS-, MyObjectStore
, . put(K, V)
get(K)
(.. ); putAll(Map<? extends K, ? extends V>)
getAll(Predicate<? super V>)
, ;
getAll(Collection) - , .
Map<K, V> getAll(Collection<K> keys);
Map<K, V> getAll(Collection<? extends K> keys);
, API! (, !)
. - :
interface Factory<T> { /** * . * * @param args . * @return . */ T create(Object... args); }
, , , :
interface Cloner<T> { /** * . * * @param obj . * @return . */ T clone(T obj); }
, ouput-, ( Java ).
PECS (Producer Extends Consumer Super) API Java. , , API. , , , PECS , .
Joshua Bloch - Effective Java (2nd Edition) Maurice Naftalin, Philip Wadler - Java Generics and Collections
Predicate Predicate, :
no suitable method found for getAll(Predicate<Vehicle>)
, , Vehicle
- Car
. Car
, , , Vehicle
, Car
! Vehicle
Car
. , , , :
final Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(new Predicate<Car>() { @Override public boolean apply(Car exp) { return vp.apply(exp); } });
! :
Collection<V> getAll(Predicate<? super V> p);
Predicate<? super V>
" V V ( Object)". , . Vehicle
:
MyObjectStore<Long, Car> carsStore = ...; Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(vp);
, .
? extends T
, . , , ? extends T
. : MyObjectStore<Long, Vehicle>
, Map<Long, Car>
( Car
- Vehicle
), :
MyObjectStore<Long, Vehicle> carsStore = ...; Map<Long, Car> cars = new HashMap<Long, Car>(2); cars.put(1L, new Car("Audi", "A6", 2011)); cars.put(2L, new Car("Honda", "Civic", 2012)); carsStore.putAll(cars); // .
, , , , wildcard ? extends T
:
void putAll(Map<? extends K, ? extends V> entries);
Map<? extends K, ? extends V>
" K K V V".
PECS - Producer Extends Consumer Super
, , , .
Joshua Bloch PECS (Producer Extends Consumer Super) , Java Generics and Collections (Maurice Naftalin, Philip Wadler) - Get and Put Principle . PECS, . :
(, Collection Predicate), , - ( producer ), ? extends T
, - ( consumer ), ? super T
.
, ? : , - , , . , , T.
Predicate - ( getAll(Predicate) T), Map<K, V>
- ( putAll(Map<K, V>) T - T K V - ).
, , - , , ( , ) - .
- wildcard- , wildcard- .
PECS-, MyObjectStore
, . put(K, V)
get(K)
(.. ); putAll(Map<? extends K, ? extends V>)
getAll(Predicate<? super V>)
, ;
getAll(Collection) - , .
Map<K, V> getAll(Collection<K> keys);
Map<K, V> getAll(Collection<? extends K> keys);
, API! (, !)
. - :
interface Factory<T> { /** * . * * @param args . * @return . */ T create(Object... args); }
, , , :
interface Cloner<T> { /** * . * * @param obj . * @return . */ T clone(T obj); }
, ouput-, ( Java ).
PECS (Producer Extends Consumer Super) API Java. , , API. , , , PECS , .
Joshua Bloch - Effective Java (2nd Edition) Maurice Naftalin, Philip Wadler - Java Generics and Collections
Predicate Predicate, :
no suitable method found for getAll(Predicate<Vehicle>)
, , Vehicle
- Car
. Car
, , , Vehicle
, Car
! Vehicle
Car
. , , , :
final Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(new Predicate<Car>() { @Override public boolean apply(Car exp) { return vp.apply(exp); } });
! :
Collection<V> getAll(Predicate<? super V> p);
Predicate<? super V>
" V V ( Object)". , . Vehicle
:
MyObjectStore<Long, Car> carsStore = ...; Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(vp);
, .
? extends T
, . , , ? extends T
. : MyObjectStore<Long, Vehicle>
, Map<Long, Car>
( Car
- Vehicle
), :
MyObjectStore<Long, Vehicle> carsStore = ...; Map<Long, Car> cars = new HashMap<Long, Car>(2); cars.put(1L, new Car("Audi", "A6", 2011)); cars.put(2L, new Car("Honda", "Civic", 2012)); carsStore.putAll(cars); // .
, , , , wildcard ? extends T
:
void putAll(Map<? extends K, ? extends V> entries);
Map<? extends K, ? extends V>
" K K V V".
PECS - Producer Extends Consumer Super
, , , .
Joshua Bloch PECS (Producer Extends Consumer Super) , Java Generics and Collections (Maurice Naftalin, Philip Wadler) - Get and Put Principle . PECS, . :
(, Collection Predicate), , - ( producer ), ? extends T
, - ( consumer ), ? super T
.
, ? : , - , , . , , T.
Predicate - ( getAll(Predicate) T), Map<K, V>
- ( putAll(Map<K, V>) T - T K V - ).
, , - , , ( , ) - .
- wildcard- , wildcard- .
PECS-, MyObjectStore
, . put(K, V)
get(K)
(.. ); putAll(Map<? extends K, ? extends V>)
getAll(Predicate<? super V>)
, ;
getAll(Collection) - , .
Map<K, V> getAll(Collection<K> keys);
Map<K, V> getAll(Collection<? extends K> keys);
, API! (, !)
. - :
interface Factory<T> { /** * . * * @param args . * @return . */ T create(Object... args); }
, , , :
interface Cloner<T> { /** * . * * @param obj . * @return . */ T clone(T obj); }
, ouput-, ( Java ).
PECS (Producer Extends Consumer Super) API Java. , , API. , , , PECS , .
Joshua Bloch - Effective Java (2nd Edition) Maurice Naftalin, Philip Wadler - Java Generics and Collections
Predicate Predicate, :
no suitable method found for getAll(Predicate<Vehicle>)
, , Vehicle
- Car
. Car
, , , Vehicle
, Car
! Vehicle
Car
. , , , :
final Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(new Predicate<Car>() { @Override public boolean apply(Car exp) { return vp.apply(exp); } });
! :
Collection<V> getAll(Predicate<? super V> p);
Predicate<? super V>
" V V ( Object)". , . Vehicle
:
MyObjectStore<Long, Car> carsStore = ...; Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(vp);
, .
? extends T
, . , , ? extends T
. : MyObjectStore<Long, Vehicle>
, Map<Long, Car>
( Car
- Vehicle
), :
MyObjectStore<Long, Vehicle> carsStore = ...; Map<Long, Car> cars = new HashMap<Long, Car>(2); cars.put(1L, new Car("Audi", "A6", 2011)); cars.put(2L, new Car("Honda", "Civic", 2012)); carsStore.putAll(cars);
Predicate Predicate, :
no suitable method found for getAll(Predicate<Vehicle>)
, , Vehicle
- Car
. Car
, , , Vehicle
, Car
! Vehicle
Car
. , , , :
final Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(new Predicate<Car>() { @Override public boolean apply(Car exp) { return vp.apply(exp); } });
! :
Collection<V> getAll(Predicate<? super V> p);
Predicate<? super V>
" V V ( Object)". , . Vehicle
:
MyObjectStore<Long, Car> carsStore = ...; Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(vp);
, .
? extends T
, . , , ? extends T
. : MyObjectStore<Long, Vehicle>
, Map<Long, Car>
( Car
- Vehicle
), :
MyObjectStore<Long, Vehicle> carsStore = ...; Map<Long, Car> cars = new HashMap<Long, Car>(2); cars.put(1L, new Car("Audi", "A6", 2011)); cars.put(2L, new Car("Honda", "Civic", 2012)); carsStore.putAll(cars); // .
, , , , wildcard ? extends T
:
void putAll(Map<? extends K, ? extends V> entries);
Map<? extends K, ? extends V>
" K K V V".
PECS - Producer Extends Consumer Super
, , , .
Joshua Bloch PECS (Producer Extends Consumer Super) , Java Generics and Collections (Maurice Naftalin, Philip Wadler) - Get and Put Principle . PECS, . :
(, Collection Predicate), , - ( producer ), ? extends T
, - ( consumer ), ? super T
.
, ? : , - , , . , , T.
Predicate - ( getAll(Predicate) T), Map<K, V>
- ( putAll(Map<K, V>) T - T K V - ).
, , - , , ( , ) - .
- wildcard- , wildcard- .
PECS-, MyObjectStore
, . put(K, V)
get(K)
(.. ); putAll(Map<? extends K, ? extends V>)
getAll(Predicate<? super V>)
, ;
getAll(Collection) - , .
Map<K, V> getAll(Collection<K> keys);
Map<K, V> getAll(Collection<? extends K> keys);
, API! (, !)
. - :
interface Factory<T> { /** * . * * @param args . * @return . */ T create(Object... args); }
, , , :
interface Cloner<T> { /** * . * * @param obj . * @return . */ T clone(T obj); }
, ouput-, ( Java ).
PECS (Producer Extends Consumer Super) API Java. , , API. , , , PECS , .
Joshua Bloch - Effective Java (2nd Edition) Maurice Naftalin, Philip Wadler - Java Generics and Collections
Predicate Predicate, :
no suitable method found for getAll(Predicate<Vehicle>)
, , Vehicle
- Car
. Car
, , , Vehicle
, Car
! Vehicle
Car
. , , , :
final Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(new Predicate<Car>() { @Override public boolean apply(Car exp) { return vp.apply(exp); } });
! :
Collection<V> getAll(Predicate<? super V> p);
Predicate<? super V>
" V V ( Object)". , . Vehicle
:
MyObjectStore<Long, Car> carsStore = ...; Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(vp);
, .
? extends T
, . , , ? extends T
. : MyObjectStore<Long, Vehicle>
, Map<Long, Car>
( Car
- Vehicle
), :
MyObjectStore<Long, Vehicle> carsStore = ...; Map<Long, Car> cars = new HashMap<Long, Car>(2); cars.put(1L, new Car("Audi", "A6", 2011)); cars.put(2L, new Car("Honda", "Civic", 2012)); carsStore.putAll(cars);
Predicate Predicate, :
no suitable method found for getAll(Predicate<Vehicle>)
, , Vehicle
- Car
. Car
, , , Vehicle
, Car
! Vehicle
Car
. , , , :
final Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(new Predicate<Car>() { @Override public boolean apply(Car exp) { return vp.apply(exp); } });
! :
Collection<V> getAll(Predicate<? super V> p);
Predicate<? super V>
" V V ( Object)". , . Vehicle
:
MyObjectStore<Long, Car> carsStore = ...; Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(vp);
, .
? extends T
, . , , ? extends T
. : MyObjectStore<Long, Vehicle>
, Map<Long, Car>
( Car
- Vehicle
), :
MyObjectStore<Long, Vehicle> carsStore = ...; Map<Long, Car> cars = new HashMap<Long, Car>(2); cars.put(1L, new Car("Audi", "A6", 2011)); cars.put(2L, new Car("Honda", "Civic", 2012)); carsStore.putAll(cars); // .
, , , , wildcard ? extends T
:
void putAll(Map<? extends K, ? extends V> entries);
Map<? extends K, ? extends V>
" K K V V".
PECS - Producer Extends Consumer Super
, , , .
Joshua Bloch PECS (Producer Extends Consumer Super) , Java Generics and Collections (Maurice Naftalin, Philip Wadler) - Get and Put Principle . PECS, . :
(, Collection Predicate), , - ( producer ), ? extends T
, - ( consumer ), ? super T
.
, ? : , - , , . , , T.
Predicate - ( getAll(Predicate) T), Map<K, V>
- ( putAll(Map<K, V>) T - T K V - ).
, , - , , ( , ) - .
- wildcard- , wildcard- .
PECS-, MyObjectStore
, . put(K, V)
get(K)
(.. ); putAll(Map<? extends K, ? extends V>)
getAll(Predicate<? super V>)
, ;
getAll(Collection) - , .
Map<K, V> getAll(Collection<K> keys);
Map<K, V> getAll(Collection<? extends K> keys);
, API! (, !)
. - :
interface Factory<T> { /** * . * * @param args . * @return . */ T create(Object... args); }
, , , :
interface Cloner<T> { /** * . * * @param obj . * @return . */ T clone(T obj); }
, ouput-, ( Java ).
PECS (Producer Extends Consumer Super) API Java. , , API. , , , PECS , .
Joshua Bloch - Effective Java (2nd Edition) Maurice Naftalin, Philip Wadler - Java Generics and Collections
Predicate Predicate, :
no suitable method found for getAll(Predicate<Vehicle>)
, , Vehicle
- Car
. Car
, , , Vehicle
, Car
! Vehicle
Car
. , , , :
final Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(new Predicate<Car>() { @Override public boolean apply(Car exp) { return vp.apply(exp); } });
! :
Collection<V> getAll(Predicate<? super V> p);
Predicate<? super V>
" V V ( Object)". , . Vehicle
:
MyObjectStore<Long, Car> carsStore = ...; Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(vp);
, .
? extends T
, . , , ? extends T
. : MyObjectStore<Long, Vehicle>
, Map<Long, Car>
( Car
- Vehicle
), :
MyObjectStore<Long, Vehicle> carsStore = ...; Map<Long, Car> cars = new HashMap<Long, Car>(2); cars.put(1L, new Car("Audi", "A6", 2011)); cars.put(2L, new Car("Honda", "Civic", 2012)); carsStore.putAll(cars); // .
, , , , wildcard ? extends T
:
void putAll(Map<? extends K, ? extends V> entries);
Map<? extends K, ? extends V>
" K K V V".
PECS - Producer Extends Consumer Super
, , , .
Joshua Bloch PECS (Producer Extends Consumer Super) , Java Generics and Collections (Maurice Naftalin, Philip Wadler) - Get and Put Principle . PECS, . :
(, Collection Predicate), , - ( producer ), ? extends T
, - ( consumer ), ? super T
.
, ? : , - , , . , , T.
Predicate - ( getAll(Predicate) T), Map<K, V>
- ( putAll(Map<K, V>) T - T K V - ).
, , - , , ( , ) - .
- wildcard- , wildcard- .
PECS-, MyObjectStore
, . put(K, V)
get(K)
(.. ); putAll(Map<? extends K, ? extends V>)
getAll(Predicate<? super V>)
, ;
getAll(Collection) - , .
Map<K, V> getAll(Collection<K> keys);
Map<K, V> getAll(Collection<? extends K> keys);
, API! (, !)
. - :
interface Factory<T> { /** * . * * @param args . * @return . */ T create(Object... args); }
, , , :
interface Cloner<T> { /** * . * * @param obj . * @return . */ T clone(T obj); }
, ouput-, ( Java ).
PECS (Producer Extends Consumer Super) API Java. , , API. , , , PECS , .
Joshua Bloch - Effective Java (2nd Edition) Maurice Naftalin, Philip Wadler - Java Generics and Collections
Predicate Predicate, :
no suitable method found for getAll(Predicate<Vehicle>)
, , Vehicle
- Car
. Car
, , , Vehicle
, Car
! Vehicle
Car
. , , , :
final Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(new Predicate<Car>() { @Override public boolean apply(Car exp) { return vp.apply(exp); } });
! :
Collection<V> getAll(Predicate<? super V> p);
Predicate<? super V>
" V V ( Object)". , . Vehicle
:
MyObjectStore<Long, Car> carsStore = ...; Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(vp);
, .
? extends T
, . , , ? extends T
. : MyObjectStore<Long, Vehicle>
, Map<Long, Car>
( Car
- Vehicle
), :
MyObjectStore<Long, Vehicle> carsStore = ...; Map<Long, Car> cars = new HashMap<Long, Car>(2); cars.put(1L, new Car("Audi", "A6", 2011)); cars.put(2L, new Car("Honda", "Civic", 2012)); carsStore.putAll(cars); // .
, , , , wildcard ? extends T
:
void putAll(Map<? extends K, ? extends V> entries);
Map<? extends K, ? extends V>
" K K V V".
PECS - Producer Extends Consumer Super
, , , .
Joshua Bloch PECS (Producer Extends Consumer Super) , Java Generics and Collections (Maurice Naftalin, Philip Wadler) - Get and Put Principle . PECS, . :
(, Collection Predicate), , - ( producer ), ? extends T
, - ( consumer ), ? super T
.
, ? : , - , , . , , T.
Predicate - ( getAll(Predicate) T), Map<K, V>
- ( putAll(Map<K, V>) T - T K V - ).
, , - , , ( , ) - .
- wildcard- , wildcard- .
PECS-, MyObjectStore
, . put(K, V)
get(K)
(.. ); putAll(Map<? extends K, ? extends V>)
getAll(Predicate<? super V>)
, ;
getAll(Collection) - , .
Map<K, V> getAll(Collection<K> keys);
Map<K, V> getAll(Collection<? extends K> keys);
, API! (, !)
. - :
interface Factory<T> { /** * . * * @param args . * @return . */ T create(Object... args); }
, , , :
interface Cloner<T> { /** * . * * @param obj . * @return . */ T clone(T obj); }
, ouput-, ( Java ).
PECS (Producer Extends Consumer Super) API Java. , , API. , , , PECS , .
Joshua Bloch - Effective Java (2nd Edition) Maurice Naftalin, Philip Wadler - Java Generics and Collections
Predicate Predicate, :
no suitable method found for getAll(Predicate<Vehicle>)
, , Vehicle
- Car
. Car
, , , Vehicle
, Car
! Vehicle
Car
. , , , :
final Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(new Predicate<Car>() { @Override public boolean apply(Car exp) { return vp.apply(exp); } });
! :
Collection<V> getAll(Predicate<? super V> p);
Predicate<? super V>
" V V ( Object)". , . Vehicle
:
MyObjectStore<Long, Car> carsStore = ...; Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(vp);
, .
? extends T
, . , , ? extends T
. : MyObjectStore<Long, Vehicle>
, Map<Long, Car>
( Car
- Vehicle
), :
MyObjectStore<Long, Vehicle> carsStore = ...; Map<Long, Car> cars = new HashMap<Long, Car>(2); cars.put(1L, new Car("Audi", "A6", 2011)); cars.put(2L, new Car("Honda", "Civic", 2012)); carsStore.putAll(cars);
Predicate Predicate, :
no suitable method found for getAll(Predicate<Vehicle>)
, , Vehicle
- Car
. Car
, , , Vehicle
, Car
! Vehicle
Car
. , , , :
final Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(new Predicate<Car>() { @Override public boolean apply(Car exp) { return vp.apply(exp); } });
! :
Collection<V> getAll(Predicate<? super V> p);
Predicate<? super V>
" V V ( Object)". , . Vehicle
:
MyObjectStore<Long, Car> carsStore = ...; Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(vp);
, .
? extends T
, . , , ? extends T
. : MyObjectStore<Long, Vehicle>
, Map<Long, Car>
( Car
- Vehicle
), :
MyObjectStore<Long, Vehicle> carsStore = ...; Map<Long, Car> cars = new HashMap<Long, Car>(2); cars.put(1L, new Car("Audi", "A6", 2011)); cars.put(2L, new Car("Honda", "Civic", 2012)); carsStore.putAll(cars); // .
, , , , wildcard ? extends T
:
void putAll(Map<? extends K, ? extends V> entries);
Map<? extends K, ? extends V>
" K K V V".
PECS - Producer Extends Consumer Super
, , , .
Joshua Bloch PECS (Producer Extends Consumer Super) , Java Generics and Collections (Maurice Naftalin, Philip Wadler) - Get and Put Principle . PECS, . :
(, Collection Predicate), , - ( producer ), ? extends T
, - ( consumer ), ? super T
.
, ? : , - , , . , , T.
Predicate - ( getAll(Predicate) T), Map<K, V>
- ( putAll(Map<K, V>) T - T K V - ).
, , - , , ( , ) - .
- wildcard- , wildcard- .
PECS-, MyObjectStore
, . put(K, V)
get(K)
(.. ); putAll(Map<? extends K, ? extends V>)
getAll(Predicate<? super V>)
, ;
getAll(Collection) - , .
Map<K, V> getAll(Collection<K> keys);
Map<K, V> getAll(Collection<? extends K> keys);
, API! (, !)
. - :
interface Factory<T> { /** * . * * @param args . * @return . */ T create(Object... args); }
, , , :
interface Cloner<T> { /** * . * * @param obj . * @return . */ T clone(T obj); }
, ouput-, ( Java ).
PECS (Producer Extends Consumer Super) API Java. , , API. , , , PECS , .
Joshua Bloch - Effective Java (2nd Edition) Maurice Naftalin, Philip Wadler - Java Generics and Collections
Predicate Predicate, :
no suitable method found for getAll(Predicate<Vehicle>)
, , Vehicle
- Car
. Car
, , , Vehicle
, Car
! Vehicle
Car
. , , , :
final Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(new Predicate<Car>() { @Override public boolean apply(Car exp) { return vp.apply(exp); } });
! :
Collection<V> getAll(Predicate<? super V> p);
Predicate<? super V>
" V V ( Object)". , . Vehicle
:
MyObjectStore<Long, Car> carsStore = ...; Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(vp);
, .
? extends T
, . , , ? extends T
. : MyObjectStore<Long, Vehicle>
, Map<Long, Car>
( Car
- Vehicle
), :
MyObjectStore<Long, Vehicle> carsStore = ...; Map<Long, Car> cars = new HashMap<Long, Car>(2); cars.put(1L, new Car("Audi", "A6", 2011)); cars.put(2L, new Car("Honda", "Civic", 2012)); carsStore.putAll(cars);
Predicate Predicate, :
no suitable method found for getAll(Predicate<Vehicle>)
, , Vehicle
- Car
. Car
, , , Vehicle
, Car
! Vehicle
Car
. , , , :
final Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(new Predicate<Car>() { @Override public boolean apply(Car exp) { return vp.apply(exp); } });
! :
Collection<V> getAll(Predicate<? super V> p);
Predicate<? super V>
" V V ( Object)". , . Vehicle
:
MyObjectStore<Long, Car> carsStore = ...; Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(vp);
, .
? extends T
, . , , ? extends T
. : MyObjectStore<Long, Vehicle>
, Map<Long, Car>
( Car
- Vehicle
), :
MyObjectStore<Long, Vehicle> carsStore = ...; Map<Long, Car> cars = new HashMap<Long, Car>(2); cars.put(1L, new Car("Audi", "A6", 2011)); cars.put(2L, new Car("Honda", "Civic", 2012)); carsStore.putAll(cars); // .
, , , , wildcard ? extends T
:
void putAll(Map<? extends K, ? extends V> entries);
Map<? extends K, ? extends V>
" K K V V".
PECS - Producer Extends Consumer Super
, , , .
Joshua Bloch PECS (Producer Extends Consumer Super) , Java Generics and Collections (Maurice Naftalin, Philip Wadler) - Get and Put Principle . PECS, . :
(, Collection Predicate), , - ( producer ), ? extends T
, - ( consumer ), ? super T
.
, ? : , - , , . , , T.
Predicate - ( getAll(Predicate) T), Map<K, V>
- ( putAll(Map<K, V>) T - T K V - ).
, , - , , ( , ) - .
- wildcard- , wildcard- .
PECS-, MyObjectStore
, . put(K, V)
get(K)
(.. ); putAll(Map<? extends K, ? extends V>)
getAll(Predicate<? super V>)
, ;
getAll(Collection) - , .
Map<K, V> getAll(Collection<K> keys);
Map<K, V> getAll(Collection<? extends K> keys);
, API! (, !)
. - :
interface Factory<T> { /** * . * * @param args . * @return . */ T create(Object... args); }
, , , :
interface Cloner<T> { /** * . * * @param obj . * @return . */ T clone(T obj); }
, ouput-, ( Java ).
PECS (Producer Extends Consumer Super) API Java. , , API. , , , PECS , .
Joshua Bloch - Effective Java (2nd Edition) Maurice Naftalin, Philip Wadler - Java Generics and Collections
Predicate Predicate, :
no suitable method found for getAll(Predicate<Vehicle>)
, , Vehicle
- Car
. Car
, , , Vehicle
, Car
! Vehicle
Car
. , , , :
final Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(new Predicate<Car>() { @Override public boolean apply(Car exp) { return vp.apply(exp); } });
! :
Collection<V> getAll(Predicate<? super V> p);
Predicate<? super V>
" V V ( Object)". , . Vehicle
:
MyObjectStore<Long, Car> carsStore = ...; Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(vp);
, .
? extends T
, . , , ? extends T
. : MyObjectStore<Long, Vehicle>
, Map<Long, Car>
( Car
- Vehicle
), :
MyObjectStore<Long, Vehicle> carsStore = ...; Map<Long, Car> cars = new HashMap<Long, Car>(2); cars.put(1L, new Car("Audi", "A6", 2011)); cars.put(2L, new Car("Honda", "Civic", 2012)); carsStore.putAll(cars); // .
, , , , wildcard ? extends T
:
void putAll(Map<? extends K, ? extends V> entries);
Map<? extends K, ? extends V>
" K K V V".
PECS - Producer Extends Consumer Super
, , , .
Joshua Bloch PECS (Producer Extends Consumer Super) , Java Generics and Collections (Maurice Naftalin, Philip Wadler) - Get and Put Principle . PECS, . :
(, Collection Predicate), , - ( producer ), ? extends T
, - ( consumer ), ? super T
.
, ? : , - , , . , , T.
Predicate - ( getAll(Predicate) T), Map<K, V>
- ( putAll(Map<K, V>) T - T K V - ).
, , - , , ( , ) - .
- wildcard- , wildcard- .
PECS-, MyObjectStore
, . put(K, V)
get(K)
(.. ); putAll(Map<? extends K, ? extends V>)
getAll(Predicate<? super V>)
, ;
getAll(Collection) - , .
Map<K, V> getAll(Collection<K> keys);
Map<K, V> getAll(Collection<? extends K> keys);
, API! (, !)
. - :
interface Factory<T> { /** * . * * @param args . * @return . */ T create(Object... args); }
, , , :
interface Cloner<T> { /** * . * * @param obj . * @return . */ T clone(T obj); }
, ouput-, ( Java ).
PECS (Producer Extends Consumer Super) API Java. , , API. , , , PECS , .
Joshua Bloch - Effective Java (2nd Edition) Maurice Naftalin, Philip Wadler - Java Generics and Collections
Predicate Predicate, :
no suitable method found for getAll(Predicate<Vehicle>)
, , Vehicle
- Car
. Car
, , , Vehicle
, Car
! Vehicle
Car
. , , , :
final Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(new Predicate<Car>() { @Override public boolean apply(Car exp) { return vp.apply(exp); } });
! :
Collection<V> getAll(Predicate<? super V> p);
Predicate<? super V>
" V V ( Object)". , . Vehicle
:
MyObjectStore<Long, Car> carsStore = ...; Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(vp);
, .
? extends T
, . , , ? extends T
. : MyObjectStore<Long, Vehicle>
, Map<Long, Car>
( Car
- Vehicle
), :
MyObjectStore<Long, Vehicle> carsStore = ...; Map<Long, Car> cars = new HashMap<Long, Car>(2); cars.put(1L, new Car("Audi", "A6", 2011)); cars.put(2L, new Car("Honda", "Civic", 2012)); carsStore.putAll(cars); // .
, , , , wildcard ? extends T
:
void putAll(Map<? extends K, ? extends V> entries);
Map<? extends K, ? extends V>
" K K V V".
PECS - Producer Extends Consumer Super
, , , .
Joshua Bloch PECS (Producer Extends Consumer Super) , Java Generics and Collections (Maurice Naftalin, Philip Wadler) - Get and Put Principle . PECS, . :
(, Collection Predicate), , - ( producer ), ? extends T
, - ( consumer ), ? super T
.
, ? : , - , , . , , T.
Predicate - ( getAll(Predicate) T), Map<K, V>
- ( putAll(Map<K, V>) T - T K V - ).
, , - , , ( , ) - .
- wildcard- , wildcard- .
PECS-, MyObjectStore
, . put(K, V)
get(K)
(.. ); putAll(Map<? extends K, ? extends V>)
getAll(Predicate<? super V>)
, ;
getAll(Collection) - , .
Map<K, V> getAll(Collection<K> keys);
Map<K, V> getAll(Collection<? extends K> keys);
, API! (, !)
. - :
interface Factory<T> { /** * . * * @param args . * @return . */ T create(Object... args); }
, , , :
interface Cloner<T> { /** * . * * @param obj . * @return . */ T clone(T obj); }
, ouput-, ( Java ).
PECS (Producer Extends Consumer Super) API Java. , , API. , , , PECS , .
Joshua Bloch - Effective Java (2nd Edition) Maurice Naftalin, Philip Wadler - Java Generics and Collections
Predicate Predicate, :
no suitable method found for getAll(Predicate<Vehicle>)
, , Vehicle
- Car
. Car
, , , Vehicle
, Car
! Vehicle
Car
. , , , :
final Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(new Predicate<Car>() { @Override public boolean apply(Car exp) { return vp.apply(exp); } });
! :
Collection<V> getAll(Predicate<? super V> p);
Predicate<? super V>
" V V ( Object)". , . Vehicle
:
MyObjectStore<Long, Car> carsStore = ...; Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(vp);
, .
? extends T
, . , , ? extends T
. : MyObjectStore<Long, Vehicle>
, Map<Long, Car>
( Car
- Vehicle
), :
MyObjectStore<Long, Vehicle> carsStore = ...; Map<Long, Car> cars = new HashMap<Long, Car>(2); cars.put(1L, new Car("Audi", "A6", 2011)); cars.put(2L, new Car("Honda", "Civic", 2012)); carsStore.putAll(cars); // .
, , , , wildcard ? extends T
:
void putAll(Map<? extends K, ? extends V> entries);
Map<? extends K, ? extends V>
" K K V V".
PECS - Producer Extends Consumer Super
, , , .
Joshua Bloch PECS (Producer Extends Consumer Super) , Java Generics and Collections (Maurice Naftalin, Philip Wadler) - Get and Put Principle . PECS, . :
(, Collection Predicate), , - ( producer ), ? extends T
, - ( consumer ), ? super T
.
, ? : , - , , . , , T.
Predicate - ( getAll(Predicate) T), Map<K, V>
- ( putAll(Map<K, V>) T - T K V - ).
, , - , , ( , ) - .
- wildcard- , wildcard- .
PECS-, MyObjectStore
, . put(K, V)
get(K)
(.. ); putAll(Map<? extends K, ? extends V>)
getAll(Predicate<? super V>)
, ;
getAll(Collection) - , .
Map<K, V> getAll(Collection<K> keys);
Map<K, V> getAll(Collection<? extends K> keys);
, API! (, !)
. - :
interface Factory<T> { /** * . * * @param args . * @return . */ T create(Object... args); }
, , , :
interface Cloner<T> { /** * . * * @param obj . * @return . */ T clone(T obj); }
, ouput-, ( Java ).
PECS (Producer Extends Consumer Super) API Java. , , API. , , , PECS , .
Joshua Bloch - Effective Java (2nd Edition) Maurice Naftalin, Philip Wadler - Java Generics and Collections
Predicate Predicate, :
no suitable method found for getAll(Predicate<Vehicle>)
, , Vehicle
- Car
. Car
, , , Vehicle
, Car
! Vehicle
Car
. , , , :
final Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(new Predicate<Car>() { @Override public boolean apply(Car exp) { return vp.apply(exp); } });
! :
Collection<V> getAll(Predicate<? super V> p);
Predicate<? super V>
" V V ( Object)". , . Vehicle
:
MyObjectStore<Long, Car> carsStore = ...; Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(vp);
, .
? extends T
, . , , ? extends T
. : MyObjectStore<Long, Vehicle>
, Map<Long, Car>
( Car
- Vehicle
), :
MyObjectStore<Long, Vehicle> carsStore = ...; Map<Long, Car> cars = new HashMap<Long, Car>(2); cars.put(1L, new Car("Audi", "A6", 2011)); cars.put(2L, new Car("Honda", "Civic", 2012)); carsStore.putAll(cars); // .
, , , , wildcard ? extends T
:
void putAll(Map<? extends K, ? extends V> entries);
Map<? extends K, ? extends V>
" K K V V".
PECS - Producer Extends Consumer Super
, , , .
Joshua Bloch PECS (Producer Extends Consumer Super) , Java Generics and Collections (Maurice Naftalin, Philip Wadler) - Get and Put Principle . PECS, . :
(, Collection Predicate), , - ( producer ), ? extends T
, - ( consumer ), ? super T
.
, ? : , - , , . , , T.
Predicate - ( getAll(Predicate) T), Map<K, V>
- ( putAll(Map<K, V>) T - T K V - ).
, , - , , ( , ) - .
- wildcard- , wildcard- .
PECS-, MyObjectStore
, . put(K, V)
get(K)
(.. ); putAll(Map<? extends K, ? extends V>)
getAll(Predicate<? super V>)
, ;
getAll(Collection) - , .
Map<K, V> getAll(Collection<K> keys);
Map<K, V> getAll(Collection<? extends K> keys);
, API! (, !)
. - :
interface Factory<T> { /** * . * * @param args . * @return . */ T create(Object... args); }
, , , :
interface Cloner<T> { /** * . * * @param obj . * @return . */ T clone(T obj); }
, ouput-, ( Java ).
PECS (Producer Extends Consumer Super) API Java. , , API. , , , PECS , .
Joshua Bloch - Effective Java (2nd Edition) Maurice Naftalin, Philip Wadler - Java Generics and Collections
Predicate Predicate, :
no suitable method found for getAll(Predicate<Vehicle>)
, , Vehicle
- Car
. Car
, , , Vehicle
, Car
! Vehicle
Car
. , , , :
final Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(new Predicate<Car>() { @Override public boolean apply(Car exp) { return vp.apply(exp); } });
! :
Collection<V> getAll(Predicate<? super V> p);
Predicate<? super V>
" V V ( Object)". , . Vehicle
:
MyObjectStore<Long, Car> carsStore = ...; Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(vp);
, .
? extends T
, . , , ? extends T
. : MyObjectStore<Long, Vehicle>
, Map<Long, Car>
( Car
- Vehicle
), :
MyObjectStore<Long, Vehicle> carsStore = ...; Map<Long, Car> cars = new HashMap<Long, Car>(2); cars.put(1L, new Car("Audi", "A6", 2011)); cars.put(2L, new Car("Honda", "Civic", 2012)); carsStore.putAll(cars); // .
, , , , wildcard ? extends T
:
void putAll(Map<? extends K, ? extends V> entries);
Map<? extends K, ? extends V>
" K K V V".
PECS - Producer Extends Consumer Super
, , , .
Joshua Bloch PECS (Producer Extends Consumer Super) , Java Generics and Collections (Maurice Naftalin, Philip Wadler) - Get and Put Principle . PECS, . :
(, Collection Predicate), , - ( producer ), ? extends T
, - ( consumer ), ? super T
.
, ? : , - , , . , , T.
Predicate - ( getAll(Predicate) T), Map<K, V>
- ( putAll(Map<K, V>) T - T K V - ).
, , - , , ( , ) - .
- wildcard- , wildcard- .
PECS-, MyObjectStore
, . put(K, V)
get(K)
(.. ); putAll(Map<? extends K, ? extends V>)
getAll(Predicate<? super V>)
, ;
getAll(Collection) - , .
Map<K, V> getAll(Collection<K> keys);
Map<K, V> getAll(Collection<? extends K> keys);
, API! (, !)
. - :
interface Factory<T> { /** * . * * @param args . * @return . */ T create(Object... args); }
, , , :
interface Cloner<T> { /** * . * * @param obj . * @return . */ T clone(T obj); }
, ouput-, ( Java ).
PECS (Producer Extends Consumer Super) API Java. , , API. , , , PECS , .
Joshua Bloch - Effective Java (2nd Edition) Maurice Naftalin, Philip Wadler - Java Generics and Collections
Predicate Predicate, :
no suitable method found for getAll(Predicate<Vehicle>)
, , Vehicle
- Car
. Car
, , , Vehicle
, Car
! Vehicle
Car
. , , , :
final Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(new Predicate<Car>() { @Override public boolean apply(Car exp) { return vp.apply(exp); } });
! :
Collection<V> getAll(Predicate<? super V> p);
Predicate<? super V>
" V V ( Object)". , . Vehicle
:
MyObjectStore<Long, Car> carsStore = ...; Predicate<Vehicle> vp = mgr.getVehiclePredicate(); Collection<Car> cars = carsStore.getAll(vp);
, .
? extends T
, . , , ? extends T
. : MyObjectStore<Long, Vehicle>
, Map<Long, Car>
( Car
- Vehicle
), :
MyObjectStore<Long, Vehicle> carsStore = ...; Map<Long, Car> cars = new HashMap<Long, Car>(2); cars.put(1L, new Car("Audi", "A6", 2011)); cars.put(2L, new Car("Honda", "Civic", 2012)); carsStore.putAll(cars); // .
, , , , wildcard ? extends T
:
void putAll(Map<? extends K, ? extends V> entries);
Map<? extends K, ? extends V>
" K K V V".
PECS - Producer Extends Consumer Super
, , , .
Joshua Bloch PECS (Producer Extends Consumer Super) , Java Generics and Collections (Maurice Naftalin, Philip Wadler) - Get and Put Principle . PECS, . :
(, Collection Predicate), , - ( producer ), ? extends T
, - ( consumer ), ? super T
.
, ? : , - , , . , , T.
Predicate - ( getAll(Predicate) T), Map<K, V>
- ( putAll(Map<K, V>) T - T K V - ).
, , - , , ( , ) - .
- wildcard- , wildcard- .
PECS-, MyObjectStore
, . put(K, V)
get(K)
(.. ); putAll(Map<? extends K, ? extends V>)
getAll(Predicate<? super V>)
, ;
getAll(Collection) - , .
Map<K, V> getAll(Collection<K> keys);
Map<K, V> getAll(Collection<? extends K> keys);
, API! (, !)
. - :
interface Factory<T> { /** * . * * @param args . * @return . */ T create(Object... args); }
, , , :
interface Cloner<T> { /** * . * * @param obj . * @return . */ T clone(T obj); }
, ouput-, ( Java ).
PECS (Producer Extends Consumer Super) API Java. , , API. , , , PECS , .
Joshua Bloch - Effective Java (2nd Edition) Maurice Naftalin, Philip Wadler - Java Generics and Collections