source code formatting.
[utils] / system / general / src / main / java / org / wamblee / system / adapters / ParameterValues.java
index fa0f008e55058314339a42c79f8b674064daf4cc..4b561c3e2f9fceddfc3466069b2657ce48d83dc7 100644 (file)
@@ -1,54 +1,68 @@
 /*
  * Copyright 2008 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 java.util.ArrayList;
-import java.util.List;
-
 import org.wamblee.system.core.DefaultRequiredInterface;
 import org.wamblee.system.core.RequiredInterface;
 import org.wamblee.system.core.Scope;
 
+import java.util.ArrayList;
+import java.util.List;
+
+
 /**
- * Represents parameter values for a method or constructor and allows for the configuration
- * of how these values are retrieved. 
- * 
+ * Represents parameter values for a method or constructor and allows for
+ * the configuration of how these values are retrieved.
+ *
  * @author Erik Brakkee
  */
 public class ParameterValues {
-    private String[] names; 
-       private Class[] types;
-       private ValueProvider[] values;
-
-       /**
-        * Constructs the configuration. By default no constructor is selected and 
-        * one of {@link #select(Class...)} or 
-        * {@link #greedy()} must be called.  
-        * @param aClass Class to construct. 
-        */
-       public ParameterValues(Class[] aTypes) {
-           names = new String[aTypes.length];
-           for (int i = 0; i < aTypes.length; i++) { 
-               names[i] = "arg" + i; 
-           }
-               types = aTypes; 
-               resetValues();   
-       }
-       
-       /**
+    /**
+     * DOCUMENT ME!
+     */
+    private String[] names;
+
+    /**
+     * DOCUMENT ME!
+     */
+    private Class[] types;
+
+    /**
+     * DOCUMENT ME!
+     */
+    private ValueProvider[] values;
+
+/**
+         * Constructs the configuration. By default no constructor is selected and 
+         * one of {@link #select(Class...)} or 
+         * {@link #greedy()} must be called.  
+         * @param aClass Class to construct. 
+         */
+    public ParameterValues(Class[] aTypes) {
+        names = new String[aTypes.length];
+
+        for (int i = 0; i < aTypes.length; i++) {
+            names[i] = "arg" + i;
+        }
+
+        types = aTypes;
+        resetValues();
+    }
+
+/**
      * Constructs the configuration. By default no constructor is selected and 
      * one of {@link #select(Class...)} or 
      * {@link #greedy()} must be called.
@@ -56,77 +70,95 @@ public class ParameterValues {
      * @param aClass Class to construct. 
      */
     public ParameterValues(String[] aNames, Class[] aTypes) {
-        assert aNames.length == aTypes.length; 
-        names = aNames;
-        types = aTypes; 
-        resetValues();   
+        assert aNames.length == aTypes.length;
+        names     = aNames;
+        types     = aTypes;
+        resetValues();
+    }
+
+    /**
+     * The types of the parameter values.
+     *
+     * @return Types.
+     */
+    public Class[] getTypes() {
+        return types;
+    }
+
+    /**
+     * Sets argument i to be optional, meaning that null is allowed to
+     * be passed in.
+     *
+     * @param aArg Argument to set.
+     *
+     * @return DOCUMENT ME!
+     */
+    public ParameterValues setOptional(int aArg) {
+        values[aArg] = new RequiredInterfaceProvider(new DefaultRequiredInterface(
+                    "arg" + aArg, types[aArg], true));
+
+        return this;
+    }
+
+    /**
+     * Sets the argument i to a fixed value.
+     *
+     * @param aArg Argument to set.
+     * @param aValue Value.
+     *
+     * @return DOCUMENT ME!
+     */
+    public ParameterValues setValue(int aArg, Object aValue) {
+        values[aArg] = new FixedValueProvider(aValue);
+
+        return this;
+    }
+
+    /**
+     * Resets the values.
+     */
+    private void resetValues() {
+        values = new ValueProvider[types.length];
+
+        for (int i = 0; i < values.length; i++) {
+            values[i] = new RequiredInterfaceProvider(new DefaultRequiredInterface(
+                        names[i], types[i]));
+        }
+    }
+
+    /**
+     * Gets the required interfaces to provide values that are not
+     * provided in another way.
+     *
+     * @return Required interfaces.
+     */
+    public List<RequiredInterface> getRequiredInterfaces() {
+        List<RequiredInterface> result = new ArrayList<RequiredInterface>();
+
+        for (ValueProvider provider : values) {
+            if (provider instanceof RequiredInterfaceProvider) {
+                result.add(((RequiredInterfaceProvider) provider)
+                    .getRequiredInterface());
+            }
+        }
+
+        return result;
+    }
+
+    /**
+     * Returns the values to use in the given scope.
+     *
+     * @param aScope Scope within which to retrieve the values.
+     *
+     * @return Values.
+     */
+    public Object[] values(Scope aScope) {
+        Object[] valueArray = new Object[values.length];
+
+        for (int i = 0; i < values.length; i++) {
+            valueArray[i] = values[i].getValue(aScope);
+        }
+
+        return valueArray;
     }
-       
-       /**
-        * The types of the parameter values. 
-        * @return Types. 
-        */
-       public Class[] getTypes() {
-               return types;
-       }
-       
-       /**
-        * Sets argument i to be optional, meaning that null is allowed to be passed in.  
-        * @param aArg Argument to set.
-        */
-       public ParameterValues setOptional(int aArg) { 
-               values[aArg] = new RequiredInterfaceProvider(new DefaultRequiredInterface(
-                               "arg" + aArg, types[aArg], true));
-               return this; 
-       }
-       
-       /**
-        * Sets the argument i to a fixed value.  
-        * @param aArg Argument to set. 
-        * @param aValue Value. 
-        */
-       public ParameterValues setValue(int aArg, Object aValue) { 
-               values[aArg] = new FixedValueProvider(aValue);
-               return this; 
-       }
-       
-       /**
-        * Resets the values. 
-        */
-       private void resetValues() { 
-               values = new ValueProvider[types.length];
-               for (int i = 0; i < values.length; i++) { 
-                       values[i] = new RequiredInterfaceProvider(new DefaultRequiredInterface(
-                                       names[i], types[i]));
-               }
-       }
-       
-       /**
-        * Gets the required interfaces to provide values that are not provided
-        * in another way. 
-        * @return Required interfaces. 
-        */
-       public List<RequiredInterface> getRequiredInterfaces() { 
-               List<RequiredInterface> result = new ArrayList<RequiredInterface>(); 
-               for (ValueProvider provider: values) { 
-                       if ( provider instanceof RequiredInterfaceProvider) { 
-                               result.add( ((RequiredInterfaceProvider)provider).getRequiredInterface());
-                       }
-               }
-               return result; 
-       }
-
-       /**
-        * Returns the values to use in the given scope. 
-        * @param aScope Scope within which to retrieve the values. 
-        * @return Values. 
-        */
-       public Object[] values(Scope aScope) {
-               Object[] valueArray = new Object[values.length];
-               for (int i = 0; i < values.length; i++) {
-                       valueArray[i] = values[i].getValue(aScope);
-               }
-               return valueArray; 
-       }
-       
 }