org.apache.ignite.binary

## Interface BinaryObjectBuilder

All Known Implementing Classes:
  BinaryObjectBuilderImpl

    public interface BinaryObjectBuilder

Binary object builder. Provides ability to build binary objects dynamically without having class definitions.

Here is an example of how a binary object can be built dynamically:

     BinaryObjectBuilder builder = Ignition.ignite().binary().builder("org.project.MyObject");

     builder.setField("fieldA", "A");
     builder.setField("fieldB", "B");

     BinaryObject binaryObj = builder.build();

Also builder can be initialized by existing binary object. This allows changing some fields without affecting other fields.

     BinaryObjectBuilder builder = Ignition.ignite().binary().builder(person);

     builder.setField("name", "John");

     person = builder.build();

If you need to modify nested binary object you can get an instance of a builder for nested binary object using `getField(String)`, changes made on nested builder will affect parent object, for example:

     BinaryObjectBuilder personBuilder = grid.binary().createBuilder(personBinaryObj);
     BinaryObjectBuilder addressBuilder = personBuilder.getField("address");

     addressBuilder.setField("city", "New York");

     personBinaryObj = personBuilder.build();

     // Should be "New York".
     String city = personBinaryObj.getField("address").getField("city");

See Also:
  `IgniteBinary.builder(String)`, `IgniteBinary.builder(BinaryObject)`

### Method Summary

Methods
`BinaryObject` `build()` Builds binary object.
`<T> T` `getField(String name)` Returns value assigned to the specified field.
`BinaryObjectBuilder` `hashCode(int hashCode)` Sets hash code for resulting binary object returned by `build()` method.
`BinaryObjectBuilder` `removeField(String fieldName)` Removes field from this builder.
`BinaryObjectBuilder` `setField(String name, BinaryObjectBuilder builder)` Sets field value.
`BinaryObjectBuilder` `setField(String name, Object val)` Sets field value.
`<T> BinaryObjectBuilder` `setField(String name, T val, Class<? super T> type)` Sets field value with value type specification.

### Method Detail

#### getField

    <T> T getField(String name)

Returns value assigned to the specified field. If the value is a binary object then an instance of `BinaryObjectBuilder` will be returned, which can be modified.

Collections and maps returned from this method are modifiable.

Parameters:
  `name` - Field name.
Returns:
  Filed value.

#### setField

    BinaryObjectBuilder setField(String name,
                               Object val)

Sets field value.

Parameters:
  `name` - Field name.
  `val` - Field value (cannot be `null`).
See Also:
  `BinaryObject.type()`

#### setField

    <T> BinaryObjectBuilder setField(String name,
                                   @Nullable
                                   T val,
                                   Class<? super T> type)

Sets field value with value type specification.

Field type is needed for proper metadata update.

Parameters:
  `name` - Field name.
  `val` - Field value.
  `type` - Field type.
See Also:
  `BinaryObject.type()`

#### setField

    BinaryObjectBuilder setField(String name,
                               @Nullable
                               BinaryObjectBuilder builder)

Sets field value.

This method should be used if field is binary object.

Parameters:
  `name` - Field name.
  `builder` - Builder for object field.

#### removeField

    BinaryObjectBuilder removeField(String fieldName)

Removes field from this builder.

Parameters:
  `fieldName` - Field name.
Returns:
  `this` instance for chaining.

#### hashCode

    BinaryObjectBuilder hashCode(int hashCode)

Sets hash code for resulting binary object returned by `build()` method.

If not set `0` is used.

Parameters:
  `hashCode` - Hash code.
Returns:
  `this` instance for chaining.

#### build

    BinaryObject build()
                       throws BinaryObjectException

Builds binary object.

Returns:
  Binary object.
Throws:
  `BinaryObjectException` - In case of error.

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.6.0
Release Date | : May 18 2016