Devo consentire all'utente di memorizzare/caricare un numero arbitrario di liste di oggetti (supponendo che siano serializzabili). Concettualmente Voglio un modello di dati comejava: API Preferenze vs Configurazione Apache Commons
class FooBean { /* bean stuff here */ }
class FooList {
final private Set<FooBean> items = new HashSet<FooBean>();
public boolean add(FooBean item) { return items.add(item); }
public boolean remove(FooBean item) { return items.remove(item); }
public Collection<FooBean> getItems() {
return Collections.unmodifiableSet(items);
}
}
class FooStore {
public FooStore() {
/* something... uses Preferences or Commons Configuration */
}
public FooList load(String key) {
/* something... retrieves a FooList associated with the key */
}
public void store(String key, FooList items) {
/* something... saves a FooList under the given key */
}
}
Dovrei usare il Preferences API o Commons Config? Qual è il vantaggio di ciascuno?