मुझे उपयोगकर्ता को ऑब्जेक्ट्स की सूचियों की मनमानी संख्या को स्टोर/लोड करने की अनुमति देने की आवश्यकता है (मान लें कि वे Serializable हैं)। सैद्धांतिक रूप मैंजावा: प्राथमिकता API बनाम अपाचे कॉमन्स कॉन्फ़िगरेशन
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 */
}
}
की तरह एक डाटा मॉडल मैं Preferences API या Commons Config का उपयोग करना चाहिए करना चाहते हैं? प्रत्येक के फायदे क्या हैं?