當前位置: 首頁>>代碼示例>>Java>>正文


Java RangeKeyCondition類代碼示例

本文整理匯總了Java中com.amazonaws.services.dynamodbv2.document.RangeKeyCondition的典型用法代碼示例。如果您正苦於以下問題:Java RangeKeyCondition類的具體用法?Java RangeKeyCondition怎麽用?Java RangeKeyCondition使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


RangeKeyCondition類屬於com.amazonaws.services.dynamodbv2.document包,在下文中一共展示了RangeKeyCondition類的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: query

import com.amazonaws.services.dynamodbv2.document.RangeKeyCondition; //導入依賴的package包/類
@Override
public Iterable<MAVLinkRecord> query(String deviceId, Date startTime, Date endTime, Integer msgId) throws IOException {
    RangeKeyCondition timeInterval;

    if (startTime == null && endTime == null) {
        timeInterval = null;
    } else if (startTime == null && endTime != null) {
        timeInterval = new RangeKeyCondition(ATTR_TIME).le(endTime.getTime());
    } else if (startTime != null && endTime == null) {
        timeInterval = new RangeKeyCondition(ATTR_TIME).ge(startTime.getTime());
    } else {
        timeInterval = new RangeKeyCondition(ATTR_TIME).between(startTime.getTime(), endTime.getTime());
    }

    QueryFilter filter = new QueryFilter(ATTR_MSG_ID).eq(msgId);

    return new MAVLinkRecordIterable(table.query(ATTR_DEVICE_ID, deviceId, timeInterval, filter).iterator());
}
 
開發者ID:envirover,項目名稱:SPLGroundControl,代碼行數:19,代碼來源:MAVLinkMessagesTable.java

示例2: addRangeKeyConditionToQuerySpec

import com.amazonaws.services.dynamodbv2.document.RangeKeyCondition; //導入依賴的package包/類
private static <T extends Item> void addRangeKeyConditionToQuerySpec(final QuerySpec querySpec,
        final CompoundAttributeQuery compoundAttributeQuery, final Class<T> itemClass) {
    final String supportingConditionStringValue = compoundAttributeQuery.getSupportingCondition().getValues().iterator()
            .next();
    final Operators comparisonOperator = compoundAttributeQuery.getSupportingCondition().getComparisonOperator();
    final Class<?> supportingAttributeType = compoundAttributeQuery.getSupportingAttributeType(itemClass);

    try {
        final Object supportingConditionValue = supportingAttributeType.getConstructor(String.class).newInstance(supportingConditionStringValue);

        final RangeKeyCondition rangeKeyCondition = RangeKeyConditionBuilder
                .build(compoundAttributeQuery.getSupportingAttributeName(), supportingConditionValue, comparisonOperator);
        querySpec.withRangeKeyCondition(rangeKeyCondition);
    } catch (final Exception e) {
        throw new PersistenceResourceFailureException(
                String.format("Could not add range key condition for query: %s on item %s.", compoundAttributeQuery,
                        itemClass.getSimpleName()),
                e);
    }
}
 
開發者ID:travel-cloud,項目名稱:Cheddar,代碼行數:21,代碼來源:QuerySpecBuilder.java

示例3: build

import com.amazonaws.services.dynamodbv2.document.RangeKeyCondition; //導入依賴的package包/類
public static RangeKeyCondition build(final String attributeName, final Object value,
        final Operators comparisonOperator) {
    Check.isNotEmptyOrNull("attributeName", attributeName);
    Check.isNotNull("conditionValue", value);

    final RangeKeyCondition rangeKeyCondition = new RangeKeyCondition(attributeName);
    switch (comparisonOperator) {
        case EQUALS:
            rangeKeyCondition.eq(value);
            break;
        case GREATER_THAN_OR_EQUALS:
            rangeKeyCondition.ge(value);
            break;
        case LESS_THAN_OR_EQUALS:
            rangeKeyCondition.le(value);
            break;
        default:
            throw new InvalidConditionOperatorException(String
                    .format("Operation %s not valid for range key condition.", comparisonOperator.toString()));
    }

    return rangeKeyCondition;
}
 
開發者ID:travel-cloud,項目名稱:Cheddar,代碼行數:24,代碼來源:RangeKeyConditionBuilder.java

示例4: shouldBuildRangeKeyCondition_withAttributeNameConditionValueAndEqualComparisonOperator

import com.amazonaws.services.dynamodbv2.document.RangeKeyCondition; //導入依賴的package包/類
@Test
public void shouldBuildRangeKeyCondition_withAttributeNameConditionValueAndEqualComparisonOperator() {
    // Given
    final String attributeName = randomString();
    final String conditionValue = randomString();
    final Operators operator = Operators.EQUALS;

    // When
    final RangeKeyCondition rangeKeyCondition = RangeKeyConditionBuilder.build(attributeName, conditionValue,
            operator);

    // Then
    assertEquals(attributeName, rangeKeyCondition.getAttrName());
    assertTrue(rangeKeyCondition.getValues().length == 1);
    assertEquals(conditionValue, rangeKeyCondition.getValues()[0]);
    assertEquals(KeyConditions.EQ, rangeKeyCondition.getKeyCondition());
}
 
開發者ID:travel-cloud,項目名稱:Cheddar,代碼行數:18,代碼來源:RangeKeyConditionBuilderTest.java

示例5: shouldBuildRangeKeyCondition_withAttributeNameConditionValueAndLessThanOrEqualToComparisonOperator

import com.amazonaws.services.dynamodbv2.document.RangeKeyCondition; //導入依賴的package包/類
@Test
public void shouldBuildRangeKeyCondition_withAttributeNameConditionValueAndLessThanOrEqualToComparisonOperator() {
    // Given
    final String attributeName = randomString();
    final String conditionValue = randomString();
    final Operators operator = Operators.LESS_THAN_OR_EQUALS;

    // When
    final RangeKeyCondition rangeKeyCondition = RangeKeyConditionBuilder.build(attributeName, conditionValue,
            operator);

    // Then
    assertEquals(attributeName, rangeKeyCondition.getAttrName());
    assertTrue(rangeKeyCondition.getValues().length == 1);
    assertEquals(conditionValue, rangeKeyCondition.getValues()[0]);
    assertEquals(KeyConditions.LE, rangeKeyCondition.getKeyCondition());
}
 
開發者ID:travel-cloud,項目名稱:Cheddar,代碼行數:18,代碼來源:RangeKeyConditionBuilderTest.java

示例6: shouldBuildRangeKeyCondition_withAttributeNameConditionValueAndGreaterThanOrEqualToComparisonOperator

import com.amazonaws.services.dynamodbv2.document.RangeKeyCondition; //導入依賴的package包/類
@Test
public void shouldBuildRangeKeyCondition_withAttributeNameConditionValueAndGreaterThanOrEqualToComparisonOperator() {
    // Given
    final String attributeName = randomString();
    final String conditionValue = randomString();
    final Operators operator = Operators.GREATER_THAN_OR_EQUALS;

    // When
    final RangeKeyCondition rangeKeyCondition = RangeKeyConditionBuilder.build(attributeName, conditionValue,
            operator);

    // Then
    assertEquals(attributeName, rangeKeyCondition.getAttrName());
    assertTrue(rangeKeyCondition.getValues().length == 1);
    assertEquals(conditionValue, rangeKeyCondition.getValues()[0]);
    assertEquals(KeyConditions.GE, rangeKeyCondition.getKeyCondition());
}
 
開發者ID:travel-cloud,項目名稱:Cheddar,代碼行數:18,代碼來源:RangeKeyConditionBuilderTest.java

示例7: lt

import com.amazonaws.services.dynamodbv2.document.RangeKeyCondition; //導入依賴的package包/類
@Override
public <V> QueryItemsBuilder<T> lt(V value) {
    if ( "".equals(value) ) throw new UnsupportedOperationException("Attempt to compare with empty string");
    _spec.withRangeKeyCondition(new RangeKeyCondition(_rkName)
                                .lt(value));
    return this;
}
 
開發者ID:Distelli,項目名稱:java-persistence,代碼行數:8,代碼來源:QueryItemsBuilderImpl.java

示例8: le

import com.amazonaws.services.dynamodbv2.document.RangeKeyCondition; //導入依賴的package包/類
@Override
public <V> QueryItemsBuilder<T> le(V value) {
    if ( "".equals(value) ) throw new UnsupportedOperationException("Attempt to compare with empty string");
    _spec.withRangeKeyCondition(new RangeKeyCondition(_rkName)
                                .le(value));
    return this;
}
 
開發者ID:Distelli,項目名稱:java-persistence,代碼行數:8,代碼來源:QueryItemsBuilderImpl.java

示例9: gt

import com.amazonaws.services.dynamodbv2.document.RangeKeyCondition; //導入依賴的package包/類
@Override
public <V> QueryItemsBuilder<T> gt(V value) {
    if ( "".equals(value) ) throw new UnsupportedOperationException("Attempt to compare with empty string");
    _spec.withRangeKeyCondition(new RangeKeyCondition(_rkName)
                                .gt(value));
    return this;
}
 
開發者ID:Distelli,項目名稱:java-persistence,代碼行數:8,代碼來源:QueryItemsBuilderImpl.java

示例10: ge

import com.amazonaws.services.dynamodbv2.document.RangeKeyCondition; //導入依賴的package包/類
@Override
public <V> QueryItemsBuilder<T> ge(V value) {
    if ( "".equals(value) ) throw new UnsupportedOperationException("Attempt to compare with empty string");
    _spec.withRangeKeyCondition(new RangeKeyCondition(_rkName)
                                .ge(value));
    return this;
}
 
開發者ID:Distelli,項目名稱:java-persistence,代碼行數:8,代碼來源:QueryItemsBuilderImpl.java

示例11: between

import com.amazonaws.services.dynamodbv2.document.RangeKeyCondition; //導入依賴的package包/類
@Override
public <V> QueryItemsBuilder<T> between(V value1, V value2) {
    if ( "".equals(value1) ) throw new UnsupportedOperationException("Attempt to compare with empty string");
    if ( "".equals(value2) ) throw new UnsupportedOperationException("Attempt to compare with empty string");
    _spec.withRangeKeyCondition(new RangeKeyCondition(_rkName)
                                .between(value1, value2));
    return this;
}
 
開發者ID:Distelli,項目名稱:java-persistence,代碼行數:9,代碼來源:QueryItemsBuilderImpl.java

示例12: beginsWith

import com.amazonaws.services.dynamodbv2.document.RangeKeyCondition; //導入依賴的package包/類
@Override
public QueryItemsBuilder<T> beginsWith(String value) {
    if ( "".equals(value) ) throw new UnsupportedOperationException("Attempt to compare with empty string");
    _spec.withRangeKeyCondition(new RangeKeyCondition(_rkName)
                                .beginsWith(value));
    return this;
}
 
開發者ID:Distelli,項目名稱:java-persistence,代碼行數:8,代碼來源:QueryItemsBuilderImpl.java

示例13: shouldBuild_withCompoundAttributeQuery

import com.amazonaws.services.dynamodbv2.document.RangeKeyCondition; //導入依賴的package包/類
@Test
public void shouldBuild_withCompoundAttributeQuery() {
    // Given
    final String attributeName = randomString(10);
    final String supportingAttributeName = randomString(10);
    final Condition condition = randomCondition(1);
    final Condition supportingCondition = randomCondition(1);
    final CompoundAttributeQuery compoundAttributeQuery = mock(CompoundAttributeQuery.class);
    final RangeKeyCondition mockRangeKeyCondition = mock(RangeKeyCondition.class);
    final String expectedValue = condition.getValues().iterator().next();
    final String expectedSupportingValue = supportingCondition.getValues().iterator().next();
    final Operators expectedSupportingComparisonOperator = supportingCondition.getComparisonOperator();

    when(compoundAttributeQuery.getAttributeName()).thenReturn(attributeName);
    when(compoundAttributeQuery.getCondition()).thenReturn(condition);
    when(compoundAttributeQuery.getSupportingCondition()).thenReturn(supportingCondition);
    Mockito.<Class<?>> when(compoundAttributeQuery.getSupportingAttributeType(any())).thenReturn(String.class);
    when(compoundAttributeQuery.getSupportingAttributeName()).thenReturn(supportingAttributeName);
    when(RangeKeyConditionBuilder.build(supportingAttributeName, expectedSupportingValue,
            expectedSupportingComparisonOperator)).thenReturn(mockRangeKeyCondition);

    // When
    final QuerySpec querySpec = QuerySpecBuilder.build(compoundAttributeQuery,
            StubWithGlobalSecondaryIndexItem.class);

    // Then
    assertEquals(attributeName, querySpec.getHashKey().getName());
    assertEquals(expectedValue, querySpec.getHashKey().getValue());
    assertEquals(mockRangeKeyCondition, querySpec.getRangeKeyCondition());
}
 
開發者ID:travel-cloud,項目名稱:Cheddar,代碼行數:31,代碼來源:QuerySpecBuilderTest.java

示例14: eq

import com.amazonaws.services.dynamodbv2.document.RangeKeyCondition; //導入依賴的package包/類
@Override
public <V> QueryItemsBuilder<T> eq(V value) {
    _spec.withRangeKeyCondition(new RangeKeyCondition(_rkName)
                                .eq(toDDBEmptyString(value)));
    return this;
}
 
開發者ID:Distelli,項目名稱:java-persistence,代碼行數:7,代碼來源:QueryItemsBuilderImpl.java


注:本文中的com.amazonaws.services.dynamodbv2.document.RangeKeyCondition類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。