Class ReflectionFieldDescriptor

  • All Implemented Interfaces:
    IMetaField

    public class ReflectionFieldDescriptor
    extends FieldDescriptor
    Implements a reflection field descriptor.
    Author:
    Holger Eichelberger
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.reflect.Field field  
      private boolean readOnly  
    • Constructor Summary

      Constructors 
      Constructor Description
      ReflectionFieldDescriptor​(TypeDescriptor<?> declaringType, java.lang.reflect.Field field, java.lang.Class<?>[] typeGenerics)
      Creates a new reflection field descriptor taking the information from field.
      ReflectionFieldDescriptor​(TypeDescriptor<?> declaringType, java.lang.reflect.Field field, java.lang.String name, boolean readOnly, java.lang.Class<?>[] typeGenerics)
      Creates a new reflection field descriptor.
      ReflectionFieldDescriptor​(TypeDescriptor<?> declaringType, java.lang.reflect.Field field, java.lang.String name, java.lang.Class<?>[] typeGenerics)
      Creates a new reflection field descriptor taking the information from field.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getJavaSignature()
      Returns the java-like signature of this operation.
      java.lang.Object getValue​(java.lang.Object owner)
      Returns the actual value of this field.
      boolean isReadOnly()
      Returns whether the field is read-only.
      boolean isStatic()
      Returns whether the field is static.
      void setValue​(java.lang.Object owner, java.lang.Object value)
      Changes the actual value for this field in owner.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • field

        private java.lang.reflect.Field field
      • readOnly

        private boolean readOnly
    • Constructor Detail

      • ReflectionFieldDescriptor

        public ReflectionFieldDescriptor​(TypeDescriptor<?> declaringType,
                                         java.lang.reflect.Field field,
                                         java.lang.Class<?>[] typeGenerics)
        Creates a new reflection field descriptor taking the information from field.
        Parameters:
        declaringType - the declaring type
        field - the field
        typeGenerics - the generics of the field type (may be null)
      • ReflectionFieldDescriptor

        public ReflectionFieldDescriptor​(TypeDescriptor<?> declaringType,
                                         java.lang.reflect.Field field,
                                         java.lang.String name,
                                         java.lang.Class<?>[] typeGenerics)
        Creates a new reflection field descriptor taking the information from field.
        Parameters:
        declaringType - the declaring type
        field - the field
        name - the explicit name of the field (may be null to take the name of field)
        typeGenerics - the generics of the field type (may be null)
      • ReflectionFieldDescriptor

        public ReflectionFieldDescriptor​(TypeDescriptor<?> declaringType,
                                         java.lang.reflect.Field field,
                                         java.lang.String name,
                                         boolean readOnly,
                                         java.lang.Class<?>[] typeGenerics)
        Creates a new reflection field descriptor.
        Parameters:
        declaringType - the declaring type
        field - the field
        name - the name the field shall be accessible
        readOnly - whether the field is readonly
        typeGenerics - the generics of the field type (may be null)
    • Method Detail

      • getJavaSignature

        public java.lang.String getJavaSignature()
        Description copied from interface: IMetaField
        Returns the java-like signature of this operation.
        Returns:
        the java-like Java signature of this operation
      • isReadOnly

        public boolean isReadOnly()
        Description copied from interface: IMetaField
        Returns whether the field is read-only. Please note that this method provides a "static" information, i.e., it cannot change during script execution. If a field can be modified at all, this method shall return true and determine when the value is changed, whether the actual access is permitted. In contrast, if it is known that the field cannot be changed at all, this method shall return false.
        Returns:
        true if the field is read-only, false else
      • isStatic

        public boolean isStatic()
        Description copied from interface: IMetaField
        Returns whether the field is static.
        Returns:
        true if the field is static, false else
      • getValue

        public java.lang.Object getValue​(java.lang.Object owner)
                                  throws VilException
        Description copied from class: FieldDescriptor
        Returns the actual value of this field.
        Specified by:
        getValue in class FieldDescriptor
        Parameters:
        owner - the owning object (ignored, i.e., shall be null, if IMetaField.isStatic())
        Returns:
        the actual value
        Throws:
        VilException - in case that retrieving the value fails