Package org.instancio

Interface TypeSelectorBuilder

All Superinterfaces:
DepthPredicateSelector, DepthSelector, GroupableSelector, TargetSelector

public interface TypeSelectorBuilder extends GroupableSelector, DepthSelector, DepthPredicateSelector
A builder for constructing predicate-based type selectors.

An instance of the builder can be obtained using Select.types(). Other methods from this class can be chained to form logical AND relationships, for example:


 types().of(BaseEntity.class).annotated(Entity.class).annotated(Table.class)
 

will match BaseEntity including its subtypes, that are annotated with @Entity and @Table.

Since:
1.6.0
See Also:
  • Method Details

    • of

      Matches specified type, including subtypes. For example, selecting types of(Collection.class} will match List, Set, etc.
      Parameters:
      type - to match
      Returns:
      selector builder
      Since:
      1.6.0
    • annotated

      <A extends Annotation> TypeSelectorBuilder annotated(Class<? extends A> annotation)
      Matches types annotated with the specified annotation, ignoring inherited annotations.

      Note: this method only matches annotations declared on classes. To select annotated fields, use FieldSelectorBuilder.annotated(Class).

      The method can be chained to require multiple annotations.

      Type Parameters:
      A - annotation type
      Parameters:
      annotation - declared annotation to match
      Returns:
      selector builder
      Since:
      1.6.0
    • excluding

      TypeSelectorBuilder excluding(Class<?> type)
      Excludes specified class from matching.

      The method can be chained to exclude multiple types.

      Parameters:
      type - type to exclude
      Returns:
      selector builder
      Since:
      1.6.0
    • atDepth

      GroupableSelector atDepth(int depth)
      Restricts this selector's target(s) to the specified depth.

      When a selector atDepth(N) is converted toScope(), the semantics of Selector.within(Scope...) method still hold, meaning: at depth equal to or greater than N.

      Specified by:
      atDepth in interface DepthSelector
      Parameters:
      depth - the depth at which selector applies
      Returns:
      selector restricted to the specified depth
      Since:
      2.14.0
    • atDepth

      GroupableSelector atDepth(Predicate<Integer> atDepth)
      Restricts this selector's target(s) to a depth that satisfies the given predicate.
      Specified by:
      atDepth in interface DepthPredicateSelector
      Parameters:
      atDepth - specifying the depth
      Returns:
      selector restricted to the specified depth
      Since:
      2.14.0