Exemplo n.º 1
0
 private boolean isRolePresent(final String roleName, final List<Role> roles) {
   boolean foundRole = false;
   if (roles != null)
     for (final Role role : roles) {
       foundRole = foundRole || roleName.equals(role.getRoleName());
     }
   return foundRole;
 }
  public Role unmarshall(StaxUnmarshallerContext context) throws Exception {
    Role role = new Role();
    int originalDepth = context.getCurrentDepth();
    int targetDepth = originalDepth + 1;

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

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

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

        if (context.testExpression("Path", targetDepth)) {
          role.setPath(StringStaxUnmarshaller.getInstance().unmarshall(context));
          continue;
        }

        if (context.testExpression("RoleName", targetDepth)) {
          role.setRoleName(StringStaxUnmarshaller.getInstance().unmarshall(context));
          continue;
        }

        if (context.testExpression("RoleId", targetDepth)) {
          role.setRoleId(StringStaxUnmarshaller.getInstance().unmarshall(context));
          continue;
        }

        if (context.testExpression("Arn", targetDepth)) {
          role.setArn(StringStaxUnmarshaller.getInstance().unmarshall(context));
          continue;
        }

        if (context.testExpression("CreateDate", targetDepth)) {
          role.setCreateDate(DateStaxUnmarshaller.getInstance().unmarshall(context));
          continue;
        }

        if (context.testExpression("AssumeRolePolicyDocument", targetDepth)) {
          role.setAssumeRolePolicyDocument(
              StringStaxUnmarshaller.getInstance().unmarshall(context));
          continue;
        }
      } else if (xmlEvent.isEndElement()) {
        if (context.getCurrentDepth() < originalDepth) {
          return role;
        }
      }
    }
  }
Exemplo n.º 3
0
  @Override
  public boolean equals(Object obj) {
    if (this == obj) return true;
    if (obj == null) return false;

    if (obj instanceof Role == false) return false;
    Role other = (Role) obj;
    if (other.getPath() == null ^ this.getPath() == null) return false;
    if (other.getPath() != null && other.getPath().equals(this.getPath()) == false) return false;
    if (other.getRoleName() == null ^ this.getRoleName() == null) return false;
    if (other.getRoleName() != null && other.getRoleName().equals(this.getRoleName()) == false)
      return false;
    if (other.getRoleId() == null ^ this.getRoleId() == null) return false;
    if (other.getRoleId() != null && other.getRoleId().equals(this.getRoleId()) == false)
      return false;
    if (other.getArn() == null ^ this.getArn() == null) return false;
    if (other.getArn() != null && other.getArn().equals(this.getArn()) == false) return false;
    if (other.getCreateDate() == null ^ this.getCreateDate() == null) return false;
    if (other.getCreateDate() != null
        && other.getCreateDate().equals(this.getCreateDate()) == false) return false;
    if (other.getAssumeRolePolicyDocument() == null ^ this.getAssumeRolePolicyDocument() == null)
      return false;
    if (other.getAssumeRolePolicyDocument() != null
        && other.getAssumeRolePolicyDocument().equals(this.getAssumeRolePolicyDocument()) == false)
      return false;
    return true;
  }