1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
public final class ObjectLoader<T>{
private final Map buffer = new HashMap<IdentOfTheObject, T>();
private final ConnexionBase connexion;
public ObjectLoader(ConnexionBase connexion){
if(null == connexion){
throw new NullPointerException();
}
this.connexion = connexion;
}
public T charger(IdentOfTheObject ident){
if(null == ident){
throw new NullPointerException();
}
if(buffer.containsKey(ident) == false){
T object = this.connexion.getObject(ident);
this.buffer.put(ident, object);
}
return buffer.get(ident);
}
} |