Package com.michelboudreau.alternator.enums

Examples of com.michelboudreau.alternator.enums.AttributeValueType


    // Make sure that item specifies hash key and range key (if in schema)
    KeySchemaElement hashKey = table.getKeySchema().getHashKeyElement();
    KeySchemaElement rangeKey = table.getKeySchema().getRangeKeyElement();
    AttributeValue hashItem = request.getItem().get(hashKey.getAttributeName());
    AttributeValueType hashItemType = getAttributeValueType(hashItem);
    if (hashItem == null || hashItemType != AttributeValueType.fromString(hashKey.getAttributeType())) {
      throw new InternalServerErrorException("Missing hash key (" + hashKey.getAttributeName() + ") from item: " + request.getItem());
    }
    if (rangeKey != null) {
      AttributeValue rangeItem = request.getItem().get(rangeKey.getAttributeName());
      AttributeValueType rangeItemType = getAttributeValueType(rangeItem);
      if (rangeItem == null || rangeItemType != AttributeValueType.fromString(rangeKey.getAttributeType())) {
        throw new InternalServerErrorException("Missing range key (" + rangeKey.getAttributeName() + ") from item: " + request.getItem());
      }
    }
View Full Code Here


      }
  }

    private boolean isComparableInScan(AttributeValue value, AttributeValue comp) {
        if (comp == null) return false;
        final AttributeValueType compType = getAttributeValueType(comp);
        final AttributeValueType valueType = getAttributeValueType(value);
        return (compType.equals(AttributeValueType.N) || compType.equals(AttributeValueType.S)) && compType.equals(valueType);
    }
View Full Code Here

        return (compType.equals(AttributeValueType.N) || compType.equals(AttributeValueType.S)) && compType.equals(valueType);
    }

    private int compareForScan(AttributeValue value, AttributeValue comp) {
        //Get type
        final AttributeValueType valueType = getAttributeValueType(value);
        if (valueType.equals(AttributeValueType.S)) return value.getS().compareTo(comp.getS());

        if (valueType.equals(AttributeValueType.N)) {
            try {
                return new Long(value.getN()).compareTo(new Long(comp.getN()));
            } catch (NumberFormatException e) {
                return new Double(value.getN()).compareTo(new Double(comp.getN()));
            }
View Full Code Here

        throw new IllegalArgumentException("Can only compare String and Number types, got " + valueType);
    }

    private String getAttributeValueAsString(AttributeValue value) {
        final AttributeValueType valueType = getAttributeValueType(value);
        if (valueType.equals(AttributeValueType.N)) return value.getN();
        if (valueType.equals(AttributeValueType.S)) return value.getS();
        throw new IllegalArgumentException("Can only return values for Number and String, got " + valueType);
    }
View Full Code Here

TOP

Related Classes of com.michelboudreau.alternator.enums.AttributeValueType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.