Example usage for com.google.common.collect Ranges upTo

List of usage examples for com.google.common.collect Ranges upTo

Introduction

In this page you can find the example usage for com.google.common.collect Ranges upTo.

Prototype

public static <C extends Comparable<?>> Range<C> upTo(C paramC, BoundType paramBoundType)

Source Link

Usage

From source file:org.jage.communication.common.cache.AddressSet.java

@Override
public void init() {
    // Evictor//from ww  w. j a  v  a2s  .c o  m
    service = Executors.newScheduledThreadPool(1);
    service.scheduleWithFixedDelay(new Runnable() {

        @Override
        public void run() {
            synchronized (addresses) {
                Map<INodeAddress, Long> expired = Maps.filterValues(addresses,
                        Ranges.upTo(System.currentTimeMillis(), BoundType.CLOSED));
                for (INodeAddress address : expired.keySet()) {
                    log.debug("Node {} is no longer my neighbour.", address);
                    addresses.remove(address);
                }
                if (!expired.isEmpty()) {
                    informOfCacheChange();
                }
            }
        }
    }, cacheEvictionPeriod, cacheEvictionPeriod, TimeUnit.SECONDS);
}

From source file:org.jage.communication.common.cache.AddressMap.java

@Override
public void init() {
    // Evictor/*from   w  ww.  j  ava 2  s  .co m*/
    service = Executors.newScheduledThreadPool(1);
    service.scheduleWithFixedDelay(new Runnable() {

        @Override
        public void run() {
            synchronized (mappingsMutex) {
                Map<INodeAddress, Long> expired = Maps.filterValues(expirations,
                        Ranges.upTo(System.currentTimeMillis(), BoundType.CLOSED));
                for (INodeAddress address : expired.keySet()) {
                    log.debug("Node {} is no longer my neighbour.", address);
                    mappings.remove(address);
                    expirations.remove(address);
                }
                if (!expired.isEmpty()) {
                    informOfCacheChange();
                }
            }
        }
    }, cacheEvictionPeriod, cacheEvictionPeriod, TimeUnit.SECONDS);
}

From source file:org.eclipse.smarthome.transform.scale.internal.ScaleTransformationService.java

private Range<Double> getRange(BoundType lowBoundType, BoundType highBoundType, Double lowValue,
        Double highValue) {// ww w.  j  av a2 s  . c om

    if (lowValue == null && highValue == null) {
        return Ranges.all();
    } else if (lowValue == null) {
        return Ranges.upTo(highValue, highBoundType);
    } else if (highValue == null) {
        return Ranges.downTo(lowValue, lowBoundType);
    } else {
        return Ranges.range(lowValue, lowBoundType, highValue, highBoundType);
    }

}