@Test public void convertNameType() throws Exception { org.gbif.nameparser.api.ParsedName pn = new org.gbif.nameparser.api.ParsedName(); for (org.gbif.nameparser.api.NameType t : org.gbif.nameparser.api.NameType.values()) { pn.setType(t); assertNotNull(NameParserGbifV1.gbifNameType(pn)); } pn.setCandidatus(true); assertEquals(NameType.CANDIDATUS, NameParserGbifV1.gbifNameType(pn)); pn.setCandidatus(false); pn.setCultivarEpithet("Bella"); assertEquals(NameType.CULTIVAR, NameParserGbifV1.gbifNameType(pn)); pn.setDoubtful(true); assertEquals(NameType.DOUBTFUL, NameParserGbifV1.gbifNameType(pn)); pn.addWarning(Warnings.BLACKLISTED_EPITHET); assertEquals(NameType.BLACKLISTED, NameParserGbifV1.gbifNameType(pn)); }
@VisibleForTesting static NameType gbifNameType(org.gbif.nameparser.api.ParsedName pn) { NameType t; if (pn.isDoubtful() && pn.getWarnings().contains(Warnings.BLACKLISTED_EPITHET)) { t = NameType.BLACKLISTED; } else if (pn.isCandidatus()) { t = NameType.CANDIDATUS; } else if (pn.getCode() == NomCode.CULTIVARS || pn.getCultivarEpithet() != null) { t = NameType.CULTIVAR; } else { t = NAME_TYPE_MAP.get(pn.getType()); } if (pn.isDoubtful() && (t == NameType.SCIENTIFIC || t == NameType.CULTIVAR)) { return NameType.DOUBTFUL; } return t; }
NameParserGbifV1 implements NameParser { @VisibleForTesting static NameType gbifNameType(org.gbif.nameparser.api.ParsedName pn) { NameType t; if (pn.isDoubtful() && pn.getWarnings().contains(Warnings.BLACKLISTED_EPITHET)) { t = NameType.BLACKLISTED; } else if (pn.isCandidatus()) { t = NameType.CANDIDATUS; } else if (pn.getCode() == NomCode.CULTIVARS || pn.getCultivarEpithet() != null) { t = NameType.CULTIVAR; } else { t = NAME_TYPE_MAP.get(pn.getType()); } if (pn.isDoubtful() && (t == NameType.SCIENTIFIC || t == NameType.CULTIVAR)) { return NameType.DOUBTFUL; } return t; } }
NameParserGbifV1 implements NameParser { @VisibleForTesting static NameType gbifNameType(org.gbif.nameparser.api.ParsedName pn) { NameType t; if (pn.isDoubtful() && pn.getWarnings().contains(Warnings.BLACKLISTED_EPITHET)) { t = NameType.BLACKLISTED; } else if (pn.isCandidatus()) { t = NameType.CANDIDATUS; } else if (pn.getCode() == NomCode.CULTIVARS || pn.getCultivarEpithet() != null) { t = NameType.CULTIVAR; } else { t = NAME_TYPE_MAP.get(pn.getType()); } if (pn.isDoubtful() && (t == NameType.SCIENTIFIC || t == NameType.CULTIVAR)) { return NameType.DOUBTFUL; } return t; } NameParserGbifV1();  NameParserGbifV1(long timeout);  NameParserGbifV1(org.gbif.nameparser.api.NameParser parser); }
NameParserGbifV1 implements NameParser { @VisibleForTesting static NameType gbifNameType(org.gbif.nameparser.api.ParsedName pn) { NameType t; if (pn.isDoubtful() && pn.getWarnings().contains(Warnings.BLACKLISTED_EPITHET)) { t = NameType.BLACKLISTED; } else if (pn.isCandidatus()) { t = NameType.CANDIDATUS; } else if (pn.getCode() == NomCode.CULTIVARS || pn.getCultivarEpithet() != null) { t = NameType.CULTIVAR; } else { t = NAME_TYPE_MAP.get(pn.getType()); } if (pn.isDoubtful() && (t == NameType.SCIENTIFIC || t == NameType.CULTIVAR)) { return NameType.DOUBTFUL; } return t; } NameParserGbifV1();  NameParserGbifV1(long timeout);  NameParserGbifV1(org.gbif.nameparser.api.NameParser parser); @Override ParsedName parse(String s, @Nullable Rank rank); @Override ParsedName parse(String scientificName); @Override ParsedName parseQuietly(String scientificName, @Nullable Rank rank); @Override ParsedName parseQuietly(String scientificName); @Override // parses the name without authorship and returns the ParsedName.canonicalName() string String parseToCanonical(String scientificName, @Nullable Rank rank); @Override String parseToCanonical(String scientificName); String parseToCanonicalOrScientificName(String scientificName); String parseToCanonicalOrScientificName(String scientificName, @Nullable Rank rank); }
NameParserGbifV1 implements NameParser { @VisibleForTesting static NameType gbifNameType(org.gbif.nameparser.api.ParsedName pn) { NameType t; if (pn.isDoubtful() && pn.getWarnings().contains(Warnings.BLACKLISTED_EPITHET)) { t = NameType.BLACKLISTED; } else if (pn.isCandidatus()) { t = NameType.CANDIDATUS; } else if (pn.getCode() == NomCode.CULTIVARS || pn.getCultivarEpithet() != null) { t = NameType.CULTIVAR; } else { t = NAME_TYPE_MAP.get(pn.getType()); } if (pn.isDoubtful() && (t == NameType.SCIENTIFIC || t == NameType.CULTIVAR)) { return NameType.DOUBTFUL; } return t; } NameParserGbifV1();  NameParserGbifV1(long timeout);  NameParserGbifV1(org.gbif.nameparser.api.NameParser parser); @Override ParsedName parse(String s, @Nullable Rank rank); @Override ParsedName parse(String scientificName); @Override ParsedName parseQuietly(String scientificName, @Nullable Rank rank); @Override ParsedName parseQuietly(String scientificName); @Override // parses the name without authorship and returns the ParsedName.canonicalName() string String parseToCanonical(String scientificName, @Nullable Rank rank); @Override String parseToCanonical(String scientificName); String parseToCanonicalOrScientificName(String scientificName); String parseToCanonicalOrScientificName(String scientificName, @Nullable Rank rank);  }