Package org.instancio.internal.selectors
Class SelectorImpl
java.lang.Object
org.instancio.internal.selectors.SelectorImpl
- All Implemented Interfaces:
ConvertibleToScope
,DepthSelector
,GroupableSelector
,Flattener
,UnusedSelectorDescription
,Selector
,TargetSelector
- Direct Known Subclasses:
MetamodelSelector
public class SelectorImpl
extends Object
implements Selector, GroupableSelector, Flattener, UnusedSelectorDescription
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionatDepth
(int depth) Restricts this selector's target(s) to the specified depth.static SelectorImpl.Builder
builder()
static SelectorImpl.Builder
builder
(SelectorImpl copy) final boolean
flatten()
Flattens selectors into a list.getDepth()
Returns selector description, including line number where it was used.static SelectorImpl
Class<?>
final int
hashCode()
boolean
boolean
isRoot()
toScope()
Scope representation of a selector.toString()
Specifies the scope for this selector in order to narrow down its target.
-
Method Details
-
builder
-
getRootSelector
-
isRoot
public boolean isRoot() -
getStackTraceHolder
-
atDepth
Description copied from interface:DepthSelector
Restricts this selector's target(s) to the specified depth.- Specified by:
atDepth
in interfaceDepthSelector
- Parameters:
depth
- the depth at which selector applies- Returns:
- selector restricted to the specified depth
-
getDescription
Description copied from interface:UnusedSelectorDescription
Returns selector description, including line number where it was used.- Specified by:
getDescription
in interfaceUnusedSelectorDescription
- Returns:
- selector description
-
within
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 twoPhone
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.
-
toScope
Description copied from interface:ConvertibleToScope
Scope representation of a selector.- Specified by:
toScope
in interfaceConvertibleToScope
- Returns:
- scope
-
flatten
Description copied from interface:Flattener
Flattens selectors into a list. -
getParent
-
getScopes
-
isFieldSelector
public boolean isFieldSelector() -
getTargetClass
-
getFieldName
-
getDepth
-
equals
Performs equality check with all fields except
parent
andstackTraceHolder
. -
hashCode
public final int hashCode()Calculates hashcode using all fields except
parent
andstackTraceHolder
. -
toString
-
builder
-