Class DataClassInformation
java.lang.Object
eu.cloudnetservice.driver.network.rpc.defaults.object.data.DataClassInformation
Holds all information about a data class and is able to create an instance from a network buffer and serializing an
instance to a network buffer.
- Since:
- 4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final DataClassInvokerGenerator.DataClassInformationWriterprivate final DataClassInvokerGenerator.DataClassInstanceCreator -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDataClassInformation(DataClassInvokerGenerator.DataClassInstanceCreator creator, DataClassInvokerGenerator.DataClassInformationWriter writer) Constructs a new data class information instance. -
Method Summary
Modifier and TypeMethodDescriptioncollectFields(@NonNull Class<?> clazz) Collects all fields which are included for rpc transmitting.static @NonNull DataClassInformationcreateClassInformation(@NonNull Class<?> clazz) Constructs a data class information based on the given class using the given generator.Get the instance writer for the underlying data class.Get the instance creator for the underlying data class.protected static <T,O> @NonNull O[] transformToArray(@NonNull Class<O> outType, @NonNull List<T> in, @NonNull Function<T, O> transformer) Transforms the given list into an array using the provided mapping function.
-
Field Details
-
instanceCreator
-
informationWriter
-
-
Constructor Details
-
DataClassInformation
protected DataClassInformation(@NonNull DataClassInvokerGenerator.DataClassInstanceCreator creator, @NonNull DataClassInvokerGenerator.DataClassInformationWriter writer) Constructs a new data class information instance.- Parameters:
creator- the instance creator for the class.writer- the instance write for the class.- Throws:
NullPointerException- if either the writer or creator is null.
-
-
Method Details
-
createClassInformation
@NonNull public static @NonNull DataClassInformation createClassInformation(@NonNull @NonNull Class<?> clazz) Constructs a data class information based on the given class using the given generator. This class pre evaluates if the data class creation is possible and collects all fields of the data class, which will be interpreted by the generator in the required way. This method ensures that only fields which should get included are passed to the data class generator.- Parameters:
clazz- the class to build the information for.- Returns:
- the created data class information for the given class.
- Throws:
NullPointerException- if either the given class or generator is null.MissingAllArgsConstructorException- if no constructor with all field types exists in the given data class.
-
collectFields
Collects all fields which are included for rpc transmitting.- Parameters:
clazz- the data class to collect the fields of.- Returns:
- all fields which are included for rpc transmitting.
- Throws:
NullPointerException- if the given data class is null.
-
transformToArray
@NonNull protected static <T,O> @NonNull O[] transformToArray(@NonNull @NonNull Class<O> outType, @NonNull @NonNull List<T> in, @NonNull @NonNull Function<T, O> transformer) Transforms the given list into an array using the provided mapping function.- Type Parameters:
T- the generic input type.O- the generic output type.- Parameters:
outType- the type of the array after transforming.in- the list of objects to transform to an array.transformer- the transformer to transform between the list entry and the array entry.- Returns:
- a new array containing all elements from the input array after being applied to the given transformer.
- Throws:
NullPointerException- if one of the given arguments is null.
-
instanceCreator
Get the instance creator for the underlying data class.- Returns:
- the instance creator.
-
informationWriter
Get the instance writer for the underlying data class.- Returns:
- the instance writer.
-