code: private int getMaxLength(List < XmlSchemaFacet > facets) {
          for (XmlSchemaFacet facet : facets) {
              if (facet instanceof XmlSchemaMaxLengthFacet) {
                  return Integer
                          .parseInt((String) ((XmlSchemaMaxLengthFacet) facet)
                                  .getValue());
              }
          }
          return -1;
      }
docs: Retrieve the maxLength facet if it exists.
  
  @param facets the list of facets
  @return the maxlength value or -1 if there are no maxLength facets