/** * Return the Tag that matches the given class */ @SuppressWarnings("unchecked") public <T extends Tag> T getTag(Class<T> tagClass) { List<T> matches = getTags(tagClass); T matchingTag = null; if (matches.size() > 0) { matchingTag = matches.get(0); } // if (matches.size() >= 2) { // throw new IllegalStateException("Multiple identical tags found (" + matches + ")"); // } // else if (matches.size() == 1) { // matchingTag = matches.get(0); // } return matchingTag; }
boolean optional = pattern.isOptional(); if (pattern instanceof TagPattern) { boolean match = (tokenIndex < tokens.size() && tokens.get(tokenIndex).getTags(((TagPattern) pattern).getTagClass()).size() > 0);