public interface OdinFieldReader
Modifier and Type | Method and Description |
---|---|
<T> void |
listen(java.util.function.Consumer<T> listener) |
void |
listenBoolean(java.util.function.Consumer<java.lang.Boolean> listener) |
void |
listenByte(java.util.function.Consumer<java.lang.Byte> listener) |
void |
listenChar(java.util.function.Consumer<java.lang.Character> listener) |
void |
listenDouble(java.util.function.Consumer<java.lang.Double> listener) |
void |
listenFloat(java.util.function.Consumer<java.lang.Float> listener) |
void |
listenInt(java.util.function.Consumer<java.lang.Integer> listener) |
void |
listenLong(java.util.function.Consumer<java.lang.Long> listener) |
OdinFieldReader |
listenNotFound(java.lang.Runnable listener)
Add a listener that will be called if this field is not found inside the current object.
This method return this reader instance in order to use a fluent design : |
void |
listenShort(java.util.function.Consumer<java.lang.Short> listener) |
void |
listenString(java.util.function.Consumer<java.lang.String> listener) |
void |
listenSubContent(IOConsumer<OdinReader> subReader)
Use a consumer to read content of a sub object.
|
<T> void |
listenTo(T o)
Read value to a given object instance, if a type definition is present in the input stream it will be skip to use the given instance type.
This method is not recursive, so all the object fields are set with new object instances according to the stream content. If the object is null this method simply skip the object to read, if you need to get object with null as given object use listenTo(Object, Consumer) .If the field is a primitive, this method skip the object to read. If the object use a inline or a immutable adapter, this method skip the object to read |
<T> void |
listenTo(T o,
AnyType<T> type,
java.util.function.Consumer<T> listener)
Read value to a given object instance and call listener with it, if a type definition is present in the input stream it will be skip to use the given instance type.
This method is not recursive, so all the object fields are set with new object instances according to the stream content. If the object is null this method do the same as listenTyped(AnyType, Consumer) and use the given type.If the field is a primitive, this method call the consumer with his new value. If the object use a inline or a immutable adapter, this method call the consumer with a new object instance. |
<T> void |
listenTo(T o,
java.util.function.Consumer<T> listener)
Read value to a given object instance and call listener with it, if a type definition is present in the input stream it will be skip to use the given instance type.
This method is not recursive, so all the object fields are set with new object instances according to the stream content. If the object is null this method do the same as listen(Consumer) .If the field is a primitive, this method call the consumer with his new value. If the object use a inline or a immutable adapter, this method call the consumer with a new object instance |
<T> void |
listenTo(T o,
java.lang.reflect.Type type,
java.util.function.Consumer<T> listener)
Read value to a given object instance and call listener with it, if a type definition is present in the input stream it will be skip to use the given instance type.
This method is not recursive, so all the object fields are set with new object instances according to the stream content. If the object is null this method do the same as listenTyped(Type, Consumer) and use the given type.If the field is a primitive, this method call the consumer with his new value. If the object use a inline or a immutable adapter, this method call the consumer with a new object instance. |
<T> void |
listenTyped(AnyType<T> type,
java.util.function.Consumer<T> listener)
Read value using the given generic type and call listener with it, if a type definition is present it will be used as object type.
This method take a odin type to be use inside adapter by using ObjectType.getField(String) or all other field getter and
TypeField.getType() |
<T> void |
listenTyped(java.lang.reflect.Type type,
java.util.function.Consumer<T> listener)
Read value using the given generic type and call listener with it, if a type definition is present it will be used as object type.
Custom type can be created to add generic argument ( can be useful for collection ) using TypeBuilder . |
OdinFieldReader listenNotFound(java.lang.Runnable listener)
// int v; is a class field
reader.readField("value")
.listenNotFound(() -> v = -1)
.listenInt((Integer i) -> v = i);
listener
- listenervoid listenBoolean(java.util.function.Consumer<java.lang.Boolean> listener)
void listenByte(java.util.function.Consumer<java.lang.Byte> listener)
void listenShort(java.util.function.Consumer<java.lang.Short> listener)
void listenInt(java.util.function.Consumer<java.lang.Integer> listener)
void listenLong(java.util.function.Consumer<java.lang.Long> listener)
void listenFloat(java.util.function.Consumer<java.lang.Float> listener)
void listenDouble(java.util.function.Consumer<java.lang.Double> listener)
void listenChar(java.util.function.Consumer<java.lang.Character> listener)
void listenString(java.util.function.Consumer<java.lang.String> listener)
<T> void listen(java.util.function.Consumer<T> listener)
<T> void listenTo(T o)
listenTo(Object, Consumer)
.T
- object typeo
- object instance<T> void listenTo(T o, java.util.function.Consumer<T> listener)
listen(Consumer)
.T
- object typeo
- object instancelistener
- listener to call when value is read<T> void listenTo(T o, AnyType<T> type, java.util.function.Consumer<T> listener)
listenTyped(AnyType, Consumer)
and use the given type.listenTo(Object)
by his security for null object case, if the object is null and the input stream doesn't contains the type definition, the given type is used
instead of Object classT
- object typeo
- object instancetype
- object typelistener
- listener to call when value is read<T> void listenTo(T o, java.lang.reflect.Type type, java.util.function.Consumer<T> listener)
listenTyped(Type, Consumer)
and use the given type.listenTo(Object)
by his security for null object case, if the object is null and the input stream doesn't contains the type definition, the given type is used
instead of Object classT
- object typeo
- object instancetype
- object typelistener
- listener to call when value is read<T> void listenTyped(AnyType<T> type, java.util.function.Consumer<T> listener)
ObjectType.getField(String)
or all other field getter and
TypeField.getType()
T
- object typetype
- generic typelistener
- listener to call when value is read<T> void listenTyped(java.lang.reflect.Type type, java.util.function.Consumer<T> listener)
TypeBuilder
.T
- object typetype
- generic typelistener
- listener to call when value is readvoid listenSubContent(IOConsumer<OdinReader> subReader)
subReader
- the sub reader consumer