當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。