Class ReflectionFieldDescriptor
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.vilTypes.FieldDescriptor
-
- net.ssehub.easy.instantiation.core.model.vilTypes.ReflectionFieldDescriptor
-
- All Implemented Interfaces:
IMetaField
public class ReflectionFieldDescriptor extends FieldDescriptor
Implements a reflection field descriptor.- Author:
- Holger Eichelberger
-
-
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 fromfield.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 fromfield.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetJavaSignature()Returns the java-like signature of this operation.java.lang.ObjectgetValue(java.lang.Object owner)Returns the actual value of this field.booleanisReadOnly()Returns whether the field is read-only.booleanisStatic()Returns whether the field is static.voidsetValue(java.lang.Object owner, java.lang.Object value)Changes the actual value for this field inowner.-
Methods inherited from class net.ssehub.easy.instantiation.core.model.vilTypes.FieldDescriptor
getDeclaringType, getMetaType, getMetaValue, getName, getSignature, getType
-
-
-
-
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 fromfield.- Parameters:
declaringType- the declaring typefield- the fieldtypeGenerics- 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 fromfield.- Parameters:
declaringType- the declaring typefield- the fieldname- the explicit name of the field (may be null to take the name offield)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 typefield- the fieldname- the name the field shall be accessiblereadOnly- whether the field is readonlytypeGenerics- the generics of the field type (may be null)
-
-
Method Detail
-
getJavaSignature
public java.lang.String getJavaSignature()
Description copied from interface:IMetaFieldReturns the java-like signature of this operation.- Returns:
- the java-like Java signature of this operation
-
isReadOnly
public boolean isReadOnly()
Description copied from interface:IMetaFieldReturns 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 returntrueand 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 returnfalse.- Returns:
trueif the field is read-only,falseelse
-
isStatic
public boolean isStatic()
Description copied from interface:IMetaFieldReturns whether the field is static.- Returns:
trueif the field is static,falseelse
-
getValue
public java.lang.Object getValue(java.lang.Object owner) throws VilExceptionDescription copied from class:FieldDescriptorReturns the actual value of this field.- Specified by:
getValuein classFieldDescriptor- Parameters:
owner- the owning object (ignored, i.e., shall be null, ifIMetaField.isStatic())- Returns:
- the actual value
- Throws:
VilException- in case that retrieving the value fails
-
setValue
public void setValue(java.lang.Object owner, java.lang.Object value) throws VilExceptionDescription copied from class:FieldDescriptorChanges the actual value for this field inowner.- Specified by:
setValuein classFieldDescriptor- Parameters:
owner- the owning object (ignored, i.e., shall be null, ifIMetaField.isStatic())value- the new value- Throws:
VilException- in case that setting the value fails, e.g., as this field isIMetaField.isReadOnly()
-
-