Class FieldModifier


  • public final class FieldModifier
    extends Object
    • Method Detail

      • set

        public void set​(Object value)
        Tries to set the field to the specified value.

        Includes static fields but ignores fields that can't be modified reflectively.

        Parameters:
        value - The value that the field should get.
        Throws:
        ReflectionException - If the operation fails.
      • defaultField

        public void defaultField()
        Tries to make the field null. Ignores static fields and fields that can't be modified reflectively.
        Throws:
        ReflectionException - If the operation fails.
      • defaultStaticField

        public void defaultStaticField()
        Tries to make the field null. Includes static fields but ignores fields that can't be modified reflectively.
        Throws:
        ReflectionException - If the operation fails.
      • copyTo

        public void copyTo​(Object to)
        Copies field's value to the corresponding field in the specified object.

        Ignores static fields and fields that can't be modified reflectively.

        Parameters:
        to - The object into which to copy the field.
        Throws:
        ReflectionException - If the operation fails.
      • changeField

        public void changeField​(PrefabValues prefabValues,
                                TypeTag enclosingType)
        Changes the field's value to something else. The new value will never be null. Other than that, the precise value is undefined.

        Ignores static fields and fields that can't be modified reflectively.

        Parameters:
        prefabValues - If the field is of a type contained within prefabValues, the new value will be taken from it.
        enclosingType - A tag for the type that contains the field. Needed to determine a generic type, if it has one..
        Throws:
        ReflectionException - If the operation fails.