class XmlHelper {

  public static Optional<Integer> readIntAttribute(XMLStreamReader reader, String attr) {
    return Optional.ofNullable(reader.getAttributeValue(null, attr)).flatMap(s -> {
      try {
        return Optional.of(Integer.valueOf(s));
      } catch (NumberFormatException e) {
        return Optional.empty();
      }
    });
  }

  private  XmlHelper();

}