X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=system%2Fgeneral%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fsystem%2Fadapters%2FConstructorConfiguration.java;h=4e22bc5ff3249ffd1d349f78f2e393d5d130a66c;hb=8de36ff0206c996baf3ee4adc3e2293b12ff5f39;hp=d5256cc88315a7757249291b87c2a06cbaee2720;hpb=89c06d4d52b46c154128c97d6e758fa1f4fc7a6e;p=utils diff --git a/system/general/src/main/java/org/wamblee/system/adapters/ConstructorConfiguration.java b/system/general/src/main/java/org/wamblee/system/adapters/ConstructorConfiguration.java index d5256cc8..4e22bc5f 100644 --- a/system/general/src/main/java/org/wamblee/system/adapters/ConstructorConfiguration.java +++ b/system/general/src/main/java/org/wamblee/system/adapters/ConstructorConfiguration.java @@ -30,73 +30,60 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; - /** - * Class that allows configuration of the constructor to use. In - * particular, it provides: - * + * Class that allows configuration of the constructor to use. In particular, it + * provides: + * */ public class ConstructorConfiguration { - /** - * DOCUMENT ME! - */ private Class clazz; - /** - * DOCUMENT ME! - */ private Constructor constructor; - /** - * DOCUMENT ME! - */ private ParameterValues values; - /** - * DOCUMENT ME! - */ private boolean publicOnly; -/** - * Constructs the configuration. By default the public constructor with the - * most arguments will be used. - * @param aClass Class to construct. - */ + /** + * Constructs the configuration. By default the public constructor with the + * most arguments will be used. + * + * @param aClass + * Class to construct. + */ public ConstructorConfiguration(Class aClass) { - clazz = aClass; - constructor = null; - publicOnly = true; + clazz = aClass; + constructor = null; + publicOnly = true; } /** - * Sets whether or no non public constructors are also considered. - * Reset the choice of a constructor to its default. - * + * Sets whether or no non public constructors are also considered. Reset the + * choice of a constructor to its default. + * * @param aNonPublic - * + * * @return */ public ConstructorConfiguration setNonPublic(boolean aNonPublic) { - publicOnly = !aNonPublic; - constructor = null; - values = null; + publicOnly = !aNonPublic; + constructor = null; + values = null; return this; } /** * Selects an explicit constructor. - * + * * @return Return the injector to allow call chaining. - * - * @throws SystemAssemblyException DOCUMENT ME! + * */ public ConstructorConfiguration select(Class... aTypes) { try { @@ -112,21 +99,21 @@ public class ConstructorConfiguration { /** * Selects the greediest constructor. - * + * * @return The injector to allow call chaining. - * - * @throws SystemAssemblyException if the greediest constructor cannot be - * uniquely identified. + * + * @throws SystemAssemblyException + * if the greediest constructor cannot be uniquely identified. */ public ConstructorConfiguration greedy() { Constructor[] declared = clazz.getDeclaredConstructors(); if (declared.length == 0) { - throw new SystemAssemblyException("Class '" + clazz - + " is an interface, primitive type, or array"); + throw new SystemAssemblyException("Class '" + clazz + + " is an interface, primitive type, or array"); } - int max = -1; + int max = -1; List> checked = new ArrayList>(); CollectionFilter.filter(Arrays.asList(declared), checked, new Condition>() { @@ -146,8 +133,8 @@ public class ConstructorConfiguration { } } - final int max2 = max; - List> ctors = checked; + final int max2 = max; + List> ctors = checked; List> longest = new ArrayList>(); CollectionFilter.filter(ctors, longest, new Condition>() { @@ -184,12 +171,12 @@ public class ConstructorConfiguration { /** * Creates the object in the given scope. - * - * @param aScope Scope containing required interfaces for this object. - * + * + * @param aScope + * Scope containing required interfaces for this object. + * * @return object. - * - * @throws SystemAssemblyException DOCUMENT ME! + * */ public Object create(Scope aScope) { Object[] valueArray = values.values(aScope); @@ -197,8 +184,8 @@ public class ConstructorConfiguration { try { return getConstructor().newInstance(valueArray); } catch (Exception e) { - throw new SystemAssemblyException("Could not construct object " - + getConstructor() + " " + Arrays.asList(valueArray), e); + throw new SystemAssemblyException("Could not construct object " + + getConstructor() + " " + Arrays.asList(valueArray), e); } }