@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getAttributes() == null) ? 0 : getAttributes().hashCode()); return hashCode; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof GetAttributesResult == false) return false; GetAttributesResult other = (GetAttributesResult) obj; if (other.getAttributes() == null ^ this.getAttributes() == null) return false; if (other.getAttributes() != null && other.getAttributes().equals(this.getAttributes()) == false) return false; return true; }
/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getAttributes() != null) sb.append("Attributes: ").append(getAttributes()); sb.append("}"); return sb.toString(); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof GetAttributesResult == false) return false; GetAttributesResult other = (GetAttributesResult)obj; if (other.getAttributes() == null ^ this.getAttributes() == null) return false; if (other.getAttributes() != null && other.getAttributes().equals(this.getAttributes()) == false) return false; return true; }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getAttributes() == null) ? 0 : getAttributes().hashCode()); return hashCode; }
/** * Returns a string representation of this object; useful for testing and * debugging. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getAttributes() != null) sb.append("Attributes: " + getAttributes() ); sb.append("}"); return sb.toString(); }
/** * The list of attributes returned by the operation. * <p> * Returns a reference to this object so that method calls can be chained together. * * @param attributes The list of attributes returned by the operation. * * @return A reference to this updated object so that method calls can be chained * together. */ public GetAttributesResult withAttributes(Attribute... attributes) { if (getAttributes() == null) setAttributes(new java.util.ArrayList<Attribute>(attributes.length)); for (Attribute value : attributes) { getAttributes().add(value); } return this; }
public GetAttributesResult unmarshall(StaxUnmarshallerContext context) throws Exception { GetAttributesResult getAttributesResult = new GetAttributesResult(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 2; while (true) { int xmlEvent = context.nextEvent(); if (xmlEvent == XmlPullParser.END_DOCUMENT) return getAttributesResult; if (xmlEvent == XmlPullParser.START_TAG) { if (context.testExpression("Attribute", targetDepth)) { getAttributesResult.getAttributes().add(AttributeStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent == XmlPullParser.END_TAG) { if (context.getCurrentDepth() < originalDepth) { return getAttributesResult; } } } }
assertNotNull(getAttributesResult.getAttributes()); assertTrue(getAttributesResult.getAttributes().size() == 2); for (Object attributesObject : getAttributesResult.getAttributes()) { Attribute attributes = (Attribute)attributesObject; assertNotNull(attributes.getName());
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof GetAttributesResult == false) return false; GetAttributesResult other = (GetAttributesResult) obj; if (other.getAttributes() == null ^ this.getAttributes() == null) return false; if (other.getAttributes() != null && other.getAttributes().equals(this.getAttributes()) == false) return false; return true; }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getAttributes() == null) ? 0 : getAttributes().hashCode()); return hashCode; }
/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getAttributes() != null) sb.append("Attributes: ").append(getAttributes()); sb.append("}"); return sb.toString(); }
/** * Gets the Item based on the item name field which is the same as id in SimpleJPA. * If the item doesn't exist then null is returned. * * @param db * @param domainName * @param itemName * @param consistentRead true to read consistently, false to use eventual consistency * @return * @throws AmazonClientException */ public static Item findItemById(AmazonSimpleDB db, String domainName, String itemName, boolean consistentRead) throws AmazonClientException { GetAttributesResult results = db.getAttributes(new GetAttributesRequest() .withConsistentRead(consistentRead) .withDomainName(domainName) .withItemName(itemName)); if(results.getAttributes().size() == 0) { return null; } Item item = new Item(itemName, results.getAttributes()); return item; } }
private void putAndDelete(String domainName, String oldAttributeName, String newAttributeName, List<Item> items) throws AmazonClientException { AmazonSimpleDB db = factory.getSimpleDb(); for (Item item : items) { GetAttributesResult getOldResults = db.getAttributes(new GetAttributesRequest().withDomainName(domainName).withConsistentRead(true).withItemName( item.getName()).withAttributeNames(oldAttributeName)); List<Attribute> oldAtts = getOldResults.getAttributes(); if (oldAtts.size() > 0) { Attribute oldAtt = oldAtts.get(0); List<ReplaceableAttribute> atts = new ArrayList<ReplaceableAttribute>(); atts.add(new ReplaceableAttribute(newAttributeName, oldAtt.getValue(), true)); db.putAttributes(new PutAttributesRequest().withDomainName(domainName).withItemName(item.getName()).withAttributes(atts)); db.deleteAttributes(new DeleteAttributesRequest().withDomainName(domainName).withItemName(item.getName()).withAttributes(oldAtts)); } } }