AnnotatedText implements Serializable { @SuppressWarnings("unchecked") public ListAttribute<Entity> getEntities() { return (ListAttribute<Entity>) attributes.get(AttributeKey.ENTITY.key()); } AnnotatedText(CharSequence data,
                  Map<String, BaseAttribute> attributes,
                  Map<String, List<String>> documentMetadata,
                  /*
                   * This version is only here as a workaround for https://github.com/FasterXML/jackson-databind/issues/1118
                   * It would be better if it was only mentioned in the mixins. No data arrives here, it just
                   * allows the mixin to be matched with the existence of a version item in the json.
                   */
                  String version); CharSequence getData(); Map<String, List<String>> getDocumentMetadata(); Map<String, BaseAttribute> getAttributes(); @SuppressWarnings("unchecked") ListAttribute<Token> getTokens(); @SuppressWarnings("unchecked") ListAttribute<TranslatedTokens> getTranslatedTokens(); @SuppressWarnings("unchecked") ListAttribute<TranslatedData> getTranslatedData(); @SuppressWarnings("unchecked") ListAttribute<LanguageDetection> getLanguageDetectionRegions(); LanguageDetection getWholeTextLanguageDetection(); @SuppressWarnings("unchecked") @Deprecated ListAttribute<EntityMention> getEntityMentions(); @SuppressWarnings("unchecked") ListAttribute<Entity> getEntities(); @SuppressWarnings("unchecked") MapAttribute<LanguageCode, ListAttribute<SimilarTerm>> getSimilarTerms(); @SuppressWarnings("unchecked") ListAttribute<SimilarTerm> getSimilarTerms(LanguageCode languageCode); @SuppressWarnings("unchecked") ListAttribute<RelationshipMention> getRelationshipMentions(); @SuppressWarnings("unchecked") @Deprecated ListAttribute<ResolvedEntity> getResolvedEntities(); @SuppressWarnings("unchecked") ListAttribute<ScriptRegion> getScriptRegions(); @SuppressWarnings("unchecked") ListAttribute<Sentence> getSentences(); @SuppressWarnings("unchecked") ListAttribute<LayoutRegion> getLayoutRegions(); @SuppressWarnings("unchecked") ListAttribute<BaseNounPhrase> getBaseNounPhrases(); @SuppressWarnings("unchecked") ListAttribute<CategorizerResult> getCategorizerResults(); @SuppressWarnings("unchecked") ListAttribute<CategorizerResult> getSentimentResults(); @SuppressWarnings("unchecked") ListAttribute<Dependency> getDependencies(); @SuppressWarnings("unchecked") ListAttribute<CategorizerResult> getTopicResults(); Embeddings getEmbeddings(); @SuppressWarnings("unchecked") ListAttribute<Concept> getConcepts(); @SuppressWarnings("unchecked") ListAttribute<Keyphrase> getKeyphrases(); TransliterationResults getTransliteration(); @Override String toString();  }
@Test public void testUpgradeEntityOrder() throws Exception { AnnotatedText.Builder builder = new AnnotatedText.Builder(); ListAttribute.Builder<EntityMention> emListBuilder = new ListAttribute.Builder<>(EntityMention.class); emListBuilder.add(new EntityMention.Builder(25, 30, "Thing1") .entityType("T1") .coreferenceChainId(0) .build()); emListBuilder.add(new EntityMention.Builder(20, 25, "Thing2") .entityType("T1") .coreferenceChainId(0) .build()); emListBuilder.add(new EntityMention.Builder(0, 6, "Thing3") .entityType("T3") .coreferenceChainId(1) .build()); builder.entityMentions(emListBuilder.build()); AnnotatedText text = builder.build(); List<Entity> entities = text.getEntities(); assertEquals(2, entities.size()); assertEquals(1, entities.get(0).getMentions().size()); assertEquals("T3", entities.get(0).getType()); assertEquals(6, entities.get(0).getMentions().get(0).getEndOffset()); Entity e = entities.get(1); assertEquals("T1", e.getType()); assertEquals(20, e.getMentions().get(0).getStartOffset()); assertEquals(25, e.getMentions().get(1).getStartOffset()); }