Package org.instancio
Class Bindings
java.lang.Object
org.instancio.Bindings
A collection of static factory methods for creating
Binding
s.
A binding allows targeting a specific class or field.
Examples:
field(Example.class, "someField")
- target some field of Example classall(Example.class)
- target all instances of Example classof(Binding...)
- convenience method for targeting multiple bindingsallStrings()
- target all StringsallInts()
- target allInteger
objects andint
primitives
-
Method Summary
Modifier and TypeMethodDescriptionstatic Binding
Creates a binding for the given type.static Binding
Binding for all booleans, primitive and wrapper.static Binding
allBytes()
Binding for all bytes, primitive and wrapper.static Binding
allChars()
Binding for all characters, primitive and wrapper.static Binding
Binding for all doubles, primitive and wrapper.static Binding
Binding for all floats, primitive and wrapper.static Binding
allInts()
Binding for all integers, primitive and wrapper.static Binding
allLongs()
Binding for all longs, primitive and wrapper.static Binding
Binding for all shorts, primitive and wrapper.static Binding
Shorthand forall(String.class)
.static Binding
Creates a binding for the given class's field.static Binding
Creates a binding for a field that belongs to the class being created.static Binding
-
Method Details
-
of
-
field
Creates a binding for the given class's field.- Parameters:
declaringClass
- class declaring the fieldfieldName
- field name to bind- Returns:
- binding
-
field
Creates a binding for a field that belongs to the class being created.Example
Person person = Instancio.of(Person.class) .ignore(field("fullName")) // Person.fullName .create();
- Parameters:
fieldName
- field name to bind- Returns:
- binding
-
all
Creates a binding for the given type.If the type is a primitive or wrapper, this method will only bind the specified type. For example:
all(int.class)
- binds primitiveint
; does not includeInteger
all(Integer.class)
- bindsInteger
wrapper; does not include primitiveint
In order to bind both, primitive
int
and wrapper, use theallInts()
.- Parameters:
type
- to bind- Returns:
- binding
-
allStrings
Shorthand forall(String.class)
.- Returns:
- binding for all Strings
-
allBytes
Binding for all bytes, primitive and wrapper.- Returns:
- binding for all bytes
-
allFloats
Binding for all floats, primitive and wrapper.- Returns:
- binding for all floats
-
allShorts
Binding for all shorts, primitive and wrapper.- Returns:
- binding for all shorts
-
allInts
Binding for all integers, primitive and wrapper.- Returns:
- binding for all integers
-
allLongs
Binding for all longs, primitive and wrapper.- Returns:
- binding for all longs
-
allDoubles
Binding for all doubles, primitive and wrapper.- Returns:
- binding for all doubles
-
allBooleans
Binding for all booleans, primitive and wrapper.- Returns:
- binding for all booleans
-
allChars
Binding for all characters, primitive and wrapper.- Returns:
- binding for all characters
-