X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fxmlrouter%2Fimpl%2FConfigImpl.java;h=980bd07601277b1c52b1580df5e44a8a2a7f135c;hb=ef3c789029b09fe8bc279a07a7b2208e286957f0;hp=c561e364b287958a169a90eb611baa58769ed3fc;hpb=e52385618670b54a5c6a4f2fbfab381bef43a905;p=xmlrouter diff --git a/impl/src/main/java/org/wamblee/xmlrouter/impl/ConfigImpl.java b/impl/src/main/java/org/wamblee/xmlrouter/impl/ConfigImpl.java index c561e36..980bd07 100644 --- a/impl/src/main/java/org/wamblee/xmlrouter/impl/ConfigImpl.java +++ b/impl/src/main/java/org/wamblee/xmlrouter/impl/ConfigImpl.java @@ -15,6 +15,8 @@ */ package org.wamblee.xmlrouter.impl; +import static org.wamblee.xmlrouter.impl.MessageUtil.*; + import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; @@ -31,7 +33,7 @@ import org.wamblee.xmlrouter.config.Identifiable; * * @param */ -public abstract class ConfigImpl implements +public abstract class ConfigImpl> implements ExtendedConfig { private Id id; @@ -41,7 +43,7 @@ public abstract class ConfigImpl implements * Constructs the object. */ public ConfigImpl(Id aId) { - // TODO test for null. + notNull("id", aId); id = aId; registered = new ArrayList(); } @@ -58,9 +60,8 @@ public abstract class ConfigImpl implements */ @Override public synchronized void add(T aT) { - // TODO test duplicate ids. - notNull(aT); - registered.add(wrap(aT)); + notNull("aT", aT); + registered.add(wrap(id.getId() + ".", aT)); } /** @@ -70,7 +71,7 @@ public abstract class ConfigImpl implements * Object to wrap. * @return Wrapped object. */ - public abstract T wrap(T aT); + public abstract T wrap(String aPrefix, T aT); /* * (non-Javadoc) @@ -81,7 +82,7 @@ public abstract class ConfigImpl implements */ @Override public synchronized boolean remove(Id aId) { - notNull(aId); + notNull("aId", aId); Iterator i = registered.iterator(); while (i.hasNext()) { T t = i.next(); @@ -97,16 +98,4 @@ public abstract class ConfigImpl implements public List values() { return Collections.unmodifiableList(registered); } - - private void notNull(T aT) { - if (aT == null) { - throw new NullPointerException("Object is null"); - } - } - - private void notNull(Id aId) { - if (aId == null) { - throw new NullPointerException("Id is null"); - } - } }