org.apache.ignite.internal.binary

## Class BinaryEnumObjectImpl

- java.lang.Object
- - org.apache.ignite.internal.binary.BinaryEnumObjectImpl

All Implemented Interfaces:
  Externalizable, Serializable, Cloneable, BinaryObject, BinaryObjectEx, CacheObject, Message

    public class BinaryEnumObjectImpl
    extends Object
    implements BinaryObjectEx, Externalizable, CacheObject

Binary enum object.

See Also:
  Serialized Form

### Field Summary

### Fields inherited from interface org.apache.ignite.internal.processors.cache.CacheObject

`TYPE_BINARY, TYPE_BINARY_ENUM, TYPE_BYTE_ARR, TYPE_REGULAR`

### Fields inherited from interface org.apache.ignite.plugin.extensions.communication.Message

`DIRECT_TYPE_SIZE`

### Constructor Summary

Constructors
Constructor and Description
`BinaryEnumObjectImpl()` `Externalizable` support.
`BinaryEnumObjectImpl(BinaryContext ctx, byte[] arr)`
`BinaryEnumObjectImpl(BinaryContext ctx, int typeId, String clsName, int ord)` Constructor.

### Method Summary

Methods
`byte` `cacheObjectType()`
`String` `className()`
`BinaryObject` `clone()` Copies this binary object.
`<T> T` `deserialize()` Gets fully deserialized instance of binary object.
`short` `directType()` Gets message type.
`String` `enumName()` Get name for this enum object.
`int` `enumOrdinal()` Get ordinal for this enum object.
`boolean` `equals(Object obj)`
`<F> F` `field(String fieldName)` Gets field value.
`byte` `fieldsCount()` Gets fields count.
`void` `finishUnmarshal(CacheObjectValueContext ctx, ClassLoader ldr)`
`boolean` `hasField(String fieldName)` Checks whether field exists in the object.
`int` `hashCode()`
`boolean` `isFlagSet(short flag)` Check if flag set.
`boolean` `isPlatformType()` Gets flag indicating whether object value is a platform type.
`boolean` `isTypeEquals(Class<?> cls)`
`void` `onAckReceived()` Method called when ack message received.
`CacheObject` `prepareForCache(CacheObjectContext ctx)` Prepares cache object for cache (e.g. copies user-provided object if needed).
`void` `prepareMarshal(CacheObjectValueContext ctx)`
`boolean` `putValue(ByteBuffer buf)`
`boolean` `putValue(ByteBuffer buf, int off, int len)`
`int` `putValue(long addr)`
`BinaryType` `rawType()` Get raw type.
`void` `readExternal(ObjectInput in)`
`boolean` `readFrom(ByteBuffer buf, MessageReader reader)` Reads this message from provided byte buffer.
`BinaryObjectBuilder` `toBuilder()` Creates a new `BinaryObjectBuilder` based on this binary object.
`String` `toString()`
`BinaryType` `type()` Gets type information for this binary object.
`int` `typeId()`
`<T> T` `value(CacheObjectValueContext ctx, boolean cpy)`
`byte[]` `valueBytes(CacheObjectValueContext cacheCtx)`
`int` `valueBytesLength(CacheObjectContext ctx)`
`void` `writeExternal(ObjectOutput out)`
`boolean` `writeTo(ByteBuffer buf, MessageWriter writer)` Writes this message to provided byte buffer.

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

`finalize, getClass, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### BinaryEnumObjectImpl

    public BinaryEnumObjectImpl()

`Externalizable` support.

#### BinaryEnumObjectImpl

    public BinaryEnumObjectImpl(BinaryContext ctx,
                        int typeId,
                        @Nullable
                        String clsName,
                        int ord)

Constructor.

Parameters:
  `ctx` - Context.
  `typeId` - Type ID.
  `clsName` - Class name.
  `ord` - Ordinal.

#### BinaryEnumObjectImpl

    public BinaryEnumObjectImpl(BinaryContext ctx,
                        byte[] arr)

Parameters:
  `ctx` - Context.
  `arr` - Array.

### Method Detail

#### className

    @Nullable
    public String className()

Returns:
  Class name.

#### typeId

    public int typeId()

Specified by:
  `typeId` in interface `BinaryObjectEx`
Returns:
  Type ID.

#### type

    public BinaryType type()
                    throws BinaryObjectException

Gets type information for this binary object.

Specified by:
  `type` in interface `BinaryObject`
Returns:
  Binary object type information.
Throws:
  `BinaryObjectException` - In case of error.

#### rawType

    @Nullable
    public BinaryType rawType()
                       throws BinaryObjectException

Get raw type.

Specified by:
  `rawType` in interface `BinaryObjectEx`
Returns:
  Raw type
Throws:
  `BinaryObjectException` - If failed.

#### isFlagSet

    public boolean isFlagSet(short flag)

Check if flag set.

Specified by:
  `isFlagSet` in interface `BinaryObjectEx`
Parameters:
  `flag` - flag to check.
Returns:
  `true` if flag is set, `false` otherwise.

#### field

    public <F> F field(String fieldName)
            throws BinaryObjectException

Gets field value.

Specified by:
  `field` in interface `BinaryObject`
Parameters:
  `fieldName` - Field name.
Returns:
  Field value.
Throws:
  `BinaryObjectException` - In case of any other error.

#### hasField

    public boolean hasField(String fieldName)

Checks whether field exists in the object.

Specified by:
  `hasField` in interface `BinaryObject`
Parameters:
  `fieldName` - Field name.
Returns:
  `True` if field exists.

#### deserialize

    public <T> T deserialize()
                  throws BinaryObjectException

Gets fully deserialized instance of binary object.

Specified by:
  `deserialize` in interface `BinaryObject`
Returns:
  Fully deserialized instance of binary object.
Throws:
  `BinaryInvalidTypeException` - If class doesn't exist.
  `BinaryObjectException` - In case of any other error.

#### clone

    public BinaryObject clone()
                       throws CloneNotSupportedException

Copies this binary object.

Specified by:
  `clone` in interface `BinaryObject`
Overrides:
  `clone` in class `Object`
Returns:
  Copy of this binary object.
Throws:
  `CloneNotSupportedException`

#### toBuilder

    public BinaryObjectBuilder toBuilder()
                                  throws BinaryObjectException

Creates a new `BinaryObjectBuilder` based on this binary object. The following code

     BinaryObjectBuilder builder = binaryObject.toBuilder();

is equivalent to

     BinaryObjectBuilder builder = ignite.binary().builder(binaryObject);

Specified by:
  `toBuilder` in interface `BinaryObject`
Returns:
  Binary object builder.
Throws:
  `BinaryObjectException` - If builder cannot be created.

#### enumOrdinal

    public int enumOrdinal()
                    throws BinaryObjectException

Get ordinal for this enum object. Use `BinaryType.isEnum()` to check if object is of enum type.

Specified by:
  `enumOrdinal` in interface `BinaryObject`
Returns:
  Ordinal.
Throws:
  `BinaryObjectException` - If object is not enum.

#### enumName

    public String enumName()
                    throws BinaryObjectException

Get name for this enum object. Use `BinaryType.isEnum()` to check if object is of enum type.

Specified by:
  `enumName` in interface `BinaryObject`
Returns:
  Name.
Throws:
  `BinaryObjectException` - If object is not enum.

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `Object`

#### equals

    public boolean equals(Object obj)

Overrides:
  `equals` in class `Object`

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

#### writeExternal

    public void writeExternal(ObjectOutput out)
                       throws IOException

Specified by:
  `writeExternal` in interface `Externalizable`
Throws:
  `IOException`

#### readExternal

    public void readExternal(ObjectInput in)
                      throws IOException,
                             ClassNotFoundException

Specified by:
  `readExternal` in interface `Externalizable`
Throws:
  `IOException`
  `ClassNotFoundException`

#### value

    @Nullable
    public <T> T value(CacheObjectValueContext ctx,
                       boolean cpy)

Specified by:
  `value` in interface `CacheObject`
Parameters:
  `ctx` - Context.
  `cpy` - If `true` need to copy value.
Returns:
  Value.

#### valueBytes

    public byte[] valueBytes(CacheObjectValueContext cacheCtx)
                      throws IgniteCheckedException

Specified by:
  `valueBytes` in interface `CacheObject`
Parameters:
  `cacheCtx` - Context.
Returns:
  Value bytes.
Throws:
  `IgniteCheckedException` - If failed.

#### putValue

    public boolean putValue(ByteBuffer buf)
                     throws IgniteCheckedException

Specified by:
  `putValue` in interface `CacheObject`
Parameters:
  `buf` - Buffer to write value to.
Returns:
  `True` if value was successfully written, `false` if there was not enough space in the buffer.
Throws:
  `IgniteCheckedException` - If failed.

#### putValue

    public int putValue(long addr)
                 throws IgniteCheckedException

Specified by:
  `putValue` in interface `CacheObject`
Parameters:
  `addr` - Address tp write value to.
Returns:
  Number of bytes written.
Throws:
  `IgniteCheckedException` - If failed.

#### putValue

    public boolean putValue(ByteBuffer buf,
                   int off,
                   int len)
                     throws IgniteCheckedException

Specified by:
  `putValue` in interface `CacheObject`
Parameters:
  `buf` - Buffer to write value to.
  `off` - Offset in source binary data.
  `len` - Length of the data to write.
Returns:
  `True` if value was successfully written, `false` if there was not enough space in the buffer.
Throws:
  `IgniteCheckedException` - If failed.

#### valueBytesLength

    public int valueBytesLength(CacheObjectContext ctx)
                         throws IgniteCheckedException

Specified by:
  `valueBytesLength` in interface `CacheObject`
Parameters:
  `ctx` - Cache object context.
Returns:
  Size required to store this value object.
Throws:
  `IgniteCheckedException` - If failed.

#### cacheObjectType

    public byte cacheObjectType()

Specified by:
  `cacheObjectType` in interface `CacheObject`
Returns:
  Object type.

#### isPlatformType

    public boolean isPlatformType()

Gets flag indicating whether object value is a platform type. Platform types will be automatically deserialized on public API cache operations regardless whether `IgniteCache.withKeepBinary()` is used or not.

Specified by:
  `isPlatformType` in interface `CacheObject`
Returns:
  Platform type flag.

#### prepareForCache

    public CacheObject prepareForCache(CacheObjectContext ctx)

Prepares cache object for cache (e.g. copies user-provided object if needed).

Specified by:
  `prepareForCache` in interface `CacheObject`
Parameters:
  `ctx` - Cache context.
Returns:
  Instance to store in cache.

#### finishUnmarshal

    public void finishUnmarshal(CacheObjectValueContext ctx,
                       ClassLoader ldr)
                         throws IgniteCheckedException

Specified by:
  `finishUnmarshal` in interface `CacheObject`
Parameters:
  `ctx` - Context.
  `ldr` - Class loader.
Throws:
  `IgniteCheckedException` - If failed.

#### prepareMarshal

    public void prepareMarshal(CacheObjectValueContext ctx)
                        throws IgniteCheckedException

Specified by:
  `prepareMarshal` in interface `CacheObject`
Parameters:
  `ctx` - Context.
Throws:
  `IgniteCheckedException` - If failed.

#### onAckReceived

    public void onAckReceived()

Method called when ack message received.

Specified by:
  `onAckReceived` in interface `Message`

#### directType

    public short directType()

Gets message type.

Specified by:
  `directType` in interface `Message`
Returns:
  Message type.

#### fieldsCount

    public byte fieldsCount()

Gets fields count.

Specified by:
  `fieldsCount` in interface `Message`
Returns:
  Fields count.

#### writeTo

    public boolean writeTo(ByteBuffer buf,
                  MessageWriter writer)

Writes this message to provided byte buffer.

Specified by:
  `writeTo` in interface `Message`
Parameters:
  `buf` - Byte buffer.
  `writer` - Writer.
Returns:
  Whether message was fully written.

#### readFrom

    public boolean readFrom(ByteBuffer buf,
                   MessageReader reader)

Reads this message from provided byte buffer.

Specified by:
  `readFrom` in interface `Message`
Parameters:
  `buf` - Byte buffer.
  `reader` - Reader.
Returns:
  Whether message was fully read.

#### isTypeEquals

    public boolean isTypeEquals(Class<?> cls)

Parameters:
  `cls` - type to examine.
Returns:
  true if typeId equals for passed type and current binary enum.

2017 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 2.1.0
Release Date | : July 20 2017