Added SetterConfiguration class for configuring how setters correspond to required...
[utils] / system / general / src / main / java / org / wamblee / system / adapters / ParameterValues.java
index 609f9d2586dbbce17b143aad3254e3ab384fdfea..1778981875ce07cff6286b1fdebc73781d92bfb8 100644 (file)
@@ -29,6 +29,7 @@ import org.wamblee.system.core.Scope;
  * @author Erik Brakkee
  */
 public class ParameterValues {
+    private String[] _names; 
        private Class[] _types;
        private ValueProvider[] _values;
 
@@ -39,10 +40,32 @@ public class ParameterValues {
         * @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.
+     * @param aNames Names of the arguments.   
+     * @param aClass Class to construct. 
+     */
+    public ParameterValues(String[] aNames, Class[] aTypes) {
+        assert aNames.length == aTypes.length; 
+        _names = aNames;
+        _types = aTypes; 
+        resetValues();   
+    }
+       
+       /**
+        * The types of the parameter values. 
+        * @return Types. 
+        */
        public Class[] getTypes() {
                return _types;
        }
@@ -74,10 +97,15 @@ public class ParameterValues {
                _values = new ValueProvider[_types.length];
                for (int i = 0; i < _values.length; i++) { 
                        _values[i] = new RequiredInterfaceProvider(new DefaultRequiredInterface(
-                                       "arg" + i, _types[i]));
+                                       _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) { 
@@ -88,6 +116,11 @@ public class ParameterValues {
                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[] values = new Object[_values.length];
                for (int i = 0; i < _values.length; i++) {