java.lang.Object
de.floydkretschmar.fixturize.stategies.constants.value.providers.fallback.ClassValueProvider
All Implemented Interfaces:
ValueProvider

public class ClassValueProvider extends Object implements ValueProvider
Defines the default fallback strategy for getting values where no value provider is defined: 1. If type is annotated with FixtureConstructor or FixtureBuilder: use the annotation with the most FixtureConstructor.constructorParameters() or FixtureBuilder.usedSetters() and use the creation method defined by that annotation 2. If any lombok annotations are present, try to generate to correct value according to the annotation:
  • Builder: create an inline builder for all fields
  • AllArgsConstructor: create an inline new call to the constructor using all fields
  • RequiredArgsConstructor: create an inline new call to the constructor using all fields that are final and don't have a constant value
  • AllArgsConstructor: create an inline new call to the constructor without arguments
3. If any manually generated constructors are present, use the one with the most arguments as the value 4. If any manually written builder methods are present, create an inline builder call for all setter that match the fields of the constant type. Matching in this case means that the setter method name must end on the name of the field.
  • Constructor Details

  • Method Details

    • provideValueAsString

      public String provideValueAsString(Element field, TypeMetadata metadata)
      Description copied from interface: ValueProvider
      Returns a string representation of a value that will be used when creating a constant for the specified field.
      Specified by:
      provideValueAsString in interface ValueProvider
      Parameters:
      field - - for which the value is being provided
      metadata - - used for creating the fixture
      Returns:
      the string representation of the value