Class ClassWrapper

  • All Implemented Interfaces:
    IMetaType

    public class ClassWrapper
    extends java.lang.Object
    implements IMetaType
    Wraps the public static methods into VIL operation descriptors.
    Author:
    Holger Eichelberger
    • Constructor Detail

      • ClassWrapper

        public ClassWrapper​(java.lang.Class<?> cls,
                            TypeRegistry registry)
        Creates a new class wrapper for the given class.
        Parameters:
        cls - the class to be wrapped
        registry - the registry this wrapper is registered with
    • Method Detail

      • getName

        public java.lang.String getName()
        Description copied from interface: IMetaType
        Returns the (simple) name of this type.
        Specified by:
        getName in interface IMetaType
        Returns:
        the simple name
      • getQualifiedName

        public java.lang.String getQualifiedName()
        Description copied from interface: IMetaType
        Returns the qualified name of this type.
        Specified by:
        getQualifiedName in interface IMetaType
        Returns:
        the qualified name
      • getOperationsCount

        public int getOperationsCount()
        Description copied from interface: IMetaType
        Returns the number of operations provided by this type.
        Specified by:
        getOperationsCount in interface IMetaType
        Returns:
        the number of operations
      • getOperation

        public IMetaOperation getOperation​(int index)
        Description copied from interface: IMetaType
        Returns the specified operation.
        Specified by:
        getOperation in interface IMetaType
        Parameters:
        index - the 0-based index of the operation to be returned
        Returns:
        the specified operation
      • isAssignableFrom

        public boolean isAssignableFrom​(IMetaType type)
        Description copied from interface: IMetaType
        Returns whether this type is the same or a super class of type.
        Specified by:
        isAssignableFrom in interface IMetaType
        Parameters:
        type - the descriptor to be tested
        Returns:
        true if both types are assignment compatible, false else
      • findConversion

        public IMetaOperation findConversion​(IMetaType sourceType,
                                             IMetaType targetType)
        Description copied from interface: IMetaType
        Returns the conversion operation from this type to target type (if there is any).
        Specified by:
        findConversion in interface IMetaType
        Parameters:
        sourceType - the source type to convert from
        targetType - the target type to convert to
        Returns:
        the conversion operation as defined in the underlying implementation class, null if no matching can be found
      • isBasicType

        public boolean isBasicType()
        Description copied from interface: IMetaType
        Returns whether this instance represents a basic type.
        Specified by:
        isBasicType in interface IMetaType
        Returns:
        true if this instance represents a basic type, false else
      • getTypeRegistry

        public TypeRegistry getTypeRegistry()
        Description copied from interface: IMetaType
        Returns the type registry this type was registered by.
        Specified by:
        getTypeRegistry in interface IMetaType
        Returns:
        the type registry
      • enableDynamicDispatch

        public boolean enableDynamicDispatch()
        Description copied from interface: IMetaType
        Returns whether this type enables dynamic dispatch of operations.
        Specified by:
        enableDynamicDispatch in interface IMetaType
        Returns:
        true if it enables dynamic dispatch, false else
      • isPlaceholder

        public boolean isPlaceholder()
        Description copied from interface: IMetaType
        Returns whether this type is valid or whether it is a placeholder type in case that the original type cannot be resolved but the script shall remain executable.
        Specified by:
        isPlaceholder in interface IMetaType
        Returns:
        true if this type is a placeholder, false else
      • addPlaceholderOperation

        public IMetaOperation addPlaceholderOperation​(java.lang.String name,
                                                      int parameterCount,
                                                      boolean acceptsNamedParameters)
        Description copied from interface: IMetaType
        Adds a placeholder operation, i.e., in case that the original operation cannot be resolved but the script shall remain executable.
        Specified by:
        addPlaceholderOperation in interface IMetaType
        Parameters:
        name - the name of the operation
        parameterCount - the number of parameters of the operation
        acceptsNamedParameters - whether the operation shall accept named parameters
        Returns:
        the added operation, null if this type is not a placeholder
      • isActualTypeOf

        public boolean isActualTypeOf​(IMetaType type)
        Description copied from interface: IMetaType
        Returns whether this type can act as an actual type of type.
        Specified by:
        isActualTypeOf in interface IMetaType
        Parameters:
        type - the type to be checked
        Returns:
        true if this type can act as an actual type of type, false else
        See Also:
        IActualTypeProvider
      • getBaseType

        public IMetaType getBaseType()
        Description copied from interface: IMetaType
        Returns the base type (in case of IVML derived types).
        Specified by:
        getBaseType in interface IMetaType
        Returns:
        the base type or null
      • getFieldCount

        public int getFieldCount()
        Description copied from interface: IMetaType
        Returns the number of fields provided by this type.
        Specified by:
        getFieldCount in interface IMetaType
        Returns:
        the number of fields
      • getField

        public IMetaField getField​(int index)
        Description copied from interface: IMetaType
        Returns the specified field.
        Specified by:
        getField in interface IMetaType
        Parameters:
        index - the 0-based index of the field to be returned
        Returns:
        the specified field
      • isInternal

        public boolean isInternal()
        Description copied from interface: IMetaType
        Returns whether this type is internal and shall not be visible to the user.
        Specified by:
        isInternal in interface IMetaType
        Returns:
        true if this type is internal, false else
      • getWrappedClass

        public java.lang.Class<?> getWrappedClass()
        Returns the class of the wrapped class.
        Returns:
        class
      • getSuperType

        public IMetaType getSuperType()
        Description copied from interface: IMetaType
        Returns the type this type is refined from.
        Specified by:
        getSuperType in interface IMetaType
        Returns:
        the super type or null if there is none
      • getGenericParameterCount

        public int getGenericParameterCount()
        Description copied from interface: IMetaType
        Returns the number of generic type parameters.
        Specified by:
        getGenericParameterCount in interface IMetaType
        Returns:
        the number of generic type parameters
      • getGenericParameterType

        public TypeDescriptor<?> getGenericParameterType​(int index)
        Description copied from interface: IMetaType
        Returns the specified generic parameter type.
        Specified by:
        getGenericParameterType in interface IMetaType
        Parameters:
        index - the index of the parameter type to return
        Returns:
        the specified parameter type
      • checkConversion

        public boolean checkConversion​(IMetaType param,
                                       IMetaOperation conversion)
        Description copied from interface: IMetaType
        Checks a conversion from this type to param via the given conversion.
        Specified by:
        checkConversion in interface IMetaType
        Parameters:
        param - the original parameter value
        conversion - the conversion function
        Returns:
        true if ok, false else
      • getCandidates

        public java.util.List<IMetaOperation> getCandidates​(java.lang.String name,
                                                            int unnamedArgsCount)
        Description copied from interface: IMetaType
        Returns operation candidates matching the given name and number of unnamed (required) arguments.
        Specified by:
        getCandidates in interface IMetaType
        Parameters:
        name - the name of the operation
        unnamedArgsCount - the number of unnamed arguments
        Returns:
        the operation candidates