ENTITY
- Entity typeR
- Type of formatterOUTPUT_TYPE
- Target encoder output typepublic interface Encoder<ENTITY,R extends Encoder<ENTITY,R,OUTPUT_TYPE>,OUTPUT_TYPE>
Entity
into any kind of strings.
Fields can be added, removed and it is also possible to change the way a
field is rendered into the resulting String.
A field can also be rendered using another EntityFormatter when that other field is a foreign key or, for that matter, another Field in any Entity.
Modifier and Type | Method and Description |
---|---|
OUTPUT_TYPE |
apply(ENTITY entity) |
<D,T,I extends FieldTrait & ReferenceFieldTrait<ENTITY,D,T>> |
put(I field)
Adds this Field to the output renderer.
|
<D,T,FK_ENTITY,I extends FieldTrait & ReferenceFieldTrait<ENTITY,D,T> & ReferenceForeignKeyFieldTrait<ENTITY,D,FK_ENTITY>> |
put(I field,
Encoder<FK_ENTITY,?,OUTPUT_TYPE> fkFormatter)
Adds this ReferenceForeignKeyField to the output renderer.
|
<FK_ENTITY> |
put(String label,
Function<ENTITY,FK_ENTITY> getter,
Encoder<FK_ENTITY,?,OUTPUT_TYPE> fkFormatter)
Adds a field that corresponds to the label to the output renderer.
|
<T> R |
put(String label,
Function<ENTITY,T> getter)
Adds a field that corresponds to the label to the output renderer.
|
<FK_ENTITY> |
putStreamer(String label,
Function<ENTITY,Stream<FK_ENTITY>> streamer,
Encoder<FK_ENTITY,?,OUTPUT_TYPE> fkFormatter)
Adds a field that corresponds to the label to the output renderer.
|
<FK_ENTITY> |
putStreamer(String label,
Function<ENTITY,Stream<FK_ENTITY>> streamer,
Function<FK_ENTITY,OUTPUT_TYPE> fkMapper)
Adds a field that corresponds to the label to the output renderer.
|
R |
remove(FieldTrait field)
Removes this Field from the output renderer.
|
R |
remove(String label)
Removes the field that corresponds to the provided label from the output
renderer.
|
OUTPUT_TYPE apply(ENTITY entity)
<D,T,I extends FieldTrait & ReferenceFieldTrait<ENTITY,D,T>> R put(I field)
D
- the database typeT
- the mapped Java type of the FieldI
- Field typefield
- to add to the renderer<D,T,FK_ENTITY,I extends FieldTrait & ReferenceFieldTrait<ENTITY,D,T> & ReferenceForeignKeyFieldTrait<ENTITY,D,FK_ENTITY>> R put(I field, Encoder<FK_ENTITY,?,OUTPUT_TYPE> fkFormatter)
D
- the database typeT
- the mapped Java type of the FieldFK_ENTITY
- the mapped Java type of the foreign key FieldI
- Field typefield
- to add to the rendererfkFormatter
- the foreign key encoder<T> R put(String label, Function<ENTITY,T> getter)
Object
of type T by applying the
provided getter on the Entity and then feeding the returned value to the
default class renderer.T
- the mapped Java type of the Fieldlabel
- the name of the field to add to the output renderergetter
- to apply to the Entity<FK_ENTITY> R put(String label, Function<ENTITY,FK_ENTITY> getter, Encoder<FK_ENTITY,?,OUTPUT_TYPE> fkFormatter)
FK_ENTITY
- the mapped Java type of an Entitylabel
- the name of the field to add to the output renderergetter
- fkFormatter the foreign key encoderfkFormatter
- the foreign key encoder<FK_ENTITY> R putStreamer(String label, Function<ENTITY,Stream<FK_ENTITY>> streamer, Encoder<FK_ENTITY,?,OUTPUT_TYPE> fkFormatter)
Stream
of type FK_ENTITY from an ENTITY. Each Stream
element will then be rendered in a subarray by applying the provided
fkFormatter.FK_ENTITY
- the mapped Java type of an Entitylabel
- the name of the field to add to the output rendererstreamer
- that can produce a Stream<FK_ENTITY>
from an
ENTITY
fkFormatter
- the foreign key encoder<FK_ENTITY> R putStreamer(String label, Function<ENTITY,Stream<FK_ENTITY>> streamer, Function<FK_ENTITY,OUTPUT_TYPE> fkMapper)
Stream<FK_ENTITY>
from an ENTITY. Each Stream element
will then be rendered by the provided custom fkMapper that produces an
Object that is subsequently rendered using its default class renderer.FK_ENTITY
- the mapped Java type of an Entitylabel
- the name of the field to add to the output rendererstreamer
- that can produce a Stream<FK_ENTITY>
from an
ENTITY
fkMapper
- the foreign key encoderR remove(String label)
label
- the name of the field to remove from the output rendererR remove(FieldTrait field)
field
- to add to the rendererCopyright © 2016 Speedment, Inc.. All rights reserved.