Class TransformingType<F,T>
java.lang.Object
com.viaversion.viaversion.api.type.Type<T>
com.viaversion.viaversion.api.type.TransformingType<F,T>
- All Implemented Interfaces:
ByteBufReader<T>,ByteBufWriter<T>,CodecWriter<T>
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class com.viaversion.viaversion.api.type.Type
getBaseClass, getOutputClass, getTypeName, toString
-
Constructor Details
-
TransformingType
-
-
Method Details
-
of
public static <F,T> Type<T> of(Type<F> from, Class<T> outputClass, Function<F, T> mapFunction, Function<T, F> reverseFunction) Returns a type that transforms the input to a separate output type. Useful if you have wrapper classes of a single object.- Type Parameters:
F- from typeT- to type- Parameters:
from- type to map fromoutputClass- output classmapFunction- function to map from F to TreverseFunction- function to map from T to F- Returns:
- transforming type
-
read
Description copied from interface:ByteBufReaderReads a value from a ByteBuf.- Parameters:
buffer- buffer to read from- Returns:
- type based on the class type
-
write
Description copied from interface:ByteBufWriterWrites an object to a type to a ByteBuf.- Parameters:
buffer- buffer to write tovalue- value to write
-
write
-