/** * Register a new instance. Registration will fail if a prior entry exists * * @param instance Instance entry to be registered. * @throws AmazonServiceException If unable to write to Simple DB because of any error. */ public void registerInstance(PriamInstance instance) throws AmazonServiceException { AmazonSimpleDB simpleDBClient = getSimpleDBClient(); PutAttributesRequest putReq = new PutAttributesRequest( DOMAIN, getKey(instance), createAttributesToRegister(instance)); UpdateCondition expected = new UpdateCondition(); expected.setName(Attributes.INSTANCE_ID); expected.setExists(false); putReq.setExpected(expected); simpleDBClient.putAttributes(putReq); }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getName() == null) ? 0 : getName().hashCode()); hashCode = prime * hashCode + ((getValue() == null) ? 0 : getValue().hashCode()); hashCode = prime * hashCode + ((getExists() == null) ? 0 : getExists().hashCode()); return hashCode; }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getDomainName() == null) ? 0 : getDomainName().hashCode()); hashCode = prime * hashCode + ((getItemName() == null) ? 0 : getItemName().hashCode()); hashCode = prime * hashCode + ((getAttributes() == null) ? 0 : getAttributes().hashCode()); hashCode = prime * hashCode + ((getExpected() == null) ? 0 : getExpected().hashCode()); return hashCode; }
/** * Constructs a new UpdateCondition object. Callers should use the setter or fluent setter (with...) methods to * initialize any additional object members. * * @param name * The name of the attribute involved in the condition. * @param value * The value of an attribute. This value can only be specified when the <code>Exists</code> parameter is * equal to <code>true</code>. * @param exists * A value specifying whether or not the specified attribute must exist with the specified value in order for * the update condition to be satisfied. Specify <code>true</code> if the attribute must exist for the update * condition to be satisfied. Specify <code>false</code> if the attribute should not exist in order for the * update condition to be satisfied. */ public UpdateCondition(String name, String value, Boolean exists) { setName(name); setValue(value); setExists(exists); }
public UpdateCondition unmarshall(StaxUnmarshallerContext context) throws Exception { UpdateCondition updateCondition = new UpdateCondition(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return updateCondition; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("Name", targetDepth)) { updateCondition.setName(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("Value", targetDepth)) { updateCondition.setValue(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("Exists", targetDepth)) { updateCondition.setExists(BooleanStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return updateCondition; } } } }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof UpdateCondition == false) return false; UpdateCondition other = (UpdateCondition)obj; if (other.getName() == null ^ this.getName() == null) return false; if (other.getName() != null && other.getName().equals(this.getName()) == false) return false; if (other.getValue() == null ^ this.getValue() == null) return false; if (other.getValue() != null && other.getValue().equals(this.getValue()) == false) return false; if (other.isExists() == null ^ this.isExists() == null) return false; if (other.isExists() != null && other.isExists().equals(this.isExists()) == false) return false; return true; }
expected = new UpdateCondition(columnName, em.padOrConvertIfRequired(curVersion), true); } else { expected = new UpdateCondition().withName(columnName).withExists(false);
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof PutAttributesRequest == false) return false; PutAttributesRequest other = (PutAttributesRequest) obj; if (other.getDomainName() == null ^ this.getDomainName() == null) return false; if (other.getDomainName() != null && other.getDomainName().equals(this.getDomainName()) == false) return false; if (other.getItemName() == null ^ this.getItemName() == null) return false; if (other.getItemName() != null && other.getItemName().equals(this.getItemName()) == false) return false; if (other.getAttributes() == null ^ this.getAttributes() == null) return false; if (other.getAttributes() != null && other.getAttributes().equals(this.getAttributes()) == false) return false; if (other.getExpected() == null ^ this.getExpected() == null) return false; if (other.getExpected() != null && other.getExpected().equals(this.getExpected()) == false) return false; return true; }
/** * <p> * The name of the attribute involved in the condition. * </p> * * @param name * The name of the attribute involved in the condition. * @return Returns a reference to this object so that method calls can be chained together. */ public UpdateCondition withName(String name) { setName(name); return this; }
/** * <p> * A value specifying whether or not the specified attribute must exist with the specified value in order for the * update condition to be satisfied. Specify <code>true</code> if the attribute must exist for the update condition * to be satisfied. Specify <code>false</code> if the attribute should not exist in order for the update condition * to be satisfied. * </p> * * @param exists * A value specifying whether or not the specified attribute must exist with the specified value in order for * the update condition to be satisfied. Specify <code>true</code> if the attribute must exist for the update * condition to be satisfied. Specify <code>false</code> if the attribute should not exist in order for the * update condition to be satisfied. * @return Returns a reference to this object so that method calls can be chained together. */ public UpdateCondition withExists(Boolean exists) { setExists(exists); return this; }
/** * <p> * The value of an attribute. This value can only be specified when the <code>Exists</code> parameter is equal to * <code>true</code>. * </p> * * @param value * The value of an attribute. This value can only be specified when the <code>Exists</code> parameter is * equal to <code>true</code>. * @return Returns a reference to this object so that method calls can be chained together. */ public UpdateCondition withValue(String value) { setValue(value); return this; }
public UpdateCondition unmarshall(StaxUnmarshallerContext context) throws Exception { UpdateCondition updateCondition = new UpdateCondition(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return updateCondition; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("Name", targetDepth)) { updateCondition.setName(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("Value", targetDepth)) { updateCondition.setValue(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("Exists", targetDepth)) { updateCondition.setExists(BooleanStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return updateCondition; } } } }
/** * Constructs a new UpdateCondition object. * Callers should use the setter or fluent setter (with...) methods to * initialize any additional object members. * * @param name The name of the attribute involved in the condition. * @param value The value of an attribute. This value can only be * specified when the <code>Exists</code> parameter is equal to * <code>true</code>. * @param exists A value specifying whether or not the specified * attribute must exist with the specified value in order for the update * condition to be satisfied. Specify <code>true</code> if the attribute * must exist for the update condition to be satisfied. Specify * <code>false</code> if the attribute should not exist in order for the * update condition to be satisfied. */ public UpdateCondition(String name, String value, Boolean exists) { setName(name); setValue(value); setExists(exists); }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getName() == null) ? 0 : getName().hashCode()); hashCode = prime * hashCode + ((getValue() == null) ? 0 : getValue().hashCode()); hashCode = prime * hashCode + ((isExists() == null) ? 0 : isExists().hashCode()); return hashCode; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof DeleteAttributesRequest == false) return false; DeleteAttributesRequest other = (DeleteAttributesRequest) obj; if (other.getDomainName() == null ^ this.getDomainName() == null) return false; if (other.getDomainName() != null && other.getDomainName().equals(this.getDomainName()) == false) return false; if (other.getItemName() == null ^ this.getItemName() == null) return false; if (other.getItemName() != null && other.getItemName().equals(this.getItemName()) == false) return false; if (other.getAttributes() == null ^ this.getAttributes() == null) return false; if (other.getAttributes() != null && other.getAttributes().equals(this.getAttributes()) == false) return false; if (other.getExpected() == null ^ this.getExpected() == null) return false; if (other.getExpected() != null && other.getExpected().equals(this.getExpected()) == false) return false; return true; }
/** * <p> * The name of the attribute involved in the condition. * </p> * * @param name * The name of the attribute involved in the condition. * @return Returns a reference to this object so that method calls can be chained together. */ public UpdateCondition withName(String name) { setName(name); return this; }
/** * <p> * A value specifying whether or not the specified attribute must exist with the specified value in order for the * update condition to be satisfied. Specify <code>true</code> if the attribute must exist for the update condition * to be satisfied. Specify <code>false</code> if the attribute should not exist in order for the update condition * to be satisfied. * </p> * * @param exists * A value specifying whether or not the specified attribute must exist with the specified value in order for * the update condition to be satisfied. Specify <code>true</code> if the attribute must exist for the update * condition to be satisfied. Specify <code>false</code> if the attribute should not exist in order for the * update condition to be satisfied. * @return Returns a reference to this object so that method calls can be chained together. */ public UpdateCondition withExists(Boolean exists) { setExists(exists); return this; }
/** * <p> * The value of an attribute. This value can only be specified when the <code>Exists</code> parameter is equal to * <code>true</code>. * </p> * * @param value * The value of an attribute. This value can only be specified when the <code>Exists</code> parameter is * equal to <code>true</code>. * @return Returns a reference to this object so that method calls can be chained together. */ public UpdateCondition withValue(String value) { setValue(value); return this; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof UpdateCondition == false) return false; UpdateCondition other = (UpdateCondition) obj; if (other.getName() == null ^ this.getName() == null) return false; if (other.getName() != null && other.getName().equals(this.getName()) == false) return false; if (other.getValue() == null ^ this.getValue() == null) return false; if (other.getValue() != null && other.getValue().equals(this.getValue()) == false) return false; if (other.getExists() == null ^ this.getExists() == null) return false; if (other.getExists() != null && other.getExists().equals(this.getExists()) == false) return false; return true; }
/** * Constructs a new UpdateCondition object. Callers should use the setter or fluent setter (with...) methods to * initialize any additional object members. * * @param name * The name of the attribute involved in the condition. * @param value * The value of an attribute. This value can only be specified when the <code>Exists</code> parameter is * equal to <code>true</code>. * @param exists * A value specifying whether or not the specified attribute must exist with the specified value in order for * the update condition to be satisfied. Specify <code>true</code> if the attribute must exist for the update * condition to be satisfied. Specify <code>false</code> if the attribute should not exist in order for the * update condition to be satisfied. */ public UpdateCondition(String name, String value, Boolean exists) { setName(name); setValue(value); setExists(exists); }