public IamInstanceProfileSpecification unmarshall(StaxUnmarshallerContext context)
      throws Exception {
    IamInstanceProfileSpecification iamInstanceProfileSpecification =
        new IamInstanceProfileSpecification();
    int originalDepth = context.getCurrentDepth();
    int targetDepth = originalDepth + 1;

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

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

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

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

        if (context.testExpression("name", targetDepth)) {
          iamInstanceProfileSpecification.setName(
              StringStaxUnmarshaller.getInstance().unmarshall(context));
          continue;
        }
      } else if (xmlEvent.isEndElement()) {
        if (context.getCurrentDepth() < originalDepth) {
          return iamInstanceProfileSpecification;
        }
      }
    }
  }
 /**
  * The name of the instance profile.
  *
  * @param name The name of the instance profile.
  * @return Returns a reference to this object so that method calls can be chained together.
  */
 public IamInstanceProfileSpecification withName(String name) {
   setName(name);
   return this;
 }