X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fxmlrouter%2Fimpl%2FConfigImpl.java;h=75b8222c04363038f3ed289eb5386a9c7843aded;hb=6c41c1cabffcc509c5b736f73578930808f6616f;hp=9442db674eb027575182da4f9675badbe76e07f4;hpb=7b7444ecb86a1af3eb11013e94776c2860205f2a;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 9442db6..75b8222 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; @@ -24,9 +26,6 @@ import org.wamblee.xmlrouter.common.Id; import org.wamblee.xmlrouter.config.Config; import org.wamblee.xmlrouter.config.Identifiable; -// TODO think real hard about the prefixing. We want a consistent view for clients. -// perhaps only provide a method to add items and hide all access to the ids. - /** * Default implementation of the {@link Config} interface. * @@ -36,7 +35,7 @@ import org.wamblee.xmlrouter.config.Identifiable; */ // TODO make sure that each item inside this config is prefixed with the id of // the config. -public abstract class ConfigImpl implements +public abstract class ConfigImpl> implements ExtendedConfig { private Id id; @@ -46,7 +45,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(); } @@ -63,8 +62,7 @@ public abstract class ConfigImpl implements */ @Override public synchronized void add(T aT) { - // TODO test duplicate ids. - notNull(aT); + notNull("aT", aT); registered.add(wrap(id.getId() + ".", aT)); } @@ -86,7 +84,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(); @@ -102,16 +100,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"); - } - } }