@Override public Object unmarshall(AttributeValue value) { return new HashSet<String>(value.getSS()); } }
@Override public Set<UUID> unmarshall(AttributeValue value) { Set<UUID> result = new HashSet<UUID>(); for (String s : value.getSS()) { result.add(UUID.fromString(s)); } return result; } }
@Override public Object unmarshall(AttributeValue value) { Set<Calendar> result = new HashSet<Calendar>(); for (String s : value.getSS()) { Calendar cal = GregorianCalendar.getInstance(); cal.setTime(DateUtils.parseISO8601Date(s)); result.add(cal); } return result; } }
@Override public void typeCheck(AttributeValue value, Method setter) { if ( value.getSS() == null ) { throw new DynamoDBMappingException("Expected SS in value " + value + " when invoking " + setter); } }
@Override public Object unmarshall(AttributeValue value) { Set<Date> result = new HashSet<Date>(); for (String s : value.getSS()) { result.add(DateUtils.parseISO8601Date(s)); } return result; } }
@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; }
.withNS(entry.getValue().getNS()) .withS(entry.getValue().getS()) .withSS(entry.getValue().getSS()) .withM(entry.getValue().getM()) .withL(entry.getValue().getL())
@Override protected void onNonKeyAttribute(String attributeName, AttributeValue currentValue) { /* If it's a set attribute and the mapper is configured with APPEND_SET, * we do an "ADD" update instead of the default "PUT". */ if (getLocalSaveBehavior() == SaveBehavior.APPEND_SET) { if (currentValue.getBS() != null || currentValue.getNS() != null || currentValue.getSS() != null) { getAttributeValueUpdates().put( attributeName, new AttributeValueUpdate().withValue( currentValue).withAction("ADD")); return; } } /* Otherwise, we do the default "PUT" update. */ super.onNonKeyAttribute(attributeName, currentValue); }
/** * 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); } }
@Override public Object unmarshall(AttributeValue value) { return new HashSet<String>(value.getSS()); } }
@Override public Object unmarshall(AttributeValue value) { final Set<Calendar> result = new HashSet<Calendar>(); for (final String s : value.getSS()) { final Calendar cal = Calendar.getInstance(); cal.setTime(DateUtils.parseISO8601Date(s)); result.add(cal); } return result; } }
@Override public Object unmarshall(AttributeValue value) { final Set<Date> result = new HashSet<Date>(); for (final String s : value.getSS()) { result.add(DateUtils.parseISO8601Date(s)); } return result; } }
@Override public void typeCheck(AttributeValue value, Method setter) { if (value.getSS() == null) { throw new DynamoDBMappingException("Expected SS in value " + value + " when invoking " + setter); } }
@Test public void testDateSet() { assertEquals(Collections.singletonList("1970-01-01T00:00:00.000Z"), convert("getDateSet", Collections.singleton(new Date(0))) .getSS()); final Calendar c = Calendar.getInstance(); c.setTimeInMillis(0); assertEquals(Collections.singletonList("1970-01-01T00:00:00.000Z"), convert("getCalendarSet", Collections.singleton(c)) .getSS()); }
@Test public void testDateSet() { assertEquals(Collections.singletonList("1970-01-01T00:00:00.000Z"), convert("getDateSet", Collections.singleton(new Date(0))) .getSS()); final Calendar c = Calendar.getInstance(); c.setTimeInMillis(0); assertEquals(Collections.singletonList("1970-01-01T00:00:00.000Z"), convert("getCalendarSet", Collections.singleton(c)) .getSS()); }
@Test public void testObjectSet() { final Object o = new Object() { @Override public String toString() { return "hello"; } }; assertEquals(Collections.singletonList("hello"), convert("getObjectSet", Collections.singleton(o)).getSS()); }
@Test public void testObjectSet() { final Object o = new Object() { @Override public String toString() { return "hello"; } }; assertEquals(Collections.singletonList("hello"), convert("getObjectSet", Collections.singleton(o)).getSS()); }