org.apache.ignite.internal.processors.cache

## Class KeyCacheObjectImpl

- java.lang.Object
- - org.apache.ignite.internal.processors.cache.CacheObjectAdapter
  - - org.apache.ignite.internal.processors.cache.KeyCacheObjectImpl

All Implemented Interfaces:
  Externalizable, Serializable, CacheObject, KeyCacheObject, Message

Direct Known Subclasses:
  UserKeyCacheObjectImpl

    public class KeyCacheObjectImpl
    extends CacheObjectAdapter
    implements KeyCacheObject

See Also:
  Serialized Form

### Field Summary

### Fields inherited from class org.apache.ignite.internal.processors.cache.CacheObjectAdapter

`val, valBytes`

### 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
`KeyCacheObjectImpl()`
`KeyCacheObjectImpl(Object val, byte[] valBytes, int part)`

### Method Summary

All Methods Instance Methods Concrete Methods
`KeyCacheObject` `copy(int part)`
`short` `directType()` Gets message type.
`boolean` `equals(Object obj)`
`byte` `fieldsCount()` Gets fields count.
`void` `finishUnmarshal(CacheObjectValueContext ctx, ClassLoader ldr)`
`int` `hashCode()`
`boolean` `internal()`
`boolean` `isPlatformType()` Gets flag indicating whether object value is a platform type.
`void` `onAckReceived()` Method called when ack message received.
`int` `partition()`
`void` `partition(int part)` Sets partition ID for this key.
`CacheObject` `prepareForCache(CacheObjectContext ctx)` Prepares cache object for cache (e.g. copies user-provided object if needed).
`void` `prepareMarshal(CacheObjectValueContext ctx)`
`boolean` `readFrom(ByteBuffer buf, MessageReader reader)` Reads this message from provided byte buffer.
`String` `toString()`
`<T> T` `value(CacheObjectValueContext ctx, boolean cpy)`
`byte[]` `valueBytes(CacheObjectValueContext ctx)`
`boolean` `writeTo(ByteBuffer buf, MessageWriter writer)` Writes this message to provided byte buffer.

### Methods inherited from class org.apache.ignite.internal.processors.cache.CacheObjectAdapter

`cacheObjectType, needCopy, objectPutSize, putValue, putValue, putValue, putValue, putValue, readExternal, valueBytesLength, writeExternal`

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

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

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

`cacheObjectType, putValue, putValue, putValue, valueBytesLength`

### Constructor Detail

#### KeyCacheObjectImpl

    public KeyCacheObjectImpl()

#### KeyCacheObjectImpl

    public KeyCacheObjectImpl(Object val,
                              byte[] valBytes,
                              int part)

Parameters:
  `val` - Value.
  `valBytes` - Value bytes.
  `part` - Partition.

### Method Detail

#### copy

    public KeyCacheObject copy(int part)

Specified by:
  `copy` in interface `KeyCacheObject`
Parameters:
  `part` - Partition ID.
Returns:
  Copy of this object with given partition set.

#### partition

    public int partition()

Specified by:
  `partition` in interface `KeyCacheObject`
Returns:
  Partition ID for this key or -1 if it is unknown.

#### partition

    public void partition(int part)

Sets partition ID for this key.

Specified by:
  `partition` in interface `KeyCacheObject`
Parameters:
  `part` - Partition ID.

#### valueBytes

    public byte[] valueBytes(CacheObjectValueContext ctx)
                      throws IgniteCheckedException

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

#### internal

    public boolean internal()

Specified by:
  `internal` in interface `KeyCacheObject`
Returns:
  `True` if internal cache key.

#### 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.

#### 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.

#### onAckReceived

    public void onAckReceived()

Method called when ack message received.

Specified by:
  `onAckReceived` in interface `Message`

#### 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.

#### hashCode

    public int hashCode()

Specified by:
  `hashCode` in interface `KeyCacheObject`
Overrides:
  `hashCode` in class `Object`
Returns:
  Key hash code.

#### 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`
Overrides:
  `fieldsCount` in class `CacheObjectAdapter`
Returns:
  Fields count.

#### readFrom

    public boolean readFrom(ByteBuffer buf,
                            MessageReader reader)

Reads this message from provided byte buffer.

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

#### writeTo

    public boolean writeTo(ByteBuffer buf,
                           MessageWriter writer)

Writes this message to provided byte buffer.

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

#### prepareMarshal

    public void prepareMarshal(CacheObjectValueContext ctx)
                        throws IgniteCheckedException

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

#### 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.

#### equals

    public boolean equals(Object obj)

Overrides:
  `equals` in class `Object`

#### toString

    public String toString()

Overrides:
  `toString` in class `CacheObjectAdapter`

2018 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 2.4.0
Release Date | : March 5 2018