Class FunctionalScalarMarshaller<T,V>

java.lang.Object
org.wildfly.clustering.marshalling.protostream.FunctionalScalarMarshaller<T,V>
Type Parameters:
T - the type of this marshaller
V - the type of the mapped scalar marshaller
All Implemented Interfaces:
org.infinispan.protostream.BaseMarshaller<T>, org.infinispan.protostream.ProtobufTagMarshaller<T>, Marshallable<T>, ProtoStreamMarshaller<T>, Readable<T>, Writable<T>
Direct Known Subclasses:
ProxyMarshaller, SingletonCollectionMarshaller, URIMarshaller

public class FunctionalScalarMarshaller<T,V> extends Object implements ProtoStreamMarshaller<T>
Marshaller that reads/writes a single field by applying functions to a ScalarMarshaller.
Author:
Paul Ferraro
  • Constructor Details

    • FunctionalScalarMarshaller

      public FunctionalScalarMarshaller(ScalarMarshaller<V> marshaller, Supplier<T> defaultFactory, org.wildfly.common.function.ExceptionFunction<T,V,IOException> function, org.wildfly.common.function.ExceptionFunction<V,T,IOException> factory)
      Constructs a new single field marshaller based on single scalar marshaller.
      Parameters:
      marshaller - the scalar marshaller used by this marshaller
      defaultFactory - generates a default value returned by readFrom(ProtoStreamReader) if no field was written.
      function - a function that returns a value suitable for use by the specified scalar marshaller
      factory - a function applied to the value read from the specified scalar marshaller
    • FunctionalScalarMarshaller

      public FunctionalScalarMarshaller(ScalarMarshaller<V> marshaller, Supplier<T> defaultFactory, BiPredicate<V,V> equals, org.wildfly.common.function.ExceptionFunction<T,V,IOException> function, org.wildfly.common.function.ExceptionFunction<V,T,IOException> factory)
      Constructs a new single field marshaller based on single scalar marshaller.
      Parameters:
      marshaller - the scalar marshaller used by this marshaller
      defaultFactory - generates a default value returned by readFrom(ProtoStreamReader) if no field was written.
      equals - a predicate used to determine if writeTo(ProtoStreamWriter, Object) should skip writing the field.
      function - a function that returns a value suitable for use by the specified scalar marshaller
      factory - a function applied to the value read from the specified scalar marshaller
    • FunctionalScalarMarshaller

      public FunctionalScalarMarshaller(ScalarMarshaller<V> marshaller, Supplier<T> defaultFactory, org.wildfly.common.function.ExceptionPredicate<T,IOException> skipWrite, org.wildfly.common.function.ExceptionFunction<T,V,IOException> function, org.wildfly.common.function.ExceptionFunction<V,T,IOException> factory)
      Constructs a new single field marshaller based on single scalar marshaller.
      Parameters:
      marshaller - the scalar marshaller used by this marshaller
      defaultFactory - generates a default value returned by readFrom(ProtoStreamReader) if no field was written.
      skipWrite - a predicate used to determine if writeTo(ProtoStreamWriter, Object) should skip writing the field.
      function - a function that returns a value suitable for use by the specified scalar marshaller
      factory - a function applied to the value read from the specified scalar marshaller
    • FunctionalScalarMarshaller

      public FunctionalScalarMarshaller(Class<? extends T> targetClass, ScalarMarshaller<V> marshaller, org.wildfly.common.function.ExceptionFunction<T,V,IOException> function, org.wildfly.common.function.ExceptionFunction<V,T,IOException> factory)
      Constructs a new single field marshaller based on single scalar marshaller.
      Parameters:
      targetClass - the type of this marshaller
      marshaller - the scalar marshaller used by this marshaller
      function - a function that returns a value suitable for use by the specified scalar marshaller
      factory - a function applied to the value read from the specified scalar marshaller
    • FunctionalScalarMarshaller

      public FunctionalScalarMarshaller(Class<? extends T> targetClass, ScalarMarshaller<V> marshaller, Supplier<T> defaultFactory, org.wildfly.common.function.ExceptionFunction<T,V,IOException> function, org.wildfly.common.function.ExceptionFunction<V,T,IOException> factory)
      Constructs a new single field marshaller based on single scalar marshaller.
      Parameters:
      targetClass - the type of this marshaller
      marshaller - the scalar marshaller used by this marshaller
      defaultFactory - generates a default value returned by readFrom(ProtoStreamReader) if no field was written.
      function - a function that returns a value suitable for use by the specified scalar marshaller
      factory - a function applied to the value read from the specified scalar marshaller
    • FunctionalScalarMarshaller

      public FunctionalScalarMarshaller(Class<? extends T> targetClass, ScalarMarshaller<V> marshaller, Supplier<T> defaultFactory, BiPredicate<V,V> equals, org.wildfly.common.function.ExceptionFunction<T,V,IOException> function, org.wildfly.common.function.ExceptionFunction<V,T,IOException> factory)
      Constructs a new single field marshaller based on single scalar marshaller.
      Parameters:
      targetClass - the type of this marshaller
      marshaller - the scalar marshaller used by this marshaller
      defaultFactory - generates a default value returned by readFrom(ProtoStreamReader) if no field was written.
      equals - a predicate comparing the default value with the value to write, used to determine if writeTo(ProtoStreamWriter, Object) should skip writing the field.
      function - a function that returns a value suitable for use by the specified scalar marshaller
      factory - a function applied to the value read from the specified scalar marshaller
    • FunctionalScalarMarshaller

      public FunctionalScalarMarshaller(Class<? extends T> targetClass, ScalarMarshaller<V> marshaller, Supplier<T> defaultFactory, org.wildfly.common.function.ExceptionPredicate<T,IOException> skipWrite, org.wildfly.common.function.ExceptionFunction<T,V,IOException> function, org.wildfly.common.function.ExceptionFunction<V,T,IOException> factory)
      Constructs a new single field marshaller based on single scalar marshaller.
      Parameters:
      targetClass - the type of this marshaller
      marshaller - the scalar marshaller used by this marshaller
      defaultFactory - generates a default value returned by readFrom(ProtoStreamReader) if no field was written.
      skipWrite - a predicate used to determine if writeTo(ProtoStreamWriter, Object) should skip writing the field.
      function - a function that returns a value suitable for use by the specified scalar marshaller
      factory - a function applied to the value read from the specified scalar marshaller
  • Method Details

    • readFrom

      public T readFrom(ProtoStreamReader reader) throws IOException
      Description copied from interface: Readable
      Reads an object from the specified reader.
      Specified by:
      readFrom in interface Readable<T>
      Parameters:
      reader - a ProtoStream reader
      Returns:
      the read object
      Throws:
      IOException - if the object could not be read
    • writeTo

      public void writeTo(ProtoStreamWriter writer, T value) throws IOException
      Description copied from interface: Writable
      Writes the specified object to the specified writer.
      Specified by:
      writeTo in interface Writable<T>
      Parameters:
      writer - a ProtoStream writer
      value - the object to be written
      Throws:
      IOException - if the object could not be written
    • getJavaClass

      public Class<? extends T> getJavaClass()
      Description copied from interface: Marshallable
      Returns the type of object handled by this marshallable instance.
      Specified by:
      getJavaClass in interface org.infinispan.protostream.BaseMarshaller<T>
      Specified by:
      getJavaClass in interface Marshallable<T>
      Returns:
      the type of object handled by this marshallable instance.