Class Ccerial

java.lang.Object
org.gittorr.ccerial.Ccerial

public final class Ccerial extends Object
The Ccerial class is the main entry point for the Ccerial serialization framework. This utility provides methods to obtain serializers for classes annotated with CcSerializable.

Usage:


 // Example of obtaining a serializer and serializing an object
 User user = new User();
 user.setName("John");
 user.setAge(30);

 ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
 Ccerial.getSerializer(User.class).serialize(user, outputStream);

 byte[] serializedData = outputStream.toByteArray();

 ByteArrayInputStream inputStream = new ByteArrayInputStream(serializedData);
 User deserializedUser = Ccerial.getSerializer(User.class).deserialize(inputStream);
 

See Also:

  • Constructor Details

    • Ccerial

      public Ccerial()
  • Method Details

    • getSerializer

      public static <E> Serializer<E> getSerializer(Class<E> forClass)
      Retrieves the serializer for the specified class. Classes must be annotated with CcSerializable to have serializers generated.
      Type Parameters:
      E - the type of the class being serialized
      Parameters:
      forClass - the class to retrieve the serializer for
      Returns:
      the Serializer instance for the specified class
      Throws:
      IllegalArgumentException - if no serializer is found for the class