X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=system%2Fgeneral%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fsystem%2Fadapters%2FSetterConfiguration.java;h=77fd9720b4c66c9ac69a12bce27862a1458e5d41;hb=0d8d8f24656e585ee75558cfd6a4c661f8f14985;hp=57323a54b409531f53667e9d771c4f9d542a0060;hpb=da48a523c81e59fe0eac34e43d12937396161f25;p=utils diff --git a/system/general/src/main/java/org/wamblee/system/adapters/SetterConfiguration.java b/system/general/src/main/java/org/wamblee/system/adapters/SetterConfiguration.java index 57323a54..77fd9720 100644 --- a/system/general/src/main/java/org/wamblee/system/adapters/SetterConfiguration.java +++ b/system/general/src/main/java/org/wamblee/system/adapters/SetterConfiguration.java @@ -47,9 +47,9 @@ import org.wamblee.system.core.SystemAssemblyException; public class SetterConfiguration { private Class _class; - private boolean _publicOnly; + private boolean publicOnly; - private Map _setters; + private Map setters; /** * Constructs the setter configuration. By default no setters are added. @@ -59,17 +59,17 @@ public class SetterConfiguration { */ public SetterConfiguration(Class aClass) { _class = aClass; - _publicOnly = true; - _setters = new HashMap(); + publicOnly = true; + setters = new HashMap(); } /** * Makes sure that all available setters are used. */ public SetterConfiguration initAllSetters() { - _setters.clear(); - for (Method method: getAllSetters(_class, _publicOnly) ) { - _setters.put(method, createParameterValues(method)); + setters.clear(); + for (Method method: getAllSetters(_class, publicOnly) ) { + setters.put(method, createParameterValues(method)); } return this; } @@ -82,7 +82,7 @@ public class SetterConfiguration { * Non public flag. */ public SetterConfiguration setNonPublic(boolean aIsNonPublic) { - _publicOnly = !aIsNonPublic; + publicOnly = !aIsNonPublic; return this; } @@ -92,7 +92,7 @@ public class SetterConfiguration { * @return Reference to the current object to allow call chaining. */ public SetterConfiguration clear() { - _setters.clear(); + setters.clear(); return this; } @@ -104,9 +104,9 @@ public class SetterConfiguration { * @return Reference to the current object to allow call chaining. */ public SetterConfiguration remove(String aName) { - for (Method method : _setters.keySet()) { + for (Method method : setters.keySet()) { if (method.getName().equals(aName)) { - _setters.remove(method); + setters.remove(method); return this; } } @@ -123,9 +123,9 @@ public class SetterConfiguration { if ( !aMethod.getDeclaringClass().isAssignableFrom(_class) ) { throw new RuntimeException("Method " + aMethod + " not found in class " + _class + " or its superclasses"); } - for (Method method : _setters.keySet()) { + for (Method method : setters.keySet()) { if (method.equals(aMethod)) { - _setters.remove(method); + setters.remove(method); return this; } } @@ -140,9 +140,9 @@ public class SetterConfiguration { * @return Reference to the current object to allow call chaining. */ public SetterConfiguration add(final String aName) { - int oldlen = _setters.size(); + int oldlen = setters.size(); List methods = new ArrayList(); - CollectionFilter.filter(getAllSetters(_class, _publicOnly), methods, + CollectionFilter.filter(getAllSetters(_class, publicOnly), methods, new Condition() { @Override public boolean matches(Method aObject) { @@ -156,7 +156,7 @@ public class SetterConfiguration { } // TODO is it possible to get more than one setter here in case the subclass overrides // the baseclass method? - _setters.put(methods.get(0), createParameterValues(methods.get(0))); + setters.put(methods.get(0), createParameterValues(methods.get(0))); return this; } @@ -173,7 +173,7 @@ public class SetterConfiguration { */ public SetterConfiguration addSetter(final Class aType) { List result = new ArrayList(); - CollectionFilter.filter(getAllSetters(_class, _publicOnly), result, + CollectionFilter.filter(getAllSetters(_class, publicOnly), result, new Condition() { @Override public boolean matches(Method aObject) { @@ -199,7 +199,7 @@ public class SetterConfiguration { + setters); } Method method = result.get(0); - _setters.put(method, createParameterValues(method)); + setters.put(method, createParameterValues(method)); return this; } @@ -244,8 +244,8 @@ public class SetterConfiguration { */ public List getRequiredInterfaces() { List result = new ArrayList(); - for (Method method : _setters.keySet()) { - result.addAll(_setters.get(method).getRequiredInterfaces()); + for (Method method : setters.keySet()) { + result.addAll(setters.get(method).getRequiredInterfaces()); } return result; } @@ -263,8 +263,8 @@ public class SetterConfiguration { throw new IllegalArgumentException("Object '" + aObject + "' is not an instance of " + _class.getName()); } - for (Method method : _setters.keySet()) { - ParameterValues values = _setters.get(method); + for (Method method : setters.keySet()) { + ParameterValues values = setters.get(method); try { method.invoke(aObject, values.values(aScope)); @@ -288,9 +288,9 @@ public class SetterConfiguration { * @return Parameter values. */ public ParameterValues values(String aMethod) { - for (Method method : _setters.keySet()) { + for (Method method : setters.keySet()) { if (method.getName().equals(aMethod)) { - return _setters.get(method); + return setters.get(method); } } throw new IllegalArgumentException("No setter method '" + aMethod @@ -298,6 +298,6 @@ public class SetterConfiguration { } public List getSetters() { - return new ArrayList(_setters.keySet()); + return new ArrayList(setters.keySet()); } }