X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=system%2Fgeneral%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fsystem%2Fadapters%2FSetterConfiguration.java;h=c8baeafb9dcdef0e4b117d49d783c43564712613;hb=5e33a52ba36ac928b9863ddd79d2d09f6a308af6;hp=af9da338a5c9526b8375a5ec4b0187d011c752e7;hpb=8de36ff0206c996baf3ee4adc3e2293b12ff5f39;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 af9da338..c8baeafb 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 @@ -1,18 +1,18 @@ /* - * Copyright 2008 the original author or authors. - * + * Copyright 2005-2010 the original author or authors. + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.system.adapters; import org.wamblee.collections.CollectionFilter; @@ -51,7 +51,7 @@ import java.util.Set; * @author Erik Brakkee */ public class SetterConfiguration { - private Class _class; + private Class clazz; private boolean publicOnly; @@ -64,7 +64,7 @@ public class SetterConfiguration { * Class which is being configured. */ public SetterConfiguration(Class aClass) { - _class = aClass; + clazz = aClass; publicOnly = true; setters = new HashMap(); } @@ -76,7 +76,7 @@ public class SetterConfiguration { public SetterConfiguration initAllSetters() { setters.clear(); - for (Method method : getAllSetters(_class, publicOnly)) { + for (Method method : getAllSetters(clazz, publicOnly)) { setters.put(method, createParameterValues(method)); } @@ -140,9 +140,9 @@ public class SetterConfiguration { * */ public SetterConfiguration remove(Method aMethod) { - if (!aMethod.getDeclaringClass().isAssignableFrom(_class)) { + if (!aMethod.getDeclaringClass().isAssignableFrom(clazz)) { throw new RuntimeException("Method " + aMethod + - " not found in class " + _class + " or its superclasses"); + " not found in class " + clazz + " or its superclasses"); } for (Method method : setters.keySet()) { @@ -169,7 +169,7 @@ public class SetterConfiguration { public SetterConfiguration add(final String aName) { int oldlen = setters.size(); List methods = new ArrayList(); - CollectionFilter.filter(getAllSetters(_class, publicOnly), methods, + CollectionFilter.filter(getAllSetters(clazz, publicOnly), methods, new Condition() { @Override public boolean matches(Method aObject) { @@ -179,7 +179,7 @@ public class SetterConfiguration { if (methods.size() == 0) { throw new IllegalArgumentException("Method '" + aName + - "' not found in " + _class.getName()); + "' not found in " + clazz.getName()); } // TODO is it possible to get more than one setter here in case the @@ -205,7 +205,7 @@ public class SetterConfiguration { */ public SetterConfiguration addSetter(final Class aType) { List result = new ArrayList(); - CollectionFilter.filter(getAllSetters(_class, publicOnly), result, + CollectionFilter.filter(getAllSetters(clazz, publicOnly), result, new Condition() { @Override public boolean matches(Method aObject) { @@ -217,7 +217,7 @@ public class SetterConfiguration { if (result.size() == 0) { throw new IllegalArgumentException("No setter found in class '" + - _class.getName() + "' that has a setter with argument type '" + + clazz.getName() + "' that has a setter with argument type '" + aType.getName() + "'"); } @@ -229,7 +229,7 @@ public class SetterConfiguration { } throw new IllegalArgumentException( - "Multiple setters found in class '" + _class.getName() + + "Multiple setters found in class '" + clazz.getName() + " that accept type '" + aType.getName() + "': " + setters); } @@ -301,9 +301,9 @@ public class SetterConfiguration { * */ public void inject(Scope aScope, Object aObject) { - if (!_class.isInstance(aObject)) { + if (!clazz.isInstance(aObject)) { throw new IllegalArgumentException("Object '" + aObject + - "' is not an instance of " + _class.getName()); + "' is not an instance of " + clazz.getName()); } for (Method method : setters.keySet()) {