Class ClassListParameter<C>

  • Type Parameters:
    C - Class type
    All Implemented Interfaces:
    Parameter<java.util.List<java.lang.Class<? extends C>>>
    Direct Known Subclasses:
    ObjectListParameter

    public class ClassListParameter<C>
    extends ListParameter<ClassListParameter<C>,​java.util.List<java.lang.Class<? extends C>>>
    Parameter class for a parameter specifying a list of class names.
    Since:
    0.1
    Author:
    Steffi Wanka, Erich Schubert
    • Field Detail

      • restrictionClass

        protected java.lang.Class<C> restrictionClass
        The restriction class for the list of class names.
    • Constructor Detail

      • ClassListParameter

        public ClassListParameter​(OptionID optionID,
                                  java.lang.Class<?> restrictionClass)
        Constructs a class list parameter with the given optionID and restriction class.
        Parameters:
        optionID - the unique id of this parameter
        restrictionClass - the restriction class of the list of class names
    • Method Detail

      • getValueAsString

        public java.lang.String getValueAsString()
        Description copied from interface: Parameter
        Get the value as string. May return null
        Returns:
        Value as string
      • formatValue

        protected java.lang.String formatValue​(java.util.List<java.lang.Class<? extends C>> val)
        Format as string.
        Parameters:
        val - Value to format
        Returns:
        String
      • parseValue

        protected java.util.List<java.lang.Class<? extends C>> parseValue​(java.lang.Object obj)
                                                                   throws ParameterException
        Description copied from class: AbstractParameter
        Parse a given value into the destination type.
        Specified by:
        parseValue in class AbstractParameter<ClassListParameter<C>,​java.util.List<java.lang.Class<? extends C>>>
        Parameters:
        obj - Object to parse (may be a string representation!)
        Returns:
        Parsed object
        Throws:
        ParameterException - when the object cannot be parsed.
      • validate

        protected boolean validate​(java.util.List<java.lang.Class<? extends C>> obj)
                            throws ParameterException
        Description copied from class: AbstractParameter
        Validate a value after parsing (e.g., do constraint checks!)
        Overrides:
        validate in class AbstractParameter<ClassListParameter<C>,​java.util.List<java.lang.Class<? extends C>>>
        Parameters:
        obj - Object to validate
        Returns:
        true iff the object is valid for this parameter.
        Throws:
        ParameterException - when the object is not valid.
      • getRestrictionClass

        public java.lang.Class<C> getRestrictionClass()
        Returns the restriction class of this class parameter.
        Returns:
        the restriction class of this class parameter.
      • getKnownImplementations

        public java.util.List<java.lang.Class<?>> getKnownImplementations()
        Get an iterator over all known implementations of the class restriction.
        Returns:
        List object
      • getSyntax

        public java.lang.String getSyntax()
        Returns a string representation of the parameter's type.
        Returns:
        "<class_1,...,class_n>"
      • instantiateClasses

        public java.util.List<C> instantiateClasses​(Parameterization config)
        Returns a list of new instances for the value (i.e., the class name) of this class list parameter. The instances have the type of the restriction class of this class list parameter.

        If the Class for the class names is not found, the instantiation is tried using the package of the restriction class as package of the class name.

        Parameters:
        config - Parameterization to use (if Parameterizable))
        Returns:
        a list of new instances for the value of this class list parameter
      • grab

        public boolean grab​(Parameterization config,
                            java.util.function.Consumer<java.util.List<? extends C>> consumer)
        Get the parameter.
        Parameters:
        config - Parameterization
        consumer - Output consumer
        Returns:
        true if valid