public interface Marshallable extends WriteMarshallable, ReadMarshallable, net.openhft.chronicle.core.io.Resettable
This interface also provides a set of static utility methods to aid in the manipulation and interpretation of marshallable data, allowing for data comparison, hashing, and serialization to and from string and file representations.
EMPTYDISCARD| Modifier and Type | Method and Description |
|---|---|
static boolean |
$equals(@NotNull WriteMarshallable $this,
Object o)
Compares a given
WriteMarshallable object with another object for equality. |
default @NotNull Map<String,FieldInfo> |
$fieldInfoMap()
Retrieves a map of field information for the current class, with field names as keys.
|
default @NotNull List<FieldInfo> |
$fieldInfos()
Retrieves the list of field information for the current class.
|
static int |
$hashCode(WriteMarshallable $this)
Generates a 32-bit hash code for a given
WriteMarshallable object. |
static String |
$toString(WriteMarshallable $this)
Converts a given
WriteMarshallable object into its string representation. |
default String |
className()
Returns the alias name for the current class, if available.
|
default <T extends Marshallable> |
copyTo(T dest)
Copy fields from this to dest by marshalling out and then in.
|
default <T> T |
deepCopy()
Creates a deep copy of the current marshallable object.
|
static <T> T |
fromFile(@NotNull Class<T> expectedType,
String filename)
Reads a file, either from the current working directory or the classpath, and interprets its
content as a marshallable object of a specific type.
|
static <T> T |
fromFile(String filename)
Reads a file, either from the current working directory or the classpath, and interprets its
content as a marshallable object.
|
static <T> T |
fromString(@NotNull CharSequence cs)
Converts a
CharSequence into its corresponding marshallable representation. |
static <T> T |
fromString(@NotNull Class<T> tClass,
@NotNull CharSequence cs)
Converts a
CharSequence into its corresponding marshallable representation,
expecting a specific type as the result. |
static <T> T |
fromString(@NotNull InputStream is)
Converts the content from an
InputStream into its corresponding marshallable representation. |
default <T> T |
getField(String name,
Class<T> tClass)
Retrieves the value of a specific field from the current marshallable object, expecting
a certain type for the field's value.
|
default long |
getLongField(String name)
Retrieves the long value of a specific field from the current marshallable object.
|
default <K,T extends Marshallable> |
mergeToMap(@NotNull Map<K,T> map,
@NotNull Function<T,K> getKey)
Merges the current marshallable object into a map, using a specified function to determine the key.
|
default void |
readMarshallable(@NotNull WireIn wire)
Reads the state of the Marshallable object from the given wire input.
|
default void |
reset()
Resets the current marshallable object to its initial state.
|
default void |
setField(String name,
Object value)
Sets the value of a specific field in the current marshallable object.
|
default void |
setLongField(String name,
long value)
Sets the long value of a specific field in the current marshallable object.
|
static <T> @Nullable Stream<T> |
streamFromFile(@NotNull Class<T> expectedType,
String filename)
Streams the content of a file as marshallable objects of a specific type.
|
static <T> @NotNull Stream<T> |
streamFromFile(String filename)
Streams the content of a file as marshallable objects.
|
default void |
writeMarshallable(@NotNull WireOut wire)
Writes the state of the Marshallable object to the given wire output.
|
binaryLengthLength, writeValueunexpectedFieldstatic boolean $equals(@NotNull
@NotNull WriteMarshallable $this,
Object o)
WriteMarshallable object with another object for equality.$this - The reference WriteMarshallable object.o - The object to compare with.true if both objects are equal, false otherwise.static int $hashCode(WriteMarshallable $this)
WriteMarshallable object.$this - The reference WriteMarshallable object.static String $toString(WriteMarshallable $this)
WriteMarshallable object into its string representation.$this - The reference WriteMarshallable object.@Nullable
static <T> T fromString(@NotNull
@NotNull CharSequence cs)
throws net.openhft.chronicle.core.io.InvalidMarshallableException
CharSequence into its corresponding marshallable representation.cs - The character sequence to convert.null if the conversion is not possible.net.openhft.chronicle.core.io.InvalidMarshallableException@Nullable
static <T> T fromString(@NotNull
@NotNull Class<T> tClass,
@NotNull
@NotNull CharSequence cs)
throws net.openhft.chronicle.core.io.InvalidMarshallableException
CharSequence into its corresponding marshallable representation,
expecting a specific type as the result.tClass - The expected class of the resulting object.cs - The character sequence to convert.T, or null if the conversion is not possible.net.openhft.chronicle.core.io.InvalidMarshallableException@NotNull static <T> T fromFile(String filename) throws IOException, net.openhft.chronicle.core.io.InvalidMarshallableException
filename - The name or path of the file to read.IOExceptionnet.openhft.chronicle.core.io.InvalidMarshallableExceptionstatic <T> T fromString(@NotNull
@NotNull InputStream is)
throws net.openhft.chronicle.core.io.InvalidMarshallableException
InputStream into its corresponding marshallable representation.is - The input stream containing the content to convert.null if the conversion is not possible.net.openhft.chronicle.core.io.InvalidMarshallableException@Nullable
static <T> T fromFile(@NotNull
@NotNull Class<T> expectedType,
String filename)
throws IOException,
net.openhft.chronicle.core.io.InvalidMarshallableException
expectedType - The expected type of the resulting object.filename - The name or path of the file to read.IOExceptionnet.openhft.chronicle.core.io.InvalidMarshallableException@NotNull static <T> @NotNull Stream<T> streamFromFile(String filename) throws IOException
filename - The name or path of the file to read.IOException@Nullable static <T> @Nullable Stream<T> streamFromFile(@NotNull @NotNull Class<T> expectedType, String filename) throws IOException
expectedType - The expected type of the resulting objects in the stream.filename - The name or path of the file to read.T.IOException@Nullable default <T> T getField(String name, Class<T> tClass) throws NoSuchFieldException
name - The name of the field.tClass - The expected class/type of the field's value.NoSuchFieldExceptiondefault void setField(String name, Object value) throws NoSuchFieldException
name - The name of the field.value - The new value for the specified field.NoSuchFieldExceptiondefault long getLongField(String name) throws NoSuchFieldException
name - The name of the field.NoSuchFieldExceptiondefault void setLongField(String name, long value) throws NoSuchFieldException
name - The name of the field.value - The new long value for the specified field.NoSuchFieldExceptiondefault void readMarshallable(@NotNull
@NotNull WireIn wire)
throws net.openhft.chronicle.core.io.IORuntimeException,
net.openhft.chronicle.core.io.InvalidMarshallableException
The default implementation will use a default value for each field not present
readMarshallable in interface ReadMarshallablewire - The wire input source.net.openhft.chronicle.core.io.IORuntimeException - If an IO error occurs during the read operation.net.openhft.chronicle.core.io.InvalidMarshallableException - If there's an error during marshalling.default void writeMarshallable(@NotNull
@NotNull WireOut wire)
throws net.openhft.chronicle.core.io.InvalidMarshallableException
The default implementation will write all values even if they are a default value. c.f. readMarshallable
writeMarshallable in interface WriteMarshallablewire - The wire output destination.net.openhft.chronicle.core.io.InvalidMarshallableException - If there's an error during marshalling.@NotNull
default <T> T deepCopy()
throws net.openhft.chronicle.core.io.InvalidMarshallableException
net.openhft.chronicle.core.io.InvalidMarshallableExceptiondefault <T extends Marshallable> T copyTo(@NotNull T dest) throws net.openhft.chronicle.core.io.InvalidMarshallableException
T - destination typedest - destinationnet.openhft.chronicle.core.io.InvalidMarshallableExceptiondefault <K,T extends Marshallable> T mergeToMap(@NotNull @NotNull Map<K,T> map, @NotNull @NotNull Function<T,K> getKey)
map - The map to merge into.getKey - The function to determine the key for the current object in the map.@NotNull default @NotNull List<FieldInfo> $fieldInfos()
@NotNull default @NotNull Map<String,FieldInfo> $fieldInfoMap()
default String className()
default void reset()
reset in interface net.openhft.chronicle.core.io.ResettableCopyright © 2024. All rights reserved.