@Override public boolean add(SuggestionGroup aGroup) { boolean empty = isEmpty(); if (!empty) { Validate.isTrue(documentName.equals(aGroup.getDocumentName()), "All suggestions in a group must come from the same document: expected [%s] but got [%s]", documentName, aGroup.getDocumentName()); } // Cache information that must be consistent in the group when the first item is added if (empty) { documentName = aGroup.getDocumentName(); } return groups.add(aGroup); }
private List<AnnotationSuggestion> getMatchingSuggestion(List<SuggestionGroup> aSuggestions, String aDocumentName, long aLayerId, String aFeature, int aBegin, int aEnd, String aLabel) { return aSuggestions.stream() .filter(group -> aDocumentName.equals(group.getDocumentName()) && aLayerId == group.getLayerId() && (aFeature == null || aFeature == group.getFeature()) && (aBegin == -1 || aBegin == group.getOffset().getBegin()) && (aEnd == -1 || aEnd == group.getOffset().getEnd())) .flatMap(group -> group.stream()) .filter(suggestion -> aLabel == null || aLabel.equals(suggestion.getLabel())) .collect(toList()); }
private List<AnnotationSuggestion> getMatchingSuggestion(List<SuggestionGroup> aSuggestions, String aDocumentName, long aLayerId, String aFeature, int aBegin, int aEnd, String aLabel) { return aSuggestions.stream() .filter(group -> aDocumentName.equals(group.getDocumentName()) && aLayerId == group.getLayerId() && (aFeature == null || aFeature == group.getFeature()) && (aBegin == -1 || aBegin == group.getOffset().getBegin()) && (aEnd == -1 || aEnd == group.getOffset().getEnd())) .flatMap(group -> group.stream()) .filter(suggestion -> aLabel == null || aLabel.equals(suggestion.getLabel())) .collect(toList()); }