@Override public Object unmarshall(AttributeValue value) { return value.getS(); } }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getS() == null) ? 0 : getS().hashCode()); hashCode = prime * hashCode + ((getN() == null) ? 0 : getN().hashCode()); hashCode = prime * hashCode + ((getB() == null) ? 0 : getB().hashCode()); hashCode = prime * hashCode + ((getSS() == null) ? 0 : getSS().hashCode()); hashCode = prime * hashCode + ((getNS() == null) ? 0 : getNS().hashCode()); hashCode = prime * hashCode + ((getBS() == null) ? 0 : getBS().hashCode()); hashCode = prime * hashCode + ((getM() == null) ? 0 : getM().hashCode()); hashCode = prime * hashCode + ((getL() == null) ? 0 : getL().hashCode()); hashCode = prime * hashCode + ((getNULL() == null) ? 0 : getNULL().hashCode()); hashCode = prime * hashCode + ((getBOOL() == null) ? 0 : getBOOL().hashCode()); return hashCode; }
@Override public UUID unmarshall(AttributeValue value) { return UUID.fromString(value.getS()); } }
@Override public Object unmarshall(AttributeValue value) { Calendar cal = GregorianCalendar.getInstance(); cal.setTime(DateUtils.parseISO8601Date(value.getS())); return cal; } }
.withN(entry.getValue().getN()) .withNS(entry.getValue().getNS()) .withS(entry.getValue().getS()) .withSS(entry.getValue().getSS()) .withM(entry.getValue().getM())
@Override public Object unmarshall(AttributeValue value) { if (clientCache == null) { throw new IllegalStateException( "Mapper must be constructed with S3 AWS Credentials to " + "load S3Link"); } return S3Link.fromJson(clientCache, value.getS()); } }
@Override public Object unmarshall(AttributeValue value) { return DateUtils.parseISO8601Date(value.getS()); } }
@Override public void typeCheck(AttributeValue value, Method setter) { if ( value.getS() == null ) { throw new DynamoDBMappingException("Expected S in value " + value + " when invoking " + setter); } }
/** * Marshall the given parameter object. */ public void marshall(AttributeValue attributeValue, ProtocolMarshaller protocolMarshaller) { if (attributeValue == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(attributeValue.getS(), S_BINDING); protocolMarshaller.marshall(attributeValue.getN(), N_BINDING); protocolMarshaller.marshall(attributeValue.getB(), B_BINDING); protocolMarshaller.marshall(attributeValue.getSS(), SS_BINDING); protocolMarshaller.marshall(attributeValue.getNS(), NS_BINDING); protocolMarshaller.marshall(attributeValue.getBS(), BS_BINDING); protocolMarshaller.marshall(attributeValue.getM(), M_BINDING); protocolMarshaller.marshall(attributeValue.getL(), L_BINDING); protocolMarshaller.marshall(attributeValue.getNULL(), NULL_BINDING); protocolMarshaller.marshall(attributeValue.getBOOL(), BOOL_BINDING); } catch (Exception e) { throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); } }
private HashMap<String, ByteIterator> extractResult(Map<String, AttributeValue> item) { if (null == item) { return null; } HashMap<String, ByteIterator> rItems = new HashMap<>(item.size()); for (Entry<String, AttributeValue> attr : item.entrySet()) { if (LOGGER.isDebugEnabled()) { LOGGER.debug(String.format("Result- key: %s, value: %s", attr.getKey(), attr.getValue())); } rItems.put(attr.getKey(), new StringByteIterator(attr.getValue().getS())); } return rItems; }
protected Object getValue(Map<String, AttributeValue> item, String keyName, String valueType) { if ( ALLOWABLE_VALUE_STRING.getValue().equals(valueType)) { AttributeValue val = item.get(keyName); if ( val == null ) return val; else return val.getS(); } else { AttributeValue val = item.get(keyName); if ( val == null ) return val; else return val.getN(); } }
@Override @SuppressWarnings({ "rawtypes", "unchecked" }) public Object unmarshall(AttributeValue value) { // TODO: Would be nice to cache this object, but not sure if we can // do that now without a breaking change; user's unmarshallers // might not all be thread-safe. DynamoDBMarshaller unmarshaller = createUnmarshaller(unmarshallerClass); return unmarshaller.unmarshall(targetClass, value.getS()); }
@Override public void process(final DynamodbStreamRecord record) throws InvalidRecordStructureException { if (record.getEventName().equals(INSERT)) { final Map<String, AttributeValue> recordKeys = record.getDynamodb().getKeys(); if (!recordKeys.containsKey(DEPLOYMENTS_HASH_KEY)) { throw new InvalidRecordStructureException( String.format("Record keys %s do not contain deploymentId", recordKeys)); } final String deploymentId = recordKeys.get(DEPLOYMENTS_HASH_KEY).getS(); log.debug(String.format("DeploymentId %s", deploymentId)); //TODO: get and verify deployment from DDB //TODO: start deployment workflow } else { //TODO: add metrics on modify and remove? } } }
protected Object getAttributeValue(ProcessContext context, PropertyDescriptor propertyType, AttributeValue value) { if ( context.getProperty(propertyType).getValue().equals(ALLOWABLE_VALUE_STRING.getValue())) { if ( value == null ) return null; else return value.getS(); } else { if ( value == null ) return null; else return new BigDecimal(value.getN()); } }
@Override public void typeCheck(AttributeValue value, Method setter) { if (value.getS() == null) { throw new DynamoDBMappingException("Expected S in value " + value + " when invoking " + setter); } }
private static Primitive toPrimitive(final AttributeValue attributeValue) { Primitive primitive = null; if (attributeValue.getS() != null) { primitive = new Primitive(attributeValue.getS()); } else if (attributeValue.getN() != null) { primitive = new Primitive(attributeValue.getN(), true); } else if (attributeValue.getB() != null) { primitive = new Primitive(attributeValue.getB()); } return primitive; }