Class ComponentParameter

  • All Implemented Interfaces:
    java.io.Serializable, Parameter

    public class ComponentParameter
    extends BasicComponentParameter
    A ComponentParameter should be used to pass in a particular component as argument to a different component's constructor. This is particularly useful in cases where several components of the same type have been registered, but with a different key. Passing a ComponentParameter as a parameter when registering a component will give PicoContainer a hint about what other component to use in the constructor. Collecting parameter types are supported for Array,Collectionand Map.
    Author:
    Jon Tirsén, Aslak Hellesøy, Jörg Schaible, Thomas Heller
    See Also:
    Serialized Form
    • Field Detail

      • DEFAULT

        public static final ComponentParameter DEFAULT
        DEFAULT is an instance of ComponentParameter using the default constructor.
      • ARRAY_ALLOW_EMPTY

        public static final ComponentParameter ARRAY_ALLOW_EMPTY
        Use ARRAY_ALLOW_EMPTY as Parameterfor an Array that may have no elements.
    • Constructor Detail

      • ComponentParameter

        public ComponentParameter​(java.lang.Object componentKey)
        Expect a parameter matching a component of a specific key.
        Parameters:
        componentKey - the key of the desired addComponent
      • ComponentParameter

        public ComponentParameter()
        Expect any scalar parameter of the appropriate type or an Array.
      • ComponentParameter

        public ComponentParameter​(boolean emptyCollection)
        Expect any scalar parameter of the appropriate type or an Array. Resolve the parameter even if no compnoent is of the array's component type.
        Parameters:
        emptyCollection - true allows an Array to be empty
      • ComponentParameter

        public ComponentParameter​(java.lang.Class componentValueType,
                                  boolean emptyCollection)
        Expect any scalar parameter of the appropriate type or the collecting type Array,Collectionor Map. The components in the collection will be of the specified type.
        Parameters:
        componentValueType - the component's type (ignored for an Array)
        emptyCollection - true allows the collection to be empty
      • ComponentParameter

        public ComponentParameter​(java.lang.Class componentKeyType,
                                  java.lang.Class componentValueType,
                                  boolean emptyCollection)
        Expect any scalar parameter of the appropriate type or the collecting type Array,Collectionor Map. The components in the collection will be of the specified type and their adapter's key must have a particular type.
        Parameters:
        componentKeyType - the component adapter's key type
        componentValueType - the component's type (ignored for an Array)
        emptyCollection - true allows the collection to be empty