Class PrimitiveAndWrapperSelectorImpl

java.lang.Object
org.instancio.internal.selectors.PrimitiveAndWrapperSelectorImpl
All Implemented Interfaces:
ConvertibleToScope, GroupableSelector, Flattener, Selector, TargetSelector

public final class PrimitiveAndWrapperSelectorImpl extends Object implements Selector, Flattener
  • Constructor Details

    • PrimitiveAndWrapperSelectorImpl

      public PrimitiveAndWrapperSelectorImpl(Class<?> primitiveType, Class<?> wrapperType)
    • PrimitiveAndWrapperSelectorImpl

      public PrimitiveAndWrapperSelectorImpl(SelectorImpl primitive, SelectorImpl wrapper)
  • Method Details

    • isScoped

      public boolean isScoped()
    • getPrimitive

      public SelectorImpl getPrimitive()
    • getWrapper

      public SelectorImpl getWrapper()
    • flatten

      public List<TargetSelector> flatten()
      Description copied from interface: Flattener
      Flattens selectors into a list.
      Specified by:
      flatten in interface Flattener
      Returns:
      flat list of selectors
    • within

      public Selector within(@NotNull @NotNull Scope... scopes)
      Description copied from interface: Selector
      Specifies the scope for this selector in order to narrow down its target.

      For example, if the Person class has two Phone fields:

      
           class Person {
               private Phone home;
               private Phone cell;
               // snip...
           }
       

      and we want to set only the cell phone to a specific value, we can narrow down the selector as follows:

      
         // Scope can be created using:
         Scope cellPhone = scope(Person.class, "cell");
         // or selector toScope() method
         Scope cellPhone = field(Person::getCell).toScope();
      
         Person person = Instancio.of(Person.class)
             .set(field(Phone.class, "number").within(cellPhone), "123-45-67")
             .create();
       

      See Selector Scopes section of the user guide for details.

      Specified by:
      within in interface Selector
      Parameters:
      scopes - one or more scopes to apply
      Returns:
      a selector with the specified scope
    • toScope

      public Scope toScope()
      Description copied from interface: ConvertibleToScope
      Scope representation of a selector.
      Specified by:
      toScope in interface ConvertibleToScope
      Returns:
      scope
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object