Class ParametersParser<SerializationT extends Serialization>


  • public abstract class ParametersParser<SerializationT extends Serialization>
    extends java.lang.Object
    Parses Serialization objects into Parameters objects of a certain kind.

    This class should eventually be in Tinks public API -- however, it might still change before that.

    • Method Detail

      • parseParameters

        public abstract Parameters parseParameters​(SerializationT serialization)
                                            throws java.security.GeneralSecurityException
        Parses a serialization into a Parameters object.

        This function is usually called with a Serialization matching the result of getObjectIdentifier(). However, implementations should check that this is the case.

        Throws:
        java.security.GeneralSecurityException
      • getObjectIdentifier

        public final Bytes getObjectIdentifier()
        Returns the objectIdentifier for this serialization.

        The object identifier is a unique identifier per registry for this object (in the standard proto serialization, it is the typeUrl). In other words, when registering a ParametersParser, the registry will invoke this to get the handled object identifier. In order to parse an object of type SerializationT, the registry will then obtain the objectIdentifier of this serialization object, and call the parser corresponding to this object.

      • getSerializationClass

        public final java.lang.Class<SerializationT> getSerializationClass()
      • create

        public static <SerializationT extends SerializationParametersParser<SerializationT> create​(ParametersParser.ParametersParsingFunction<SerializationT> function,
                                                                                                     Bytes objectIdentifier,
                                                                                                     java.lang.Class<SerializationT> serializationClass)
        Creates a ParametersParser object.

        In order to create a ParametersParser object, one typically writes a function

        
         class MyClass {
           private static MyParameters parse(MySerialization parametersSerialization)
                     throws GeneralSecurityException {
             ...
           }
         }
         
        This function can then be used to create a ParametersParser:
        
         ParametersParser<MySerialization> parser =
               ParametersParser.create(MyClass::parse, objectIdentifier, MySerialization.class);
         
        Parameters:
        function - The function used to parse a Parameters object.
        objectIdentifier - The identifier to be returned by getObjectIdentifier()
        serializationClass - The class object corresponding to SerializationT