Class FieldFactory

java.lang.Object
spoon.reflect.factory.SubFactory
spoon.reflect.factory.FieldFactory

public class FieldFactory extends SubFactory
The CtField sub-factory.
  • Constructor Details

    • FieldFactory

      public FieldFactory(Factory factory)
      Creates a new field sub-factory.
      Parameters:
      factory - the parent factory
  • Method Details

    • create

      public <T> CtField<T> create(CtType<?> target, Set<ModifierKind> modifiers, CtTypeReference<T> type, String name)
      Creates a field.
      Parameters:
      target - the target type to which the field is added
      modifiers - the modifiers
      type - the field's type
      name - the field's name
    • create

      public <T> CtField<T> create(CtType<?> target, Set<ModifierKind> modifiers, CtTypeReference<T> type, String name, CtExpression<T> defaultExpression)
      Creates a field.
      Parameters:
      target - the target type to which the field is added
      modifiers - the modifiers
      type - the field's type
      name - the field's name
      defaultExpression - the initializing expression
    • create

      public <T> CtField<T> create(CtType<?> target, CtField<T> source)
      Creates a field by copying an existing field.
      Type Parameters:
      T - the type of the field
      Parameters:
      target - the target type where the new field has to be inserted to
      source - the source field to be copied
      Returns:
      the newly created field
    • createReference

      public <T> CtFieldReference<T> createReference(CtField<T> field)
      Creates a field reference from an existing field.
    • createReference

      public <T> CtFieldReference<T> createReference(CtTypeReference<?> declaringType, CtTypeReference<T> type, String fieldName)
      Creates a field reference.
    • createReference

      public <T> CtFieldReference<T> createReference(Field field)
      Creates a field reference from a java.lang.reflect field.
    • createReference

      public <T> CtFieldReference<T> createReference(String signature)
      Creates a field reference from its signature, as defined by the field reference's toString.