Package cdc.args

Class Arg


  • public final class Arg
    extends Object
    Effective argument.

    It is a (name, value) pair.

    Author:
    Damien Carbonne
    • Constructor Detail

      • Arg

        public Arg​(String name,
                   Object value)
        Creates an effective argument.

        No check is done on argument value.

        Parameters:
        name - The name. It must be valid.
        value - the value.
        Throws:
        IllegalArgumentException - When name is invalid.
      • Arg

        public Arg​(FormalArg<T> farg,
                   T value)
        Creates an effective argument that is compliant with a formal argument.
        Type Parameters:
        T - The formal argument type.
        Parameters:
        farg - The formal argument.
        value - The value.
        Throws:
        IllegalArgumentException - When farg is null or value is not compliant with farg.
    • Method Detail

      • getName

        public String getName()
        Returns:
        The name.
      • getValue

        public Object getValue()
        Returns:
        The value.
      • getValue

        public Object getValue​(Object def)
        Returns the value or a default value.
        Parameters:
        def - The default value.
        Returns:
        The value or def if value is null.
      • getValue

        public <T> T getValue​(Class<T> cls)
        Returns the value cast to a target class.
        Type Parameters:
        T - The target type.
        Parameters:
        cls - The target class.
        Returns:
        The cast of value to cls.
      • getValue

        public <T> T getValue​(Class<T> cls,
                              T def)
        Returns the value cast to a target class or a default value.
        Type Parameters:
        T - The target type.
        Parameters:
        cls - The target class.
        def - The default value.
        Returns:
        The value cats to cls or def if value is null.
      • isCompliantWith

        public boolean isCompliantWith​(FormalArg<?> farg)
      • isCompliantWith

        public boolean isCompliantWith​(FormalArgs fargs)
      • isCompliantWith

        public boolean isCompliantWith​(Class<?> cls)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object