org.apache.ignite.internal.portable.builder

## Class PortableBuilderImpl

- java.lang.Object
- - org.apache.ignite.internal.portable.builder.PortableBuilderImpl

All Implemented Interfaces:
  PortableBuilder

    public class PortableBuilderImpl
    extends Object
    implements PortableBuilder

### Constructor Summary

Constructors
Constructor and Description
`PortableBuilderImpl(PortableContext ctx, int typeId)`
`PortableBuilderImpl(PortableContext ctx, int typeId, String typeName)`
`PortableBuilderImpl(PortableContext ctx, String clsName)`
`PortableBuilderImpl(PortableObjectImpl obj)`

### Method Summary

Methods
`PortableObject` `build()` Builds portable object.
`<F> F` `getField(String name)` Returns value assigned to the specified field.
`PortableBuilderImpl` `hashCode(int hashCode)` Sets hash code for resulting portable object returned by `PortableBuilder.build()` method.
`PortableBuilderImpl` `removeField(String name)` Removes field from portable object.
`PortableBuilder` `setField(String name, Object val)` Sets field value.
`PortableBuilder` `setField(String name, PortableBuilder builder)` Sets field value.
`<T> PortableBuilder` `setField(String name, T val, Class<? super T> type)` Sets field value with value type specification.
`int` `typeId()`
`static PortableBuilderImpl` `wrap(PortableObject obj)` Creates builder initialized by specified portable object.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### PortableBuilderImpl

    public PortableBuilderImpl(PortableContext ctx,
                       String clsName)

Parameters:
  `clsName` - Class name.
  `ctx` - Portable context.

#### PortableBuilderImpl

    public PortableBuilderImpl(PortableContext ctx,
                       int typeId)

Parameters:
  `typeId` - Type ID.
  `ctx` - Portable context.

#### PortableBuilderImpl

    public PortableBuilderImpl(PortableContext ctx,
                       int typeId,
                       String typeName)

Parameters:
  `typeName` - Type name.
  `ctx` - Context.
  `typeId` - Type id.

#### PortableBuilderImpl

    public PortableBuilderImpl(PortableObjectImpl obj)

Parameters:
  `obj` - Object to wrap.

### Method Detail

#### build

    public PortableObject build()

Builds portable object.

Specified by:
  `build` in interface `PortableBuilder`
Returns:
  Portable object.

#### hashCode

    public PortableBuilderImpl hashCode(int hashCode)

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

If not set `0` is used.

Specified by:
  `hashCode` in interface `PortableBuilder`
Parameters:
  `hashCode` - Hash code.
Returns:
  `this` instance for chaining.

#### getField

    public <F> F getField(String name)

Returns value assigned to the specified field. If the value is a portable object instance of `GridPortableBuilder` will be returned, which can be modified.

Collections and maps returned from this method are modifiable.

Specified by:
  `getField` in interface `PortableBuilder`
Parameters:
  `name` - Field name.
Returns:
  Filed value.

#### setField

    public PortableBuilder setField(String name,
                           Object val)

Sets field value.

Specified by:
  `setField` in interface `PortableBuilder`
Parameters:
  `name` - Field name.
  `val` - Field value (cannot be `null`).
See Also:
  `PortableObject.metaData()`

#### setField

    public <T> PortableBuilder 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.

Specified by:
  `setField` in interface `PortableBuilder`
Parameters:
  `name` - Field name.
  `val` - Field value.
  `type` - Field type.
See Also:
  `PortableObject.metaData()`

#### setField

    public PortableBuilder setField(String name,
                           @Nullable
                           PortableBuilder builder)

Sets field value.

This method should be used if field is portable object.

Specified by:
  `setField` in interface `PortableBuilder`
Parameters:
  `name` - Field name.
  `builder` - Builder for object field.

#### removeField

    public PortableBuilderImpl removeField(String name)

Removes field from portable object.

Specified by:
  `removeField` in interface `PortableBuilder`
Parameters:
  `name` - Field name.
Returns:
  `this` instance for chaining.

#### wrap

    public static PortableBuilderImpl wrap(PortableObject obj)

Creates builder initialized by specified portable object.

Parameters:
  `obj` - Portable object to initialize builder.
Returns:
  New builder.

#### typeId

    public int typeId()

Returns:
  Object type id.

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.4.0
Release Date | : September 24 2015