private static Set<AttributeDefinition> sortAttributes(AttributeDefinition[] attributes) {
        Set<AttributeDefinition> sortedAttrs = new LinkedHashSet<>(attributes.length);
        List<AttributeDefinition> elementAds = null;
        for (AttributeDefinition ad : attributes) {
            if (ad.getParser().isParseAsElement()) {
                if (elementAds == null) {
                    elementAds = new ArrayList<>();
                }
                elementAds.add(ad);
            } else {
                sortedAttrs.add(ad);
            }
        }
        if (elementAds != null) {
            sortedAttrs.addAll(elementAds);
        }
        return sortedAttrs;
    }
private static Set < AttributeDefinition > sortAttributes ( AttributeDefinition [ ] attributes ) { Set < AttributeDefinition > sortedAttrs = new LinkedHashSet < > ( attributes . length ) ; List < AttributeDefinition > elementAds = null ; for ( AttributeDefinition ad : attributes ) { if ( ad . getParser ( ) . isParseAsElement ( ) ) { if ( elementAds == null ) { elementAds = new ArrayList < > ( ) ; } elementAds . add ( ad ) ; } else { sortedAttrs . add ( ad ) ; } } if ( elementAds != null ) { sortedAttrs . addAll ( elementAds ) ; } return sortedAttrs ; }
/*
Sorts attributes so that xsd:attribute ones come first