2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
9 package eu
.etaxonomy
.cdm
.strategy
.cache
.name
;
11 import java
.util
.ArrayList
;
12 import java
.util
.List
;
13 import java
.util
.UUID
;
15 import org
.apache
.log4j
.Logger
;
17 import eu
.etaxonomy
.cdm
.common
.CdmUtils
;
18 import eu
.etaxonomy
.cdm
.common
.UTF8
;
19 import eu
.etaxonomy
.cdm
.model
.agent
.INomenclaturalAuthor
;
20 import eu
.etaxonomy
.cdm
.model
.name
.HybridRelationship
;
21 import eu
.etaxonomy
.cdm
.model
.name
.INonViralName
;
22 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
23 import eu
.etaxonomy
.cdm
.model
.name
.TaxonName
;
24 import eu
.etaxonomy
.cdm
.strategy
.cache
.TagEnum
;
25 import eu
.etaxonomy
.cdm
.strategy
.cache
.TaggedText
;
26 import eu
.etaxonomy
.cdm
.strategy
.exceptions
.UnknownCdmTypeException
;
27 import eu
.etaxonomy
.cdm
.strategy
.parser
.NonViralNameParserImplRegExBase
;
31 * This class is a default implementation for the INonViralNameCacheStrategy<T extends NonViralName>
33 * The method implements a cache strategy for botanical names so no method has to be overwritten by
34 * a subclass for botanic names.
35 * Where differing from this default botanic name strategy other subclasses should overwrite the
36 * existing methods, e.g. a CacheStrategy for zoological names should overwrite getAuthorAndExAuthor
39 public class TaxonNameDefaultCacheStrategy
40 extends NameCacheStrategyBase
41 implements INonViralNameCacheStrategy
{
43 private static final Logger logger
= Logger
.getLogger(TaxonNameDefaultCacheStrategy
.class);
44 private static final long serialVersionUID
= -6577757501563212669L;
46 final static UUID uuid
= UUID
.fromString("1cdda0d1-d5bc-480f-bf08-40a510a2f223");
48 protected String nameAuthorSeperator
= " ";
49 protected String basionymStart
= "(";
50 protected String basionymEnd
= ")";
51 protected String exAuthorSeperator
= " ex ";
52 private static String NOTHO
= "notho";
53 protected CharSequence basionymAuthorCombinationAuthorSeperator
= " ";
55 protected String zooAuthorYearSeperator
= ", ";
58 public UUID
getUuid(){
62 // ************************** FACTORY ******************************/
64 public static TaxonNameDefaultCacheStrategy
NewInstance(){
65 return new TaxonNameDefaultCacheStrategy();
69 // ************ CONSTRUCTOR *******************/
71 protected TaxonNameDefaultCacheStrategy(){
75 /* **************** GETTER / SETTER **************************************/
78 * String that separates the NameCache part from the AuthorCache part
81 public String
getNameAuthorSeperator() {
82 return nameAuthorSeperator
;
84 public void setNameAuthorSeperator(String nameAuthorSeperator
) {
85 this.nameAuthorSeperator
= nameAuthorSeperator
;
90 * String the basionym author part starts with e.g. '('.
91 * This should correspond with the {@link TaxonNameDefaultCacheStrategy#getBasionymEnd() basionymEnd} attribute
94 public String
getBasionymStart() {
97 public void setBasionymStart(String basionymStart
) {
98 this.basionymStart
= basionymStart
;
102 * String the basionym author part ends with e.g. ')'.
103 * This should correspond with the {@link TaxonNameDefaultCacheStrategy#getBasionymStart() basionymStart} attribute
106 public String
getBasionymEnd() {
109 public void setBasionymEnd(String basionymEnd
) {
110 this.basionymEnd
= basionymEnd
;
115 * String to separate ex author from author.
118 public String
getExAuthorSeperator() {
119 return exAuthorSeperator
;
121 public void setExAuthorSeperator(String exAuthorSeperator
) {
122 this.exAuthorSeperator
= exAuthorSeperator
;
127 * String that separates the basionym/original_combination author part from the combination author part
130 public CharSequence
getBasionymAuthorCombinationAuthorSeperator() {
131 return basionymAuthorCombinationAuthorSeperator
;
135 public void setBasionymAuthorCombinationAuthorSeperator( CharSequence basionymAuthorCombinationAuthorSeperator
) {
136 this.basionymAuthorCombinationAuthorSeperator
= basionymAuthorCombinationAuthorSeperator
;
139 public String
getZooAuthorYearSeperator() {
140 return zooAuthorYearSeperator
;
142 public void setZooAuthorYearSeperator(String authorYearSeperator
) {
143 this.zooAuthorYearSeperator
= authorYearSeperator
;
146 // ******************* Authorship ******************************/
149 public String
getAuthorshipCache(TaxonName taxonName
) {
150 if (taxonName
== null){
152 }else if (taxonName
.getNameType().isViral()){
154 }else if(taxonName
.isProtectedAuthorshipCache() == true) {
156 return taxonName
.getAuthorshipCache();
158 return getNonCacheAuthorshipCache(taxonName
);
163 * Returns the authorshipcache string for the atomized authorship fields. Does not use the authorship field.
164 * @throws NullPointerException if nonViralName is null.
168 protected String
getNonCacheAuthorshipCache(TaxonName nonViralName
){
169 if (nonViralName
.getNameType().isZoological()){
170 return this.getZoologicalNonCacheAuthorshipCache(nonViralName
);
173 INomenclaturalAuthor combinationAuthor
= nonViralName
.getCombinationAuthorship();
174 INomenclaturalAuthor exCombinationAuthor
= nonViralName
.getExCombinationAuthorship();
175 INomenclaturalAuthor basionymAuthor
= nonViralName
.getBasionymAuthorship();
176 INomenclaturalAuthor exBasionymAuthor
= nonViralName
.getExBasionymAuthorship();
177 String basionymPart
= "";
178 String authorPart
= "";
180 if (basionymAuthor
!= null || exBasionymAuthor
!= null){
181 basionymPart
= basionymStart
+ getAuthorAndExAuthor(basionymAuthor
, exBasionymAuthor
) + basionymEnd
;
183 if (combinationAuthor
!= null || exCombinationAuthor
!= null){
184 authorPart
= getAuthorAndExAuthor(combinationAuthor
, exCombinationAuthor
);
186 result
= CdmUtils
.concat(basionymAuthorCombinationAuthorSeperator
, basionymPart
, authorPart
);
187 // if ("".equals(result)){
194 protected String
getZoologicalNonCacheAuthorshipCache(TaxonName nonViralName
) {
195 if (nonViralName
== null){
199 INomenclaturalAuthor combinationAuthor
= nonViralName
.getCombinationAuthorship();
200 INomenclaturalAuthor exCombinationAuthor
= nonViralName
.getExCombinationAuthorship();
201 INomenclaturalAuthor basionymAuthor
= nonViralName
.getBasionymAuthorship();
202 INomenclaturalAuthor exBasionymAuthor
= nonViralName
.getExBasionymAuthorship();
203 Integer publicationYear
= nonViralName
.getPublicationYear();
204 Integer originalPublicationYear
= nonViralName
.getOriginalPublicationYear();
206 String basionymPart
= "";
207 String authorPart
= "";
209 if (basionymAuthor
!= null || exBasionymAuthor
!= null || originalPublicationYear
!= null ){
210 String authorAndEx
= getAuthorAndExAuthor(basionymAuthor
, exBasionymAuthor
);
211 String originalPublicationYearString
= originalPublicationYear
== null ?
null : String
.valueOf(originalPublicationYear
);
212 String authorAndExAndYear
= CdmUtils
.concat(zooAuthorYearSeperator
, authorAndEx
, originalPublicationYearString
);
213 basionymPart
= basionymStart
+ authorAndExAndYear
+ basionymEnd
;
215 if (combinationAuthor
!= null || exCombinationAuthor
!= null){
216 String authorAndEx
= getAuthorAndExAuthor(combinationAuthor
, exCombinationAuthor
);
217 String publicationYearString
= publicationYear
== null ?
null : String
.valueOf(publicationYear
);
218 authorPart
= CdmUtils
.concat(zooAuthorYearSeperator
, authorAndEx
, publicationYearString
);
220 result
= CdmUtils
.concat(basionymAuthorCombinationAuthorSeperator
, basionymPart
, authorPart
);
229 * Returns the AuthorCache part for a combination of an author and an ex author. This applies on
230 * combination authors as well as on basionym/orginal combination authors.
231 * The correct order is exAuthor ex author though some botanist do not know about and do it the
232 * other way round. (see 46.4-46.6 ICBN (Vienna Code, 2006))
234 * @param author the author
235 * @param exAuthor the ex-author
238 protected String
getAuthorAndExAuthor(INomenclaturalAuthor author
, INomenclaturalAuthor exAuthor
){
239 String authorString
= "";
240 String exAuthorString
= "";
242 authorString
= CdmUtils
.Nz(author
.getNomenclaturalTitle());
244 if (exAuthor
!= null){
245 exAuthorString
= CdmUtils
.Nz(exAuthor
.getNomenclaturalTitle());
246 exAuthorString
+= exAuthorSeperator
;
248 String result
= exAuthorString
+ authorString
;
255 * Checks if the given name should include the author in it's cached version.<BR>
256 * This is usually the case but not for <i>species aggregates</i>.
257 * @param nonViralName
260 protected boolean nameIncludesAuthorship(INonViralName nonViralName
){
261 Rank rank
= nonViralName
.getRank();
262 if (rank
!= null && rank
.isSpeciesAggregate()){
269 // ************* TAGGED NAME ***************************************/
272 protected List
<TaggedText
> doGetTaggedTitle(TaxonName taxonName
) {
273 List
<TaggedText
> tags
= new ArrayList
<>();
274 if (taxonName
.getNameType().isViral()){
275 String acronym
= taxonName
.getAcronym();
276 tags
.add(new TaggedText(TagEnum
.name
, acronym
));
278 }else if (taxonName
.isHybridFormula()){
280 String hybridSeparator
= NonViralNameParserImplRegExBase
.hybridSign
;
281 boolean isFirst
= true;
282 List
<HybridRelationship
> rels
= taxonName
.getOrderedChildRelationships();
283 for (HybridRelationship rel
: rels
){
285 tags
.add(new TaggedText(TagEnum
.hybridSign
, hybridSeparator
));
288 tags
.addAll(getTaggedTitle(rel
.getParentName()));
291 }else if (taxonName
.isAutonym()){
293 tags
.addAll(handleTaggedAutonym(taxonName
));
295 List
<TaggedText
> nameTags
= getTaggedName(taxonName
);
296 tags
.addAll(nameTags
);
297 String authorCache
= getAuthorshipCache(taxonName
);
298 if (isNotBlank(authorCache
)){
299 tags
.add(new TaggedText(TagEnum
.authors
, authorCache
));
306 * Returns the tag list of the name part (without author and reference).
311 public List
<TaggedText
> getTaggedName(TaxonName taxonName
) {
312 if (taxonName
== null){
314 }else if (taxonName
.isViral()){
317 List
<TaggedText
> tags
= new ArrayList
<>();
318 Rank rank
= taxonName
.getRank();
320 if (taxonName
.isProtectedNameCache()){
321 tags
.add(new TaggedText(TagEnum
.name
, taxonName
.getNameCache()));
322 }else if (taxonName
.isHybridFormula()){
324 String hybridSeparator
= NonViralNameParserImplRegExBase
.hybridSign
;
325 boolean isFirst
= true;
326 List
<HybridRelationship
> rels
= taxonName
.getOrderedChildRelationships();
327 for (HybridRelationship rel
: rels
){
329 tags
.add(new TaggedText(TagEnum
.hybridSign
, hybridSeparator
));
332 tags
.addAll(getTaggedName(rel
.getParentName()));
336 }else if (rank
== null){
337 tags
= getRanklessTaggedNameCache(taxonName
);
338 // }else if (nonViralName.isInfragenericUnranked()){
339 // result = getUnrankedInfragenericNameCache(nonViralName);
340 }else if (rank
.isInfraSpecific()){
341 tags
= getInfraSpeciesTaggedNameCache(taxonName
);
342 }else if (rank
.isSpecies() || isAggregateWithAuthorship(taxonName
, rank
) ){ //exception see #4288
343 tags
= getSpeciesTaggedNameCache(taxonName
);
344 }else if (rank
.isInfraGeneric()){
345 tags
= getInfraGenusTaggedNameCache(taxonName
);
346 }else if (rank
.isGenus()){
347 tags
= getGenusOrUninomialTaggedNameCache(taxonName
);
348 }else if (rank
.isSupraGeneric()){
349 tags
= getGenusOrUninomialTaggedNameCache(taxonName
);
351 tags
= getRanklessTaggedNameCache(taxonName
);
352 logger
.warn("Rank does not belong to a rank class: " + rank
.getTitleCache() + ". Used rankless nameCache for name " + taxonName
.getUuid());
354 //TODO handle appended phrase here instead of different places, check first if this is true for all
360 //***************************** PRIVATES ***************************************/
362 private boolean isAggregateWithAuthorship(TaxonName nonViralName
, Rank rank
) {
366 return rank
.isSpeciesAggregate() && ( isNotBlank(nonViralName
.getAuthorshipCache()) || nonViralName
.getNomenclaturalReference() != null );
371 * Returns the tag list for an autonym taxon.
373 * @see NonViralName#isAutonym()
374 * @see BotanicalName#isAutonym()
375 * @param nonViralName
378 private List
<TaggedText
> handleTaggedAutonym(TaxonName nonViralName
) {
379 List
<TaggedText
> tags
= null;
380 if (nonViralName
.isInfraSpecific()){
382 tags
= getSpeciesTaggedNameCache(nonViralName
);
385 String authorCache
= getAuthorshipCache(nonViralName
);
386 if (isNotBlank(authorCache
)){
387 tags
.add(new TaggedText(TagEnum
.authors
, authorCache
));
390 //infra species marker
391 if (nonViralName
.getRank() == null || !nonViralName
.getRank().isInfraSpecific()){
392 //TODO handle exception
393 logger
.warn("Rank for autonym does not exist or is not lower than species !!");
395 String infraSpeciesMarker
= nonViralName
.getRank().getAbbreviation();
396 if (nonViralName
.isTrinomHybrid()){
397 infraSpeciesMarker
= CdmUtils
.concat("", NOTHO
, infraSpeciesMarker
);
399 if (isNotBlank(infraSpeciesMarker
)){
400 tags
.add(new TaggedText(TagEnum
.rank
, infraSpeciesMarker
));
405 String infraSpeciesPart
= CdmUtils
.Nz(nonViralName
.getInfraSpecificEpithet()).trim();
406 if (isNotBlank(infraSpeciesPart
)){
407 tags
.add(new TaggedText(TagEnum
.name
, infraSpeciesPart
));
410 } else if (nonViralName
.isInfraGeneric()){
412 tags
=getGenusOrUninomialTaggedNameCache(nonViralName
);
415 String authorCache
= getAuthorshipCache(nonViralName
);
416 if (isNotBlank(authorCache
)){
417 tags
.add(new TaggedText(TagEnum
.authors
, authorCache
));
420 //infra species marker
421 if (nonViralName
.getRank() == null || !nonViralName
.getRank().isInfraGeneric()){
422 //TODO handle exception
423 logger
.warn("Rank for autonym does not exist or is not lower than species !!");
425 Rank rank
= nonViralName
.getRank();
426 String infraGenericMarker
= rank
.getAbbreviation();
427 if (rank
.equals(Rank
.SECTION_BOTANY()) || rank
.equals(Rank
.SUBSECTION_BOTANY())){
428 infraGenericMarker
= infraGenericMarker
.replace("(bot.)", "");
430 if (isNotBlank(infraGenericMarker
)){
431 tags
.add(new TaggedText(TagEnum
.rank
, infraGenericMarker
));
436 String infraGenericPart
= CdmUtils
.Nz(nonViralName
.getInfraGenericEpithet()).trim();
437 if (isNotBlank(infraGenericPart
)){
438 tags
.add(new TaggedText(TagEnum
.name
, infraGenericPart
));
448 * Returns the tag list for rankless taxa.
449 * @param nonViralName
452 protected List
<TaggedText
> getRanklessTaggedNameCache(INonViralName nonViralName
){
453 List
<TaggedText
> tags
= getUninomialTaggedPart(nonViralName
);
454 String speciesEpi
= CdmUtils
.Nz(nonViralName
.getSpecificEpithet()).trim();
455 if (isNotBlank(speciesEpi
)){
456 tags
.add(new TaggedText(TagEnum
.name
, speciesEpi
));
459 String infraSpeciesEpi
= CdmUtils
.Nz(nonViralName
.getInfraSpecificEpithet());
460 if (isNotBlank(infraSpeciesEpi
)){
461 tags
.add(new TaggedText(TagEnum
.name
, infraSpeciesEpi
));
464 //result += " (rankless)";
465 addAppendedTaggedPhrase(tags
, nonViralName
);
470 * Returns the tag list for the first epithet (including a hybrid sign if required).
471 * @param nonViralName
474 private List
<TaggedText
> getUninomialTaggedPart(INonViralName nonViralName
) {
475 List
<TaggedText
> tags
= new ArrayList
<>();
477 if (nonViralName
.isMonomHybrid()){
478 addHybridPrefix(tags
);
481 String uninomial
= CdmUtils
.Nz(nonViralName
.getGenusOrUninomial()).trim();
482 if (isNotBlank(uninomial
)){
483 tags
.add(new TaggedText(TagEnum
.name
, uninomial
));
490 * Returns the tag list for an genus or higher taxon.
492 * @param nonViralName
495 protected List
<TaggedText
> getGenusOrUninomialTaggedNameCache(INonViralName nonViralName
){
496 List
<TaggedText
> tags
= getUninomialTaggedPart(nonViralName
);
497 addAppendedTaggedPhrase(tags
, nonViralName
);
502 * Returns the tag list for an infrageneric taxon (including species aggregates).
504 * @see #getSpeciesAggregateTaggedCache(NonViralName)
505 * @param nonViralName
508 protected List
<TaggedText
> getInfraGenusTaggedNameCache(INonViralName nonViralName
){
509 Rank rank
= nonViralName
.getRank();
510 if (rank
!= null && rank
.isSpeciesAggregate() && isBlank(nonViralName
.getAuthorshipCache())){
511 return getSpeciesAggregateTaggedCache(nonViralName
);
515 List
<TaggedText
> tags
= getUninomialTaggedPart(nonViralName
);
518 String infraGenericMarker
;
521 infraGenericMarker
= rank
.getInfraGenericMarker();
522 if (rank
.equals(Rank
.SECTION_BOTANY()) || rank
.equals(Rank
.SUBSECTION_BOTANY())){
523 infraGenericMarker
= infraGenericMarker
.replace("(bot.)", "");
525 } catch (UnknownCdmTypeException e
) {
526 infraGenericMarker
= "'unhandled infrageneric rank'";
529 infraGenericMarker
= "'undefined infrageneric rank'";
531 String infraGenEpi
= CdmUtils
.Nz(nonViralName
.getInfraGenericEpithet()).trim();
532 if (nonViralName
.isBinomHybrid()){
533 infraGenericMarker
= CdmUtils
.concat("", NOTHO
, infraGenericMarker
);
536 addInfraGenericPart(nonViralName
, tags
, infraGenericMarker
, infraGenEpi
);
538 addAppendedTaggedPhrase(tags
, nonViralName
);
544 * Default implementation for the infrageneric part of a name.
545 * This is usually the infrageneric marker and the infrageneric epitheton. But may be
546 * implemented differently e.g. for zoological names the infrageneric epitheton
547 * may be surrounded by brackets and the marker left out.
548 * @param nonViralName
550 * @param infraGenericMarker
552 protected void addInfraGenericPart(
553 @SuppressWarnings("unused") INonViralName name
,
554 List
<TaggedText
> tags
,
555 String infraGenericMarker
,
556 String infraGenEpi
) {
558 tags
.add(new TaggedText(TagEnum
.rank
, infraGenericMarker
));
561 if (isNotBlank(infraGenEpi
)){
562 tags
.add(new TaggedText(TagEnum
.name
, infraGenEpi
));
567 * Returns the tag list for a species aggregate (or similar) taxon.<BR>
568 * Possible ranks for a <i>species aggregate</i> are "aggr.", "species group", ...
569 * @param nonViralName
572 protected List
<TaggedText
> getSpeciesAggregateTaggedCache(INonViralName nonViralName
){
573 if (! isBlank(nonViralName
.getAuthorshipCache())){
574 List
<TaggedText
> result
= getSpeciesTaggedNameCache(nonViralName
);
579 List
<TaggedText
> tags
= getGenusAndSpeciesTaggedPart(nonViralName
);
581 addSpeciesAggregateTaggedEpithet(tags
, nonViralName
);
582 addAppendedTaggedPhrase(tags
, nonViralName
);
587 * Adds the aggregate tag to the tag list.
589 * @param nonViralName
591 private void addSpeciesAggregateTaggedEpithet(List
<TaggedText
> tags
, INonViralName nonViralName
) {
594 marker
= nonViralName
.getRank().getInfraGenericMarker();
595 } catch (UnknownCdmTypeException e
) {
596 marker
= "'unknown aggregat type'";
598 if (isNotBlank(marker
)){
599 tags
.add(new TaggedText(TagEnum
.rank
, marker
));
605 * Returns the tag list for a species taxon.
606 * @param nonViralName
609 protected List
<TaggedText
> getSpeciesTaggedNameCache(INonViralName nonViralName
){
610 List
<TaggedText
> tags
= getGenusAndSpeciesTaggedPart(nonViralName
);
611 addAppendedTaggedPhrase(tags
, nonViralName
);
615 protected List
<TaggedText
> getInfraSpeciesTaggedNameCache(TaxonName name
){
616 if (name
.getNameType().isZoological()){
617 boolean includeMarker
=includeInfraSpecificMarkerForZooNames(name
);
618 return getInfraSpeciesTaggedNameCache(name
, includeMarker
);
620 return getInfraSpeciesTaggedNameCache(name
, true);
624 protected boolean includeInfraSpecificMarkerForZooNames(TaxonName name
){
625 return ! (name
.isAutonym()); //only exclude marker if autonym, see also ZooNameNoMarkerCacheStrategy
629 * Creates the tag list for an infraspecific taxon. If include is true the result will contain
630 * the infraspecific marker (e.g. "var.")
631 * @param nonViralName
632 * @param includeMarker
635 protected List
<TaggedText
> getInfraSpeciesTaggedNameCache(INonViralName nonViralName
, boolean includeMarker
){
636 List
<TaggedText
> tags
= getGenusAndSpeciesTaggedPart(nonViralName
);
637 if (includeMarker
|| nonViralName
.isTrinomHybrid()){
638 String marker
= (nonViralName
.getRank().getAbbreviation()).trim().replace("null", "");
639 if (nonViralName
.isTrinomHybrid()){
640 marker
= CdmUtils
.concat("", NOTHO
, marker
);
642 if (isNotBlank(marker
)){
643 tags
.add(new TaggedText(TagEnum
.rank
, marker
));
647 String infrSpecEpi
= CdmUtils
.Nz(nonViralName
.getInfraSpecificEpithet());
649 infrSpecEpi
= infrSpecEpi
.trim().replace("null", "");
651 if (isNotBlank(infrSpecEpi
)){
652 tags
.add(new TaggedText(TagEnum
.name
, infrSpecEpi
));
655 addAppendedTaggedPhrase(tags
, nonViralName
);
661 * Adds a tag for the hybrid sign and an empty separator to avoid trailing whitespaces.
664 private void addHybridPrefix(List
<TaggedText
> tags
) {
665 tags
.add(new TaggedText(TagEnum
.hybridSign
, NonViralNameParserImplRegExBase
.hybridSign
));
666 tags
.add(new TaggedText(TagEnum
.separator
, "")); //no whitespace separator
670 * Creates the tag list for the genus and species part.
671 * @param nonViralName
674 private List
<TaggedText
> getGenusAndSpeciesTaggedPart(INonViralName nonViralName
) {
676 List
<TaggedText
> tags
= getUninomialTaggedPart(nonViralName
);
679 boolean hasInfraGenericEpi
= isNotBlank(nonViralName
.getInfraGenericEpithet());
680 if (hasInfraGenericEpi
){
681 String infrGenEpi
= nonViralName
.getInfraGenericEpithet().trim();
682 if (nonViralName
.isBinomHybrid()){
683 //maybe not correct but not really expected to happen
684 infrGenEpi
= UTF8
.HYBRID
+ infrGenEpi
;
686 infrGenEpi
= "(" + infrGenEpi
+ ")";
687 tags
.add(new TaggedText(TagEnum
.name
, infrGenEpi
));
691 String specEpi
= CdmUtils
.Nz(nonViralName
.getSpecificEpithet()).trim();
692 if (! hasInfraGenericEpi
&& nonViralName
.isBinomHybrid() ||
693 hasInfraGenericEpi
&& nonViralName
.isTrinomHybrid()){
694 addHybridPrefix(tags
);
696 if (isNotBlank(specEpi
)){
697 tags
.add(new TaggedText(TagEnum
.name
, specEpi
));
703 * Adds the tag for the appended phrase if an appended phrase exists
705 * @param nonViralName
707 protected void addAppendedTaggedPhrase(List
<TaggedText
> tags
, INonViralName nonViralName
){
708 String appendedPhrase
= nonViralName
==null ?
null : nonViralName
.getAppendedPhrase();
709 if (isNotBlank(appendedPhrase
)){
710 tags
.add(new TaggedText(TagEnum
.name
, appendedPhrase
));
715 public String
getLastEpithet(TaxonName taxonName
) {
716 Rank rank
= taxonName
.getRank();
717 if(rank
.isGenus() || rank
.isSupraGeneric()) {
718 return taxonName
.getGenusOrUninomial();
719 } else if(rank
.isInfraGeneric()) {
720 return taxonName
.getInfraGenericEpithet();
721 } else if(rank
.isSpecies()) {
722 return taxonName
.getSpecificEpithet();
724 return taxonName
.getInfraSpecificEpithet();