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


Java Range.closed方法代码示例

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


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

示例1: findCenterPosition

import com.google.common.collect.Range; //导入方法依赖的package包/类
@Test
@Parameters(method = "findCenterPosition_params")
public void findCenterPosition(Integer itemSize, Integer containerFrom, Integer containerTo, Integer viewportFrom, Integer viewportTo, int expectedResult) {
    // given
    Rectangle viewport = new Rectangle();
    when(viewportHelper.getViewport()).thenReturn(viewport);

    Range<Integer> viewportRange = Range.closed(viewportFrom, viewportTo);
    when(rangeCreator.getRangeForAxis(viewport, Axis.HORIZONTAL)).thenReturn(viewportRange);

    Rectangle playerContainerRectangle = new Rectangle();
    when(sizeHelper.getPlayerContainerRectangle()).thenReturn(playerContainerRectangle);

    Range<Integer> container = Range.closed(containerFrom, containerTo);
    when(rangeCreator.getRangeForAxis(playerContainerRectangle, Axis.HORIZONTAL)).thenReturn(container);

    int parentAbsoluteCoord = 10;

    // when
    int result = finder.getCenterPosition(itemSize, parentAbsoluteCoord, Axis.HORIZONTAL);

    // then
    assertThat(result, equalTo(expectedResult - parentAbsoluteCoord));
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:25,代码来源:CenterPositionFinderTest.java

示例2: testTableWithTwoInds

import com.google.common.collect.Range; //导入方法依赖的package包/类
@Test
public void testTableWithTwoInds(DataAccessObject dataAccessObject) throws AlgorithmExecutionException {
    // GIVEN
    Attribute attributeA = new Attribute(new ColumnIdentifier(TABLE_NAME, "a"), Range.closed(1, 3), INTEGER);
    Attribute attributeB = new Attribute(new ColumnIdentifier(TABLE_NAME, "b"), Range.closed(2, 4), INTEGER);
    Attribute attributeC = new Attribute(new ColumnIdentifier(TABLE_NAME, "c"), Range.closed(1, 4), INTEGER);
    ImmutableList<Attribute> attributes = ImmutableList.of(attributeA, attributeB, attributeC);
    TableInfo tableInfo = new TableInfo(TABLE_NAME, attributes);
    InclusionDependency indAC = toInd(attributeA.getColumnIdentifier(), attributeC.getColumnIdentifier());
    InclusionDependency indBC = toInd(attributeB.getColumnIdentifier(), attributeC.getColumnIdentifier());
    ImmutableSet<InclusionDependency> validInds = ImmutableSet.of(indAC, indBC);

    when(dataAccessObject.isValidUIND(any(InclusionDependency.class)))
            .thenAnswer(invocation -> validInds.contains(invocation.<InclusionDependency>getArgument(0)));

    // WHEN
    when(dataAccessObject.getTableInfo(TABLE_NAME)).thenReturn(tableInfo);
    bellBrockhausen.execute();

    // THEN
    assertThat(resultReceiver.getReceivedResults()).containsExactlyInAnyOrder(toArray(validInds));
}
 
开发者ID:HPI-Information-Systems,项目名称:AdvancedDataProfilingSeminar,代码行数:23,代码来源:BellBrockhausenTest.java

示例3: testTableWithNoInds

import com.google.common.collect.Range; //导入方法依赖的package包/类
@Test
public void testTableWithNoInds(DataAccessObject dataAccessObject) throws AlgorithmExecutionException {
    // GIVEN
    Attribute attributeA = new Attribute(new ColumnIdentifier(TABLE_NAME, "a"), Range.closed(1, 3), INTEGER);
    Attribute attributeB = new Attribute(new ColumnIdentifier(TABLE_NAME, "b"), Range.closed(2, 4), INTEGER);
    Attribute attributeC = new Attribute(new ColumnIdentifier(TABLE_NAME, "c"), Range.closed(1, 4), INTEGER);
    TableInfo tableInfo = new TableInfo(TABLE_NAME, ImmutableList.of(attributeA, attributeB, attributeC));
    ImmutableSet<InclusionDependency> validInds = ImmutableSet.of();

    when(dataAccessObject.isValidUIND(any(InclusionDependency.class))).thenReturn(false);

    // WHEN
    when(dataAccessObject.getTableInfo(TABLE_NAME)).thenReturn(tableInfo);
    bellBrockhausen.execute();

    // THEN
    assertThat(resultReceiver.getReceivedResults()).containsExactlyInAnyOrder(toArray(validInds));
}
 
开发者ID:HPI-Information-Systems,项目名称:AdvancedDataProfilingSeminar,代码行数:19,代码来源:BellBrockhausenTest.java

示例4: testTableWithTransitiveInds

import com.google.common.collect.Range; //导入方法依赖的package包/类
@Test
public void testTableWithTransitiveInds(DataAccessObject dataAccessObject) throws AlgorithmExecutionException {
    // GIVEN
    Attribute attributeA = new Attribute(new ColumnIdentifier(TABLE_NAME, "a"), Range.closed(1, 3), INTEGER);
    Attribute attributeB = new Attribute(new ColumnIdentifier(TABLE_NAME, "b"), Range.closed(3, 4), INTEGER);
    Attribute attributeC = new Attribute(new ColumnIdentifier(TABLE_NAME, "c"), Range.closed(1, 3), INTEGER);
    Attribute attributeD = new Attribute(new ColumnIdentifier(TABLE_NAME, "d"), Range.closed(1, 4), INTEGER);
    ImmutableList<Attribute> attributes = ImmutableList.of(attributeA, attributeB, attributeC, attributeD);
    TableInfo tableInfo = new TableInfo(TABLE_NAME, attributes);
    InclusionDependency indAC = toInd(attributeA.getColumnIdentifier(), attributeC.getColumnIdentifier());
    InclusionDependency indAD = toInd(attributeA.getColumnIdentifier(), attributeD.getColumnIdentifier());
    InclusionDependency indCA = toInd(attributeC.getColumnIdentifier(), attributeA.getColumnIdentifier());
    InclusionDependency indCD = toInd(attributeC.getColumnIdentifier(), attributeD.getColumnIdentifier());
    InclusionDependency indBD = toInd(attributeB.getColumnIdentifier(), attributeD.getColumnIdentifier());
    ImmutableSet<InclusionDependency> validInds = ImmutableSet.of(indAC, indAD, indCA, indCD, indBD);

    when(dataAccessObject.isValidUIND(any(InclusionDependency.class)))
            .thenAnswer(invocation -> validInds.contains(invocation.<InclusionDependency>getArgument(0)));

    // WHEN
    when(dataAccessObject.getTableInfo(TABLE_NAME)).thenReturn(tableInfo);
    bellBrockhausen.execute();

    // THEN
    assertThat(resultReceiver.getReceivedResults()).containsExactlyInAnyOrder(toArray(validInds));
}
 
开发者ID:HPI-Information-Systems,项目名称:AdvancedDataProfilingSeminar,代码行数:27,代码来源:BellBrockhausenTest.java

示例5: testTableWithEqualValues

import com.google.common.collect.Range; //导入方法依赖的package包/类
@Test
public void testTableWithEqualValues(DataAccessObject dataAccessObject) throws AlgorithmExecutionException {
    // GIVEN
    Attribute attributeA = new Attribute(new ColumnIdentifier(TABLE_NAME, "a"), Range.closed(1, 3), INTEGER);
    Attribute attributeB = new Attribute(new ColumnIdentifier(TABLE_NAME, "b"), Range.closed(1, 3), INTEGER);
    Attribute attributeC = new Attribute(new ColumnIdentifier(TABLE_NAME, "c"), Range.closed(1, 3), INTEGER);
    ImmutableList<Attribute> attributes = ImmutableList.of(attributeA, attributeB, attributeC);
    TableInfo tableInfo = new TableInfo(TABLE_NAME, attributes);
    InclusionDependency indAB = toInd(attributeA.getColumnIdentifier(), attributeB.getColumnIdentifier());
    InclusionDependency indBA = toInd(attributeB.getColumnIdentifier(), attributeA.getColumnIdentifier());
    InclusionDependency indAC = toInd(attributeA.getColumnIdentifier(), attributeC.getColumnIdentifier());
    InclusionDependency indCA = toInd(attributeC.getColumnIdentifier(), attributeA.getColumnIdentifier());
    InclusionDependency indBC = toInd(attributeB.getColumnIdentifier(), attributeC.getColumnIdentifier());
    InclusionDependency indCB = toInd(attributeC.getColumnIdentifier(), attributeB.getColumnIdentifier());
    ImmutableSet<InclusionDependency> validInds = ImmutableSet.of(indAB, indBA, indAC, indCA, indBC, indCB);

    when(dataAccessObject.isValidUIND(any(InclusionDependency.class)))
            .thenAnswer(invocation -> validInds.contains(invocation.<InclusionDependency>getArgument(0)));

    // WHEN
    when(dataAccessObject.getTableInfo(TABLE_NAME)).thenReturn(tableInfo);
    bellBrockhausen.execute();

    // THEN
    assertThat(resultReceiver.getReceivedResults()).containsExactlyInAnyOrder(toArray(validInds));
}
 
开发者ID:HPI-Information-Systems,项目名称:AdvancedDataProfilingSeminar,代码行数:27,代码来源:BellBrockhausenTest.java

示例6: testTableWithMixedTypes

import com.google.common.collect.Range; //导入方法依赖的package包/类
@Test
public void testTableWithMixedTypes(DataAccessObject dataAccessObject) throws AlgorithmExecutionException {
    // GIVEN
    Attribute attributeA = new Attribute(new ColumnIdentifier(TABLE_NAME, "a"), Range.closed(1, 3), INTEGER);
    Attribute attributeB = new Attribute(new ColumnIdentifier(TABLE_NAME, "b"), Range.closed(1, 4), INTEGER);
    Attribute attributeC = new Attribute(new ColumnIdentifier(TABLE_NAME, "d"), Range.closed("b", "c"), TEXT);
    Attribute attributeD = new Attribute(new ColumnIdentifier(TABLE_NAME, "c"), Range.closed("a", "z"), TEXT);
    ImmutableList<Attribute> attributes = ImmutableList.of(attributeA, attributeB, attributeC, attributeD);
    TableInfo tableInfo = new TableInfo(TABLE_NAME, attributes);
    InclusionDependency indAB = toInd(attributeA.getColumnIdentifier(), attributeB.getColumnIdentifier());
    InclusionDependency indCD = toInd(attributeC.getColumnIdentifier(), attributeD.getColumnIdentifier());
    ImmutableSet<InclusionDependency> validInds = ImmutableSet.of(indAB, indCD);

    when(dataAccessObject.isValidUIND(any(InclusionDependency.class)))
            .thenAnswer(invocation -> validInds.contains(invocation.<InclusionDependency>getArgument(0)));

    // WHEN
    when(dataAccessObject.getTableInfo(TABLE_NAME)).thenReturn(tableInfo);
    bellBrockhausen.execute();

    // THEN
    assertThat(resultReceiver.getReceivedResults()).containsExactlyInAnyOrder(toArray(validInds));
}
 
开发者ID:HPI-Information-Systems,项目名称:AdvancedDataProfilingSeminar,代码行数:24,代码来源:BellBrockhausenTest.java

示例7: selectVersion

import com.google.common.collect.Range; //导入方法依赖的package包/类
@Nonnull
private static ABIVersion selectVersion(final ConnectClientRequest message) {
    final Range<ABIVersion> clientRange = Range.closed(message.getMinVersion(), message.getMaxVersion());
    for (ABIVersion v : SUPPORTED_ABIVERSIONS) {
        if (clientRange.contains(v)) {
            return v;
        }
    }

    throw new IllegalArgumentException(String.format(
        "No common version between backend versions %s and client versions %s", SUPPORTED_ABIVERSIONS,
        clientRange));
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:14,代码来源:Shard.java

示例8: getValueRange

import com.google.common.collect.Range; //导入方法依赖的package包/类
private Attribute getValueRange(final DatabaseConnectionGenerator connectionGenerator, final ColumnIdentifier columnIdentifier)
        throws AlgorithmExecutionException {
    String columnName = columnIdentifier.getColumnIdentifier();
    String tableName = columnIdentifier.getTableIdentifier();
    String query = format("SELECT MIN(%s) as minVal, MAX(%s) as maxVal, PG_TYPEOF(MAX(%s)) as type FROM %s",
            columnName, columnName, columnName, tableName);
    try (ResultSet resultSet = connectionGenerator.generateResultSetFromSql(query)) {
        resultSet.next();
        DataType type = DataType.fromString(resultSet.getString("type"));
        Range<Comparable> valueRange;
        switch (type) {
            case TEXT:
                valueRange = Range.closed(resultSet.getString("minVal"), resultSet.getString("maxVal"));
                break;
            case INTEGER:
                valueRange = Range.closed(resultSet.getInt("minVal"), resultSet.getInt("maxVal"));
                break;
            default:
                throw new AlgorithmExecutionException(
                        format("Invalid data type %s for column %s", type, columnIdentifier));
        }
        return new Attribute(columnIdentifier, valueRange, type);
    } catch (SQLException e) {
        throw new InputGenerationException(
                format("Error calculating value range for column %s", columnIdentifier), e);
    }
}
 
开发者ID:HPI-Information-Systems,项目名称:AdvancedDataProfilingSeminar,代码行数:28,代码来源:PostgresDataAccessObject.java

示例9: parseInternal

import com.google.common.collect.Range; //导入方法依赖的package包/类
@Override
protected Range<N> parseInternal(Node node, String text) throws FormatException, InvalidXMLException {
    final String[] parts = text.split("\\.\\.");
    switch(parts.length) {
        case 1: return Range.singleton(domainParser.parse(node, text));
        case 2: return Range.closed(domainParser.parse(node, parts[0]),
                                    domainParser.parse(node, parts[1]));
    }
    throw new FormatException();
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:11,代码来源:RangeParser.java

示例10: getPremiumMaximum

import com.google.common.collect.Range; //导入方法依赖的package包/类
public @Nullable Range<Integer> getPremiumMaximum() {
    int min = Integer.MAX_VALUE, max = Integer.MIN_VALUE;
    for(Quota quota : getQuotas()) {
        if(quota.premium()) {
            min = Math.min(min, quota.maximum());
            max = Math.max(max, quota.maximum());
        }
    }
    return min <= max ? Range.closed(min, max) : null;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:11,代码来源:QuotaConfig.java

示例11: parseKillStreak

import com.google.common.collect.Range; //导入方法依赖的package包/类
@MethodParser("kill-streak")
public KillStreakFilter parseKillStreak(Element el) throws InvalidXMLException {
    boolean repeat = XMLUtils.parseBoolean(el.getAttribute("repeat"), false);
    boolean persistent = XMLUtils.parseBoolean(el.getAttribute("persistent"), false);
    Integer count = XMLUtils.parseNumber(el.getAttribute("count"), Integer.class, (Integer) null);
    Integer min = XMLUtils.parseNumber(el.getAttribute("min"), Integer.class, (Integer) null);
    Integer max = XMLUtils.parseNumber(el.getAttribute("max"), Integer.class, (Integer) null);
    Range<Integer> range;

    if(count != null) {
        range = Range.singleton(count);
    } else if(min == null) {
        if(max == null) {
            throw new InvalidXMLException("kill-streak filter must have a count, min, or max", el);
        } else {
            range = Range.atMost(max);
        }
    } else {
        if(max == null) {
            range = Range.atLeast(min);
        } else {
            range = Range.closed(min, max);
        }
    }

    if(repeat && !range.hasUpperBound()) {
        throw new InvalidXMLException("repeating kill-streak filter must have a count or max", el);
    }

    return new KillStreakFilter(range, repeat, persistent);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:32,代码来源:FilterDefinitionParser.java

示例12: parseRandom

import com.google.common.collect.Range; //导入方法依赖的package包/类
@MethodParser("random")
public Filter parseRandom(Element el) throws InvalidXMLException {
    Node node = new Node(el);
    Range<Double> chance;
    try {
        chance = Range.closedOpen(0d, XMLUtils.parseNumber(node, Double.class));
    } catch(InvalidXMLException e) {
        chance = XMLUtils.parseNumericRange(node, Double.class);
    }

    Range<Double> valid = Range.closed(0d, 1d);
    if (valid.encloses(chance)) {
        return proto.isNoOlderThan(ProtoVersions.EVENT_QUERIES) ? new RandomFilter(chance)
                                                                : new LegacyRandomFilter(chance);
    } else {
        double lower = chance.hasLowerBound() ? chance.lowerEndpoint() : Double.NEGATIVE_INFINITY;
        double upper = chance.hasUpperBound() ? chance.upperEndpoint() : Double.POSITIVE_INFINITY;
        double invalid;
        if(!valid.contains(lower)) {
            invalid = lower;
        } else {
            invalid = upper;
        }

        throw new InvalidXMLException("chance value (" + invalid + ") is not between 0 and 1", el);
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:28,代码来源:FilterDefinitionParser.java

示例13: findCSS

import com.google.common.collect.Range; //导入方法依赖的package包/类
private static Range<Integer> findCSS(String text, int offset) {
  int start = text.indexOf("{", offset);
  int end = text.indexOf("}", start);
  if (start > end || start == -1 || end == -1) {
    return null;
  }
  start = offset + StringUtil.lastIndexOf(text.substring(offset, start), "{", "}") + 1;
  return Range.closed(start, end + 1);
}
 
开发者ID:XDean,项目名称:CSS-Editor-FX,代码行数:10,代码来源:CSSHighLight.java

示例14: getRangeFromElement

import com.google.common.collect.Range; //导入方法依赖的package包/类
private Range<Integer> getRangeFromElement(Element feedbackElement) {
    int from = Integer.parseInt(feedbackElement.getAttribute("from"));
    int to = Integer.parseInt(feedbackElement.getAttribute("to"));
    return Range.closed(from, to);
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:6,代码来源:ReportFeedbacksParser.java

示例15: vertical

import com.google.common.collect.Range; //导入方法依赖的package包/类
private Range<Integer> vertical(Rectangle rectangle) {
    return Range.closed(rectangle.getTop(), rectangle.getBottom());
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:4,代码来源:RangeCreator.java


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