Guava Range - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Guava Range class.

This code example shows how to use the following methods:hasLowerBound, hasUpperBound, lowerEndpoint, upperEndpoint
        this.cidr = Rule.CIDR_ALL;
        return this;
    } 
 
    public RuleBuilder ports(Range<Integer> ports) {
        checkArgument(ports.hasUpperBound(), "ports should have a closed upper bound");
        checkArgument(ports.hasLowerBound(), "ports should have a closed lower bound ");
 
        checkArgument(ports.lowerEndpoint() > 0, "ports should be a positive range");
        checkArgument(ports.upperEndpoint() < 65535, "ports upper bound should less than 65535");
 
        this.ports = checkNotNull(ports, "ports is null");
        return this;
    } 
 
    public RuleBuilder ports(int lowerPort, int upperPort) {
        return ports(Ranges.closed(lowerPort, upperPort));
    } 
 
    public RuleBuilder port(int port) {
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:hasLowerBound, hasUpperBound, intersection, isEmpty
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:hasLowerBound, hasUpperBound, lowerBoundType, lowerEndpoint, upperBoundType
                                    Set<FileAttribute> attr)
    { 
        setReplyRequired(true); 
        setPnfsPath(path);
        _pattern = pattern;
        _lower = range.hasLowerBound() ? range.lowerEndpoint() : null;
        _upper = range.hasUpperBound() ? range.upperEndpoint() : null;
        _lowerBoundType = range.hasLowerBound() ? range.lowerBoundType() : null;
        _upperBoundType = range.hasUpperBound() ? range.upperBoundType() : null;
        _requestedAttributes = attr;
    } 
 
    /** Returns the UUID identifying this request. */ 
    public UUID getUUID()
    { 
        return _uuid;
    } 
 
    /** Returns the pattern used to filter the result. */ 
    public Glob getPattern() 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:hasLowerBound, hasUpperBound, lowerBoundType, lowerEndpoint, upperBoundType
    } 
     
    private void _writeContents(Range<?> value, JsonGenerator jgen, SerializerProvider provider)
        throws IOException
    { 
        if (value.hasLowerBound()) {
            if (_endpointSerializer != null) { 
                jgen.writeFieldName("lowerEndpoint");
                _endpointSerializer.serialize(value.lowerEndpoint(), jgen, provider);
            } else { 
                provider.defaultSerializeField("lowerEndpoint", value.lowerEndpoint(), jgen);
            } 
            provider.defaultSerializeField("lowerBoundType", value.lowerBoundType(), jgen);
        } 
        if (value.hasUpperBound()) {
            if (_endpointSerializer != null) { 
                jgen.writeFieldName("upperEndpoint");
                _endpointSerializer.serialize(value.upperEndpoint(), jgen, provider);
            } else { 
                provider.defaultSerializeField("upperEndpoint", value.upperEndpoint(), jgen);

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:contains, encloses, lowerEndpoint, upperEndpoint
 
import com.google.common.collect.Range;
 
class ScrollUtil { 
  static int moveDelta(Range<Integer> container, Range<Integer> range) {
    if (container.encloses(range)) return 0;
    if (container.upperEndpoint() - container.lowerEndpoint() < range.upperEndpoint() - range.lowerEndpoint()) {
      return container.lowerEndpoint() - range.lowerEndpoint();
    } 
 
    if (container.contains(range.upperEndpoint())) {
      return container.lowerEndpoint() - range.lowerEndpoint();
    } 
 
    if (container.contains(range.lowerEndpoint())) {
      return container.upperEndpoint() - range.upperEndpoint();
    } 
 
    if (container.upperEndpoint() < range.lowerEndpoint()) {
      return container.upperEndpoint() - range.upperEndpoint();

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:contains, encloses, lowerEndpoint, upperEndpoint
 
import com.google.common.collect.Range;
import org.junit.Test; 
 
import static org.junit.Assert.assertEquals; 
 
public class ScrollUtilTest { 
  @Test
  public void rangeContainment() { 
    assertDelta(0, 0, 100, 1, 2); 
  } 
 
  @Test
  public void rangeLargeThanContainer() { 
    assertDelta(-1, 0, 1, 1, 100); 
  } 
 
  @Test
  public void containerContainsEnd() { 
    assertDelta(1, 10, 12, 9, 11); 

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:hasLowerBound, hasUpperBound
 
		currentShardId = keyIterator.next();
	} 
 
	public boolean isBounded(){ 
		return (keyRange.hasLowerBound() && keyRange.hasUpperBound());
	} 
 
	public long size(){ 
		return size;
	} 
 
	@Override 
	public void remove() { 
		//To change body of implemented methods use File | Settings | File Templates. 
	} 
 
	public String getObjectName() {
		return objectName;
	} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:contains
this.latitude = latitude;
        this.longitude = longitude;
        this.value = String.format( "%s,%s", this.latitude, this.longitude );
 
        if ( !LATITUDE_RANGE.contains( this.latitude ) )
        { 
            throw new IllegalArgumentException( String.format( "Latitude [%s] is not within range %s", this.latitude, LATITUDE_RANGE ) );
        } 
 
        if ( !LONGITUDE_RANGE.contains( this.longitude ) )
        { 
            throw new IllegalArgumentException( String.format( "Longitude [%s] is not within range %s", this.longitude, LONGITUDE_RANGE ) );
        } 
    } 
 
    public double getLatitude() 
    { 
        return this.latitude;
    } 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:contains
    @Override 
    public boolean accept(CacheEntry entry) 
    { 
        long lastAccess =
            System.currentTimeMillis() - entry.getLastAccessTime();
        return _time.contains(lastAccess / 1000);
    } 
} 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:contains
 
  /** 
   * Fails if the subject is not in the given range. 
   */ 
  public final void isIn(Range<T> range) {
    if (!range.contains(getSubject())) {
      fail("is in", range);
    } 
  } 
 
  /** 
   * Fails if the subject is in the given range. 
   */ 
  public final void isNotIn(Range<T> range) {
    if (range.contains(getSubject())) {
      fail("is not in", range);
    } 
  } 
 
  /** 
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
See Code Examples for Guava Range Methods: