Class ClassDefinitionBuilder

    • Constructor Detail

      • 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
      • ClassDefinitionBuilder

        public ClassDefinitionBuilder​(int factoryId,
                                      int classId,
                                      int version)
        IMPORTANT: Make sure that the version matches the portableVersion in the SerializationService
      • ClassDefinitionBuilder

        public ClassDefinitionBuilder​(PortableId portableId)
        IMPORTANT: Make sure that the version matches the portableVersion in the SerializationService
        Since:
        5.4
    • Method Detail

      • addIntField

        @Nonnull
        public ClassDefinitionBuilder addIntField​(@Nonnull
                                                  java.lang.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

        @Nonnull
        public ClassDefinitionBuilder addLongField​(@Nonnull
                                                   java.lang.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

        @Nonnull
        @Deprecated
        public ClassDefinitionBuilder addUTFField​(@Nonnull
                                                  java.lang.String fieldName)
        Deprecated.
        for the sake of better naming. Use addStringField(String) instead.
        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()
      • addStringField

        @Nonnull
        public ClassDefinitionBuilder addStringField​(@Nonnull
                                                     java.lang.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

        @Nonnull
        public ClassDefinitionBuilder addBooleanField​(@Nonnull
                                                      java.lang.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

        @Nonnull
        public ClassDefinitionBuilder addByteField​(@Nonnull
                                                   java.lang.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

        @Nonnull
        public ClassDefinitionBuilder addBooleanArrayField​(@Nonnull
                                                           java.lang.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

        @Nonnull
        public ClassDefinitionBuilder addCharField​(@Nonnull
                                                   java.lang.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

        @Nonnull
        public ClassDefinitionBuilder addDoubleField​(@Nonnull
                                                     java.lang.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

        @Nonnull
        public ClassDefinitionBuilder addFloatField​(@Nonnull
                                                    java.lang.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

        @Nonnull
        public ClassDefinitionBuilder addShortField​(@Nonnull
                                                    java.lang.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()
      • addDecimalField

        @Nonnull
        public ClassDefinitionBuilder addDecimalField​(@Nonnull
                                                      java.lang.String fieldName)
        Adds a decimal which is arbitrary precision and scale floating-point number to the class definition
        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()
      • addTimeField

        @Nonnull
        public ClassDefinitionBuilder addTimeField​(@Nonnull
                                                   java.lang.String fieldName)
        Adds a time field consisting of hour, minute, seconds and nanos parts to the class definition
        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()
      • addDateField

        @Nonnull
        public ClassDefinitionBuilder addDateField​(@Nonnull
                                                   java.lang.String fieldName)
        Adds a date field consisting of year, month of the year and day of the month to the class definition
        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()
      • addTimestampField

        @Nonnull
        public ClassDefinitionBuilder addTimestampField​(@Nonnull
                                                        java.lang.String fieldName)
        Adds a timestamp field consisting of year, month of the year, day of the month, hour, minute, seconds, nanos parts to the class definition
        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()
      • addTimestampWithTimezoneField

        @Nonnull
        public ClassDefinitionBuilder addTimestampWithTimezoneField​(@Nonnull
                                                                    java.lang.String fieldName)
        Adds a timestamp with timezone field consisting of year, month of the year, day of the month, offset seconds, hour, minute, seconds, nanos parts to the class definition
        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

        @Nonnull
        public ClassDefinitionBuilder addByteArrayField​(@Nonnull
                                                        java.lang.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

        @Nonnull
        public ClassDefinitionBuilder addCharArrayField​(@Nonnull
                                                        java.lang.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

        @Nonnull
        public ClassDefinitionBuilder addIntArrayField​(@Nonnull
                                                       java.lang.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

        @Nonnull
        public ClassDefinitionBuilder addLongArrayField​(@Nonnull
                                                        java.lang.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

        @Nonnull
        public ClassDefinitionBuilder addDoubleArrayField​(@Nonnull
                                                          java.lang.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

        @Nonnull
        public ClassDefinitionBuilder addFloatArrayField​(@Nonnull
                                                         java.lang.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

        @Nonnull
        public ClassDefinitionBuilder addShortArrayField​(@Nonnull
                                                         java.lang.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

        @Nonnull
        @Deprecated
        public ClassDefinitionBuilder addUTFArrayField​(@Nonnull
                                                       java.lang.String fieldName)
        Deprecated.
        for the sake of better naming. Use addStringArrayField(String) instead.
        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()
      • addStringArrayField

        @Nonnull
        public ClassDefinitionBuilder addStringArrayField​(@Nonnull
                                                          java.lang.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

        @Nonnull
        public ClassDefinitionBuilder addPortableField​(@Nonnull
                                                       java.lang.String fieldName,
                                                       ClassDefinition classDefinition)
        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

        @Nonnull
        public ClassDefinitionBuilder addPortableArrayField​(@Nonnull
                                                            java.lang.String fieldName,
                                                            ClassDefinition classDefinition)
        Parameters:
        fieldName - name of the field that will be added to this class definition
        classDefinition - class definition of the nested portable 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()
      • addDecimalArrayField

        @Nonnull
        public ClassDefinitionBuilder addDecimalArrayField​(@Nonnull
                                                           java.lang.String fieldName)
        Adds an array of Decimal's to the class definition
        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()
        See Also:
        addDecimalField(String)
      • addTimeArrayField

        @Nonnull
        public ClassDefinitionBuilder addTimeArrayField​(@Nonnull
                                                        java.lang.String fieldName)
        Adds an array of Time's to the class definition
        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()
        See Also:
        addTimeField(String)
      • addDateArrayField

        @Nonnull
        public ClassDefinitionBuilder addDateArrayField​(@Nonnull
                                                        java.lang.String fieldName)
        Adds an array of Date's to the class definition
        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()
        See Also:
        addDateField(String)
      • addTimestampArrayField

        @Nonnull
        public ClassDefinitionBuilder addTimestampArrayField​(@Nonnull
                                                             java.lang.String fieldName)
        Adds an array of Timestamp's to the class definition
        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()
        See Also:
        addTimestampField(String)
      • addTimestampWithTimezoneArrayField

        @Nonnull
        public ClassDefinitionBuilder addTimestampWithTimezoneArrayField​(@Nonnull
                                                                         java.lang.String fieldName)
        Adds an array of TimestampWithTimezone's to the class definition
        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()
        See Also:
        addTimestampWithTimezoneField(String)
      • addField

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

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

        public int getFactoryId()
      • getClassId

        public int getClassId()
      • getVersion

        public int getVersion()
      • getPortableId

        public PortableId getPortableId()
        Since:
        5.4