当前位置: 首页>>代码示例>>Java>>正文


Java BoundType.CLOSED属性代码示例

本文整理汇总了Java中com.google.common.collect.BoundType.CLOSED属性的典型用法代码示例。如果您正苦于以下问题:Java BoundType.CLOSED属性的具体用法?Java BoundType.CLOSED怎么用?Java BoundType.CLOSED使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.google.common.collect.BoundType的用法示例。


在下文中一共展示了BoundType.CLOSED属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testIncludes

@Test
public void testIncludes() throws Exception {
    DestinationName dn = DestinationName.get("persistent://pulsar/use/ns1/topic-1");
    Long hashKey = factory.getLongHashCode(dn.toString());
    Long upper = Math.max(hashKey + 1, NamespaceBundles.FULL_UPPER_BOUND);
    BoundType upperType = upper.equals(NamespaceBundles.FULL_UPPER_BOUND) ? BoundType.CLOSED : BoundType.OPEN;
    NamespaceBundle bundle = factory.getBundle(dn.getNamespaceObject(),
            Range.range(hashKey / 2, BoundType.CLOSED, upper, upperType));
    assertTrue(bundle.includes(dn));
    bundle = factory.getBundle(NamespaceName.get("pulsar/use/ns1"),
            Range.range(upper, BoundType.CLOSED, NamespaceBundles.FULL_UPPER_BOUND, BoundType.CLOSED));
    assertTrue(!bundle.includes(dn));

    NamespaceBundle otherBundle = factory.getBundle(NamespaceName.get("pulsar/use/ns2"),
            Range.range(0l, BoundType.CLOSED, 0x40000000L, BoundType.OPEN));
    assertTrue(!otherBundle.includes(dn));
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:17,代码来源:NamespaceBundleTest.java

示例2: matches

@Override
protected boolean matches(IPlayerQuery query, MatchPlayer player) {
    final StatsUserFacet facet = player.getUserContext().facet(StatsUserFacet.class);
    int kills = persistent ? facet.teamKills() : facet.lifeKills();
    if(repeat && kills > 0) {
        int modulo = this.range.upperEndpoint() - (this.range.upperBoundType() == BoundType.CLOSED ? 0 : 1);
        kills = 1 + (kills - 1) % modulo;
    }
    return this.range.contains(kills);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:10,代码来源:KillStreakFilter.java

示例3: describe

/**
 * Return an english phrase describing the given {@link Range} e.g.
 *
 *     Range.all()                      -> "unbounded"
 *     Range.singleton(3)               -> "3"
 *     Range.atLeast(3)                 -> "at least 3"
 *     Range.closedOpen(3, 7)           -> "at least 3 and less than 7"
 *     Range.closed(3, 7)               -> "between 3 and 7"
 */
public static String describe(Range<?> range) {
    if(range.hasLowerBound() && range.hasUpperBound() && range.lowerBoundType() == BoundType.CLOSED && range.upperBoundType() == BoundType.CLOSED) {
        if(range.lowerEndpoint().equals(range.upperEndpoint())) {
            // singleton
            return range.lowerEndpoint().toString();
        } else {
            // closed-closed
            return "between " + range.lowerEndpoint() + " and " + range.upperEndpoint();
        }
    }

    final List<String> parts = new ArrayList<>(2);

    if(range.hasLowerBound()) {
        parts.add((range.lowerBoundType() == BoundType.CLOSED ? "at least " : "more than ") + range.lowerEndpoint());
    }

    if(range.hasUpperBound()) {
        parts.add((range.upperBoundType() == BoundType.CLOSED ? "at most " : "less than ") + range.upperEndpoint());
    }

    switch(parts.size()) {
        case 0: return "unbounded";
        case 1: return parts.get(0);
        default: return parts.get(0) + " and " + parts.get(1);
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:36,代码来源:Ranges.java

示例4: nextInt

default int nextInt(final Range<Integer> range) {
    final int upperEndPoint = range.hasUpperBound()
            ? range.upperBoundType() == BoundType.CLOSED ? range.upperEndpoint() : range.upperEndpoint() - 1
            : Integer.MAX_VALUE;

    final int lowerEndPoint = range.hasLowerBound()
            ? range.lowerBoundType() == BoundType.CLOSED ? range.lowerEndpoint() : range.lowerEndpoint() + 1
            : Integer.MIN_VALUE;

    return nextIntBetween(lowerEndPoint, upperEndPoint);
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:11,代码来源:NumberGenerator.java

示例5: getHashRange

private static Range<Long> getHashRange(String rangePathPart) {
    String[] endPoints = rangePathPart.split("_");
    checkArgument(endPoints.length == 2, "Malformed bundle hash range path part:" + rangePathPart);
    Long startLong = Long.decode(endPoints[0]);
    Long endLong = Long.decode(endPoints[1]);
    BoundType endType = (endPoints[1].equals(LAST_BOUNDARY)) ? BoundType.CLOSED : BoundType.OPEN;
    return Range.range(startLong, BoundType.CLOSED, endLong, endType);
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:8,代码来源:ServiceUnitZkUtils.java

示例6: RestartingS3InputStream

public RestartingS3InputStream(AmazonS3 s3, String bucket, String key, @Nullable Range<Long> range) {
    _s3 = s3;
    _bucket = bucket;
    _key = key;

    S3Object s3Object;

    // Get the object synchronously so any immediate S3 errors, such as file not found, are thrown inline.
    if (range == null) {
        s3Object = _s3.getObject(new GetObjectRequest(_bucket, _key));
        _pos = 0;
        _length = s3Object.getObjectMetadata().getContentLength();
    } else {
        long start, end;

        if (range.hasLowerBound()) {
            start = range.lowerEndpoint() + (range.lowerBoundType() == BoundType.CLOSED ? 0 : 1);
        } else {
            start = 0;
        }

        if (range.hasUpperBound()) {
            end = range.upperEndpoint() - (range.upperBoundType() == BoundType.CLOSED ? 0 : 1);
        } else {
            end = Long.MAX_VALUE;
        }

        s3Object = _s3.getObject(new GetObjectRequest(_bucket, _key).withRange(start, end));

        _pos = start;
        // The S3 metadata's content length is the length of the data actually being returned by S3.
        // Since we effectively skipped the first "start" bytes we need to add them back to the total length
        // of data being read to make future calculations using _pos and _length consistent.
        _length = start + s3Object.getObjectMetadata().getContentLength();
    }

    _in = s3Object.getObjectContent();
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:38,代码来源:RestartingS3InputStream.java

示例7: Range

public Range(final T lower,final BoundType lowerBoundType,
			 final T upper,final BoundType upperBoundType) {
	// store the lower and upper bounds
	_lowerBound = lower;
	_upperBound = upper;
	
	_lowerBoundType = lowerBoundType;
	_upperBoundType = upperBoundType;
	
	// Create the delegate
	if (_lowerBound != null && _upperBound != null) {
		if (lowerBoundType == BoundType.OPEN && upperBoundType == BoundType.OPEN) { 
			_range = com.google.common.collect.Range.open(_lowerBound,_upperBound);
		} else if (lowerBoundType == BoundType.OPEN && upperBoundType == BoundType.CLOSED) {
			_range = com.google.common.collect.Range.openClosed(_lowerBound,_upperBound);
		} else if (lowerBoundType == BoundType.CLOSED && upperBoundType == BoundType.CLOSED) {
			_range = com.google.common.collect.Range.closed(_lowerBound,_upperBound);
		} else if (lowerBoundType == BoundType.CLOSED && upperBoundType == BoundType.OPEN) {
			_range = com.google.common.collect.Range.closedOpen(_lowerBound,_upperBound);
		} else {
			throw new IllegalArgumentException("Both lower and upper bound types MUST be provided!");
		}
	} else if (_lowerBound != null) {
		if (lowerBoundType == BoundType.OPEN) {
			_range = com.google.common.collect.Range.greaterThan(_lowerBound);
		} else {
			_range = com.google.common.collect.Range.atLeast(_lowerBound);
		}
	} else if (_upperBound != null) {
		if (upperBoundType == BoundType.OPEN) {
			_range = com.google.common.collect.Range.lessThan(_upperBound);
		} else {
			_range = com.google.common.collect.Range.atMost(_upperBound);
		}
	} else {
		throw new IllegalArgumentException("Cannot create range, at least lower or upper bound SHOULD be not null");
	}
}
 
开发者ID:opendata-euskadi,项目名称:r01fb,代码行数:38,代码来源:Range.java

示例8: _numberInRangeQuery

@SuppressWarnings("rawtypes")
private static <N extends Number & Comparable> Query _numberInRangeQuery(final IndexDocumentFieldID fieldId,
																		 final Range<N> range,
																		 final Class<N> numberType) {
	boolean lowerIncluded = range.hasLowerBound() && range.lowerBoundType() == BoundType.CLOSED;
	boolean upperIncluded = range.hasUpperBound() && range.upperBoundType() == BoundType.CLOSED;
	
	N lowerBound = range.hasLowerBound() ? range.lowerEndpoint() : null;
	N upperBound = range.hasUpperBound() ? range.upperEndpoint() : null;
	
	Query outNumberEqQry = null;
	 if (numberType.equals(Integer.class)) {
		outNumberEqQry = NumericRangeQuery.newIntRange(fieldId.asString(),
													   (Integer)lowerBound,(Integer)upperBound, 
													   lowerIncluded,upperIncluded);
	 } else if (numberType.equals(Long.class)) {
		outNumberEqQry = NumericRangeQuery.newLongRange(fieldId.asString(),
														(Long)lowerBound,(Long)upperBound, 
														lowerIncluded,upperIncluded);
	} else if (numberType.equals(Double.class)) {
		outNumberEqQry = NumericRangeQuery.newDoubleRange(fieldId.asString(),
													      (Double)lowerBound,(Double)upperBound, 
													      lowerIncluded,upperIncluded);			
	} else if (numberType.equals(Float.class)) {
		outNumberEqQry = NumericRangeQuery.newFloatRange(fieldId.asString(),
													      (Float)lowerBound,(Float)upperBound, 
													      lowerIncluded,upperIncluded);
	}
	return outNumberEqQry;
}
 
开发者ID:opendata-euskadi,项目名称:r01fb,代码行数:30,代码来源:LuceneSearchQuery.java

示例9: formatTsRange

public static String formatTsRange(Range<Long> tsRange) {
    if (tsRange == null)
        return null;

    StringBuilder sb = new StringBuilder();
    if (tsRange.hasLowerBound()) {
        if (tsRange.lowerBoundType() == BoundType.CLOSED) {
            sb.append("[");
        } else {
            sb.append("(");
        }
        sb.append(DateFormat.formatToTimeStr(tsRange.lowerEndpoint()));
    } else {
        sb.append("(-∞");
    }

    sb.append("~");

    if (tsRange.hasUpperBound()) {
        sb.append(DateFormat.formatToTimeStr(tsRange.upperEndpoint()));
        if (tsRange.upperBoundType() == BoundType.CLOSED) {
            sb.append("]");
        } else {
            sb.append(")");
        }
    } else {
        sb.append("+∞)");
    }
    return sb.toString();
}
 
开发者ID:apache,项目名称:kylin,代码行数:30,代码来源:RangeUtil.java

示例10: bounds

public <O extends Comparable<? super O>>Range<O> bounds() {
  O mini = minInclusive();
  O mine = minExclusive();
  O maxi = maxInclusive();
  O maxe = maxExclusive();
  Ordering<O> ordering = Ordering.<O>natural();
  O min = ordering.nullsLast().min(mini,mine);
  O max = ordering.nullsFirst().max(maxi,maxe);
  BoundType lower = 
    min == null ? null :
    min == mini ? BoundType.CLOSED :
      BoundType.OPEN;
  BoundType upper = 
    max == null ? null : 
    max == maxi ? BoundType.CLOSED :
      BoundType.OPEN;
  if (lower == null && upper == null)
    return Range.<O>all();
  else if (lower != null && upper == null) 
    return lower == BoundType.CLOSED ? 
      Range.atLeast(min) : 
      Range.greaterThan(min);
  else if (lower == null && upper != null)
    return upper == BoundType.CLOSED ?
      Range.atMost(max) :
      Range.lessThan(max);
  else {
    return Range.range(min, lower, max, upper);
  }
}
 
开发者ID:OpenSocial,项目名称:activitystreams,代码行数:30,代码来源:Parameter.java

示例11: bt

private BoundType bt(JsonPrimitive p) {
  try {
    return BoundType.valueOf(p.toString());
  } catch (Throwable t) {
    return BoundType.CLOSED;
  }
}
 
开发者ID:OpenSocial,项目名称:activitystreams,代码行数:7,代码来源:Adapters.java

示例12: subrange

/**
 * subrange - allocate new subcolors to this range of chars, fill in arcs.
 * The range will overlap existing ranges; even in the simplest case,
 * it will overlap the initial WHITE range. For each existing range that
 * it overlaps, allocate a new color, mark the range as mapping to that color,
 * and add an arc between the states for that color.
 */
void subrange(int from, int to, State lp, State rp) throws RegexException {
    /* Avoid one call to map.get() for each character in the range.
     * This map will usually contain one item, but in complex cases more.
     * For example, if we had [a-f][g-h] and then someone asked for [f-g], there
     * would be two. Each of these new ranges will get a new color via subcolor.
     */
    Map<Range<Integer>, Short> curColors = map.subRangeMap(Range.closed(from, to)).asMapOfRanges();
    /*
     * To avoid concurrent mod problems, we need to copy the ranges we are working from.
     */
    List<Range<Integer>> ranges = Lists.newArrayList(curColors.keySet());
    for (Range<Integer> rangeToProcess : ranges) {
        // bound management here irritating.
        int start = rangeToProcess.lowerEndpoint();
        if (rangeToProcess.lowerBoundType() == BoundType.OPEN) {
            start++;
        }
        int end = rangeToProcess.upperEndpoint();
        if (rangeToProcess.upperBoundType() == BoundType.CLOSED) {
            end++;
        }
        // allocate a new subcolor and account it owning the entire range.
        short color = subcolor(start, end - start);
        compiler.getNfa().newarc(Compiler.PLAIN, color, lp, rp);
    }
}
 
开发者ID:basis-technology-corp,项目名称:tcl-regex-java,代码行数:33,代码来源:ColorMap.java

示例13: any

/**
 * Generate a {@code long} within the intersection formed by the specified {@code range} and this instance own range.
 *
 * @param range the specfied range
 * @return a generated {@code long}
 */
public long any(final Range<Long> range) {

  Range<Long> r = range.intersection(constraint);

  if (r.isEmpty()) {
    throw new IllegalStateException(String.format(
        "The intersection of the passed in range %s and this class constrained range %s result in a empty range", range, constraint));
  }

  long upperBound = r.hasUpperBound() ? r.upperEndpoint() : Long.MAX_VALUE;
  long lowerBound = r.hasLowerBound() ? r.lowerEndpoint() : Long.MIN_VALUE;

  if (r.hasUpperBound() && BoundType.CLOSED == r.upperBoundType()) {
    upperBound++;
  }

  if (r.hasLowerBound() && BoundType.OPEN == r.lowerBoundType()) {
    lowerBound++;
  }

  long delta = Math.abs(upperBound - lowerBound);

  long randomLong = ((( Math.abs(this.random.nextLong()) % (delta / resolution))) * resolution) + lowerBound ;

  return randomLong;
}
 
开发者ID:letrait,项目名称:magenta,代码行数:32,代码来源:RandomLong.java

示例14: any

/**
 * Generate a random short within the intersection of the specified
 * <code>range</code> and this instance current range.
 *
 * @param range
 *          the desired range
 * @return a randomly generated integer
 */
public short any(final Range<Short> range) {

  Range<Short> r = range.intersection(constraint);

  if (r.isEmpty()) {
    throw new IllegalStateException(String.format(
        "The intersection of the passed in range %s and this class constrained range %s result in a empty range", range, constraint));
  }

  short upperBound = r.hasUpperBound() ? r.upperEndpoint() : Short.MAX_VALUE;
  short lowerBound = r.hasLowerBound() ? r.lowerEndpoint() : Short.MIN_VALUE;

  if (BoundType.CLOSED == r.upperBoundType()) {
    // upperBound is not included in the random.nextInt() method
    upperBound++;
  }

  if (BoundType.OPEN == r.lowerBoundType()) {
    // lowerBound is included in the random.nextInt() method
    lowerBound++;
  }

  short delta = (short) Math.abs(upperBound - lowerBound);

  short anyIntRange = (short) ((this.random.nextInt(delta / resolution) * resolution) + lowerBound);

  return anyIntRange;
}
 
开发者ID:letrait,项目名称:magenta,代码行数:36,代码来源:RandomShort.java

示例15: any

/**
 * Generate a random integer within the intersection of the specified
 * <code>range</code> and this instance current range.
 *
 * @param range
 *          the desired range
 * @return a randomly generated integer
 */
public int any(final Range<Integer> range) {

  Range<Integer> r = range.intersection(constraint);

  if (r.isEmpty()) {
    throw new IllegalStateException(String.format(
        "The intersection of the passed in range %s and this class constrained range %s result in a empty range", range, constraint));
  }

  int upperBound = r.hasUpperBound() ? r.upperEndpoint() : Integer.MAX_VALUE;
  int lowerBound = r.hasLowerBound() ? r.lowerEndpoint() : Integer.MIN_VALUE;

  if (r.hasUpperBound() && BoundType.CLOSED == r.upperBoundType()) {
    // upperBound is not included in the random.nextInt() method
    upperBound++;
  }

  if (r.hasLowerBound() && BoundType.OPEN == r.lowerBoundType()) {
    // lowerBound is included in the random.nextInt() method
    lowerBound++;
  }

  int delta = Math.abs(upperBound - lowerBound);

  int anyIntegerRange = (this.random.nextInt(delta / resolution) * resolution) + lowerBound ;

  return anyIntegerRange;
}
 
开发者ID:letrait,项目名称:magenta,代码行数:36,代码来源:RandomInteger.java


注:本文中的com.google.common.collect.BoundType.CLOSED属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。