Example usage for org.apache.commons.lang3.mutable MutableInt subtract

List of usage examples for org.apache.commons.lang3.mutable MutableInt subtract

Introduction

In this page you can find the example usage for org.apache.commons.lang3.mutable MutableInt subtract.

Prototype

public void subtract(final Number operand) 

Source Link

Document

Subtracts a value from the value of this instance.

Usage

From source file:org.apache.apex.malhar.lib.utils.serde.SerdeCollectionSlice.java

@Override
public CollectionT deserialize(Slice slice, MutableInt offset) {
    MutableInt sliceOffset = new MutableInt(slice.offset + offset.intValue());

    int numElements = GPOUtils.deserializeInt(slice.buffer, sliceOffset);
    sliceOffset.subtract(slice.offset);
    try {/*from   w  ww. j  av  a 2 s . c  om*/
        CollectionT collection = collectionClass.newInstance();

        for (int index = 0; index < numElements; index++) {
            T object = serde.deserialize(slice, sliceOffset);
            collection.add(object);
        }

        offset.setValue(sliceOffset.intValue());
        return collection;
    } catch (Exception ex) {
        throw Throwables.propagate(ex);
    }
}

From source file:org.apache.apex.malhar.lib.utils.serde.SerdeStringSlice.java

@Override
public String deserialize(Slice object, MutableInt offset) {
    offset.add(object.offset);/*from   w  w  w  . j av a 2  s  .c o m*/
    String string = GPOUtils.deserializeString(object.buffer, offset);
    offset.subtract(object.offset);
    return string;
}