Example usage for java.util OptionalLong of

List of usage examples for java.util OptionalLong of

Introduction

In this page you can find the example usage for java.util OptionalLong of.

Prototype

public static OptionalLong of(long value) 

Source Link

Document

Returns an OptionalLong describing the given value.

Usage

From source file:com.addthis.bundle.util.AutoField.java

default OptionalLong getLong(Bundle bundle) {
    ValueObject valueObject = getValue(bundle);
    if (valueObject == null) {
        return OptionalLong.empty();
    }//from w ww  . ja  v  a  2s.  co  m
    return OptionalLong.of(ValueUtil.asNumberOrParse(valueObject).asLong().asNative());
}

From source file:org.apache.hadoop.hbase.regionserver.HStoreFile.java

@Override
public OptionalLong getBulkLoadTimestamp() {
    byte[] bulkLoadTimestamp = metadataMap.get(BULKLOAD_TIME_KEY);
    return bulkLoadTimestamp == null ? OptionalLong.empty() : OptionalLong.of(Bytes.toLong(bulkLoadTimestamp));
}

From source file:org.apache.hadoop.hbase.regionserver.HStoreFile.java

@Override
public OptionalLong getMinimumTimestamp() {
    TimeRange tr = getReader().timeRange;
    return tr != null ? OptionalLong.of(tr.getMin()) : OptionalLong.empty();
}

From source file:org.apache.hadoop.hbase.regionserver.HStoreFile.java

@Override
public OptionalLong getMaximumTimestamp() {
    TimeRange tr = getReader().timeRange;
    return tr != null ? OptionalLong.of(tr.getMax()) : OptionalLong.empty();
}

From source file:org.apache.hadoop.hbase.regionserver.TestHStoreFile.java

/**
 * Create a mock StoreFile with the given attributes.
 *///from  w  w w  . j  av a  2 s .c o  m
private HStoreFile mockStoreFile(boolean bulkLoad, long size, long bulkTimestamp, long seqId, String path) {
    HStoreFile mock = Mockito.mock(HStoreFile.class);
    StoreFileReader reader = Mockito.mock(StoreFileReader.class);

    Mockito.doReturn(size).when(reader).length();

    Mockito.doReturn(reader).when(mock).getReader();
    Mockito.doReturn(bulkLoad).when(mock).isBulkLoadResult();
    Mockito.doReturn(OptionalLong.of(bulkTimestamp)).when(mock).getBulkLoadTimestamp();
    Mockito.doReturn(seqId).when(mock).getMaxSequenceId();
    Mockito.doReturn(new Path(path)).when(mock).getPath();
    String name = "mock storefile, bulkLoad=" + bulkLoad + " bulkTimestamp=" + bulkTimestamp + " seqId=" + seqId
            + " path=" + path;
    Mockito.doReturn(name).when(mock).toString();
    return mock;
}