Exemplo n.º 1
0
  @Override
  public boolean equals(Object obj) {
    if (this == obj) return true;
    if (obj == null) return false;

    if (obj instanceof AccountAttribute == false) return false;
    AccountAttribute other = (AccountAttribute) obj;

    if (other.getAttributeName() == null ^ this.getAttributeName() == null) return false;
    if (other.getAttributeName() != null
        && other.getAttributeName().equals(this.getAttributeName()) == false) return false;
    if (other.getAttributeValues() == null ^ this.getAttributeValues() == null) return false;
    if (other.getAttributeValues() != null
        && other.getAttributeValues().equals(this.getAttributeValues()) == false) return false;
    return true;
  }
  public AccountAttribute unmarshall(StaxUnmarshallerContext context) throws Exception {
    AccountAttribute accountAttribute = new AccountAttribute();
    int originalDepth = context.getCurrentDepth();
    int targetDepth = originalDepth + 1;

    if (context.isStartOfDocument()) targetDepth += 1;

    while (true) {
      XMLEvent xmlEvent = context.nextEvent();
      if (xmlEvent.isEndDocument()) return accountAttribute;

      if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) {

        if (context.testExpression("attributeName", targetDepth)) {
          accountAttribute.setAttributeName(
              StringStaxUnmarshaller.getInstance().unmarshall(context));
          continue;
        }

        if (context.testExpression("attributeValueSet", targetDepth)) {
          accountAttribute.withAttributeValues(new ArrayList<AccountAttributeValue>());
          continue;
        }

        if (context.testExpression("attributeValueSet/item", targetDepth)) {
          accountAttribute.withAttributeValues(
              AccountAttributeValueStaxUnmarshaller.getInstance().unmarshall(context));
          continue;
        }

      } else if (xmlEvent.isEndElement()) {
        if (context.getCurrentDepth() < originalDepth) {
          return accountAttribute;
        }
      }
    }
  }