ENTITY
- the source entityFK_ENTITY
- the target entitypublic interface FindFromNullable<ENTITY,FK_ENTITY> extends Function<ENTITY,Stream<FK_ENTITY>>
Stream
. Formally, a FindFrom
has the following signature:
FK_ENTITY apply(ENTITY entity);
Each FindFrom
contains metadata of which fields it compares to
determine the mapping as well as a reference to the foreign manager.
FindFromNullable
is a specialization of FindFrom
that is used
to signal that the referenced entity might not exist.
Modifier and Type | Method and Description |
---|---|
Stream<FK_ENTITY> |
apply(ENTITY entity)
Applies this method, locating the referenced entity and returning it as a
singleton stream if found.
|
FK_ENTITY |
applyOrThrow(ENTITY entity)
Applies this method, returning the referenced entity.
|
Field<ENTITY> |
getSourceField()
Returns the field that the stream originates from.
|
TableIdentifier<FK_ENTITY> |
getTableIdentifier()
Returns the identifier for the referenced (foreign) table.
|
Field<FK_ENTITY> |
getTargetField()
Returns the field that the stream references.
|
boolean |
isPresent(ENTITY entity)
Returns
true if the apply(Object) -method will return a
stream with a value. |
TableIdentifier<FK_ENTITY> getTableIdentifier()
Field<ENTITY> getSourceField()
In the following example, foo
is the source:
foos.stream()
.flatMap(foo.findBars()) // findBars returns FindFromNullable<Foo, Bar>
.forEach(...);
Field<FK_ENTITY> getTargetField()
In the following example, bar
is the target:
foos.stream()
.flatMap(foo.findBars()) // findBars returns Streamer<Foo, Bar>
.forEach(...);
boolean isPresent(ENTITY entity)
true
if the apply(Object)
-method will return a
stream with a value. Otherwise, false
is returned.entity
- the entity to locate a foreign entity forFK_ENTITY applyOrThrow(ENTITY entity) throws IllegalArgumentException
isPresent(Object)
.
Another way of retrieving the referenced entity is to use the
apply(Object)
-method.
entity
- the entity to locate a foreign entity forIllegalArgumentException
- if no foreign entity was referencedCopyright © 2018 Speedment, Inc.. All rights reserved.