Class FieldUtils

java.lang.Object
ru.objectsfill.utils.FieldUtils

public class FieldUtils extends Object
Utility class for working with fields in Java classes.
  • Method Details

    • doWithFields

      public static void doWithFields(Fill fill)
      Invokes the given FieldCallback for each field in the specified class and its superclasses.
      Parameters:
      fill - special generated object
      Throws:
      IllegalArgumentException - if the class is null
      IllegalStateException - if the FieldCallback encounters an error while processing a field
    • addObjectWithParamConstruct

      public static <T> T addObjectWithParamConstruct(Constructor<?> constructor, Fill fill)
      create instance of class with construct parameters
      Type Parameters:
      T - type of object
      Parameters:
      fill - special generated object
      constructor - get construct for object creation
      Returns:
      T constructed object
      Throws:
      IllegalArgumentException - if the class is null
      IllegalStateException - if the FieldCallback encounters an error while processing a field
    • addObjectWithParamConstruct

      public static <T> T addObjectWithParamConstruct(Constructor<?> constructor, Fill fill, Class<?> tClass)
      create instance of class with construct parameters
      Type Parameters:
      T - type of object
      Parameters:
      fill - special generated object
      constructor - get construct for object creation
      tClass - class of outer object for creation
      Returns:
      T constructed object
      Throws:
      IllegalArgumentException - if the class is null
      IllegalStateException - if the FieldCallback encounters an error while processing a field
    • getObjectUnaryOperator

      public static UnaryOperator<Object> getObjectUnaryOperator(Fill fill)
      get wrap function or default t -> t. If we don't have reference to field
      Parameters:
      fill - the `Fill` object containing the generation parameters
      Returns:
      function
    • getObjectUnaryOperator

      public static UnaryOperator<Object> getObjectUnaryOperator(Fill fill, Field field)
      get wrap function or default t -> t. If we don't have reference to field
      Parameters:
      fill - the `Fill` object containing the generation parameters
      field - The field for which the collection stream is being filled.
      Returns:
      function
    • getExtFillParam

      public static Optional<Extend> getExtFillParam(Field field, Fill fill)
      Parameters:
      field - The field for which the collection stream is being filled.
      fill - The Fill object containing the necessary information for generation.
      Returns:
      extended parameter for some field