All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.tarantool.driver.api.tuple.operations.TupleOperationBitwiseOr Maven / Gradle / Ivy

Go to download

Tarantool Cartridge driver for Tarantool versions 1.10+ based on Netty framework

There is a newer version: 0.14.0
Show newest version
package io.tarantool.driver.api.tuple.operations;


/**
 * Represents bitwise OR operation on tuple field
 *
 * @author Sergey Volgin
 */
public class TupleOperationBitwiseOr extends TupleUpdateOperation {

    public TupleOperationBitwiseOr(int fieldIndex, long value) {
        super(TarantoolUpdateOperationType.BITWISEOR, fieldIndex, value);
        checkValue(value);
    }

    public TupleOperationBitwiseOr(String fieldName, long value) {
        super(TarantoolUpdateOperationType.BITWISEOR, fieldName, value);
        checkValue(value);
    }

    private TupleOperationBitwiseOr(
        TarantoolUpdateOperationType operationType, Integer fieldIndex,
        String fieldName, Object value, boolean isProxyOperation) {
        super(operationType, fieldIndex, fieldName, value, isProxyOperation);
    }

    @Override
    public TupleOperation toProxyTupleOperation() {
        return new TupleOperationBitwiseOr(
            this.getOperationType(),
            this.getFieldNumber(),
            this.getFieldName(),
            this.getValue(),
            true
        );
    }

    private void checkValue(long value) {
        if (value < 0) {
            throw new IllegalArgumentException("Bitwise operations can be performed only with values >= 0");
        }
    }

    @Override
    public TupleOperation cloneWithIndex(int fieldMetadataIndex) {
        return new TupleOperationBitwiseOr(
            this.getOperationType(),
            fieldMetadataIndex,
            this.getFieldName(),
            this.getValue(),
            this.isProxyOperation()
        );
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy