Class ClassDefinitionBuilder

java.lang.Object
com.hazelcast.nio.serialization.ClassDefinitionBuilder

public final class ClassDefinitionBuilder
extends Object
ClassDefinitionBuilder is used to build and register ClassDefinitions manually.
See Also:
ClassDefinition, Portable, SerializationConfig.addClassDefinition(ClassDefinition)
  • Constructor Details

    • ClassDefinitionBuilder

      public ClassDefinitionBuilder​(int factoryId, int classId)
      IMPORTANT: It uses a default portableVersion (0) for non-versioned classes. Make sure to specify the portableVersion in the constructor if you override the default portableVersion in the SerializationService
      Parameters:
      factoryId - factoryId to use
      classId - classId to use
    • ClassDefinitionBuilder

      public ClassDefinitionBuilder​(int factoryId, int classId, int version)
      IMPORTANT: Make sure that the version matches the portableVersion in the SerializationService
      Parameters:
      factoryId - factoryId to use
      classId - classId to use
      version - portableVersion to use
  • Method Details

    • addIntField

      public ClassDefinitionBuilder addIntField​(String fieldName)
      Parameters:
      fieldName - name of the field that will be added to this class definition
      Returns:
      itself for chaining
      Throws:
      HazelcastSerializationException - if a field with same name already exists or if this method is called after build()
    • addLongField

      public ClassDefinitionBuilder addLongField​(String fieldName)
      Parameters:
      fieldName - name of the field that will be added to this class definition
      Returns:
      itself for chaining
      Throws:
      HazelcastSerializationException - if a field with same name already exists or if this method is called after build()
    • addUTFField

      public ClassDefinitionBuilder addUTFField​(String fieldName)
      Parameters:
      fieldName - name of the field that will be added to this class definition
      Returns:
      itself for chaining
      Throws:
      HazelcastSerializationException - if a field with same name already exists or if this method is called after build()
    • addBooleanField

      public ClassDefinitionBuilder addBooleanField​(String fieldName)
      Parameters:
      fieldName - name of the field that will be added to this class definition
      Returns:
      itself for chaining
      Throws:
      HazelcastSerializationException - if a field with same name already exists or if this method is called after build()
    • addByteField

      public ClassDefinitionBuilder addByteField​(String fieldName)
      Parameters:
      fieldName - name of the field that will be added to this class definition
      Returns:
      itself for chaining
      Throws:
      HazelcastSerializationException - if a field with same name already exists or if this method is called after build()
    • addBooleanArrayField

      public ClassDefinitionBuilder addBooleanArrayField​(String fieldName)
      Parameters:
      fieldName - name of the field that will be added to this class definition
      Returns:
      itself for chaining
      Throws:
      HazelcastSerializationException - if a field with same name already exists or if this method is called after build()
    • addCharField

      public ClassDefinitionBuilder addCharField​(String fieldName)
      Parameters:
      fieldName - name of the field that will be added to this class definition
      Returns:
      itself for chaining
      Throws:
      HazelcastSerializationException - if a field with same name already exists or if this method is called after build()
    • addDoubleField

      public ClassDefinitionBuilder addDoubleField​(String fieldName)
      Parameters:
      fieldName - name of the field that will be added to this class definition
      Returns:
      itself for chaining
      Throws:
      HazelcastSerializationException - if a field with same name already exists or if this method is called after build()
    • addFloatField

      public ClassDefinitionBuilder addFloatField​(String fieldName)
      Parameters:
      fieldName - name of the field that will be added to this class definition
      Returns:
      itself for chaining
      Throws:
      HazelcastSerializationException - if a field with same name already exists or if this method is called after build()
    • addShortField

      public ClassDefinitionBuilder addShortField​(String fieldName)
      Parameters:
      fieldName - name of the field that will be added to this class definition
      Returns:
      itself for chaining
      Throws:
      HazelcastSerializationException - if a field with same name already exists or if this method is called after build()
    • addByteArrayField

      public ClassDefinitionBuilder addByteArrayField​(String fieldName)
      Parameters:
      fieldName - name of the field that will be added to this class definition
      Returns:
      itself for chaining
      Throws:
      HazelcastSerializationException - if a field with same name already exists or if this method is called after build()
    • addCharArrayField

      public ClassDefinitionBuilder addCharArrayField​(String fieldName)
      Parameters:
      fieldName - name of the field that will be added to this class definition
      Returns:
      itself for chaining
      Throws:
      HazelcastSerializationException - if a field with same name already exists or if this method is called after build()
    • addIntArrayField

      public ClassDefinitionBuilder addIntArrayField​(String fieldName)
      Parameters:
      fieldName - name of the field that will be added to this class definition
      Returns:
      itself for chaining
      Throws:
      HazelcastSerializationException - if a field with same name already exists or if this method is called after build()
    • addLongArrayField

      public ClassDefinitionBuilder addLongArrayField​(String fieldName)
      Parameters:
      fieldName - name of the field that will be added to this class definition
      Returns:
      itself for chaining
      Throws:
      HazelcastSerializationException - if a field with same name already exists or if this method is called after build()
    • addDoubleArrayField

      public ClassDefinitionBuilder addDoubleArrayField​(String fieldName)
      Parameters:
      fieldName - name of the field that will be added to this class definition
      Returns:
      itself for chaining
      Throws:
      HazelcastSerializationException - if a field with same name already exists or if this method is called after build()
    • addFloatArrayField

      public ClassDefinitionBuilder addFloatArrayField​(String fieldName)
      Parameters:
      fieldName - name of the field that will be added to this class definition
      Returns:
      itself for chaining
      Throws:
      HazelcastSerializationException - if a field with same name already exists or if this method is called after build()
    • addShortArrayField

      public ClassDefinitionBuilder addShortArrayField​(String fieldName)
      Parameters:
      fieldName - name of the field that will be added to this class definition
      Returns:
      itself for chaining
      Throws:
      HazelcastSerializationException - if a field with same name already exists or if this method is called after build()
    • addUTFArrayField

      public ClassDefinitionBuilder addUTFArrayField​(String fieldName)
      Parameters:
      fieldName - name of the field that will be added to this class definition
      Returns:
      itself for chaining
      Throws:
      HazelcastSerializationException - if a field with same name already exists or if this method is called after build()
    • addPortableField

      public ClassDefinitionBuilder addPortableField​(String fieldName, ClassDefinition def)
      Parameters:
      fieldName - name of the field that will be added to this class definition
      Returns:
      itself for chaining
      Throws:
      HazelcastSerializationException - if a field with same name already exists or if this method is called after build()
    • addPortableArrayField

      public ClassDefinitionBuilder addPortableArrayField​(String fieldName, ClassDefinition classDefinition)
      Parameters:
      fieldName - name of the field that will be add to this class definition
      classDefinition - class definition of the nested portable that will be add to this class definition
      Returns:
      itself for chaining
      Throws:
      HazelcastSerializationException - if a field with same name already exists or if this method is called after build()
    • addField

      @PrivateApi public ClassDefinitionBuilder addField​(com.hazelcast.internal.serialization.impl.portable.FieldDefinitionImpl fieldDefinition)
    • build

      public ClassDefinition build()
      Returns:
      creates and returns a new ClassDefinition
    • getFactoryId

      public int getFactoryId()
    • getClassId

      public int getClassId()
    • getVersion

      public int getVersion()