
com.alachisoft.ncache.client.internal.command.ListGetItemCommand Maven / Gradle / Ivy
package com.alachisoft.ncache.client.internal.command;
import Alachisoft.NCache.Common.DataTypes.List.ListGetItemOperation;
import com.alachisoft.ncache.common.protobuf.ListAddWithoutIndexProtocol;
import com.alachisoft.ncache.common.protobuf.ListCommandProtocol;
import com.alachisoft.ncache.common.protobuf.ListGetItemProtocol;
import com.alachisoft.ncache.runtime.util.TimeSpan;
public class ListGetItemCommand extends ListCommandBase {
private int _index;
private ListGetItemOperation.OpType _operationType;
private ListGetItemProtocol.ListGetItem.Builder _listGetItemCommandBuilder;
public ListGetItemCommand(ListGetItemOperation operation) {
super.name = "ListRemoveWithIndex";
super.key = operation.getName();
_index = operation.getIndex();
_lockId = (String) operation.getLockId();
_lockTimeout = operation.getLockTimeout();
_operationType = operation.getOperationType();
}
@Override
public RequestType getCommandRequestType() {
return RequestType.AtomicRead;
}
@Override
public CommandType getCommandType() {
return CommandType.DATA_TYPE;
}
@Override
protected void createCommand() {
_listGetItemCommandBuilder = ListGetItemProtocol.ListGetItem.newBuilder();
_listGetItemCommandBuilder.setIndex(_index);
switch (_operationType)
{
case First:
_listGetItemCommandBuilder.setMethod(ListGetItemProtocol.ListGetItem.Method.FIRST);
break;
case Last:
_listGetItemCommandBuilder.setMethod(ListGetItemProtocol.ListGetItem.Method.LAST);
break;
case Index:
_listGetItemCommandBuilder.setMethod(ListGetItemProtocol.ListGetItem.Method.LIST_GETTER);
break;
}
super.createCommand();
_listCommandBuilder.setType(ListCommandProtocol.ListCommand.Type.LIST_GET_ITEM);
_listCommandBuilder.setListGetItem(_listGetItemCommandBuilder.build());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy