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(Class<?> clazz, FieldCallback fc)
      Invokes the given FieldCallback for each field in the specified class and its superclasses.
      Parameters:
      clazz - the class to process fields for
      fc - the FieldCallback to invoke for each field
      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