2 * Copyright (C) 2009 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
;
11 import java
.io
.Serializable
;
12 import java
.util
.Collection
;
13 import java
.util
.UUID
;
15 import org
.apache
.commons
.lang3
.StringUtils
;
16 import org
.apache
.logging
.log4j
.LogManager
;
17 import org
.apache
.logging
.log4j
.Logger
;
18 import org
.joda
.time
.DateTime
;
20 import eu
.etaxonomy
.cdm
.common
.CdmUtils
;
21 import eu
.etaxonomy
.cdm
.common
.DOI
;
22 import eu
.etaxonomy
.cdm
.common
.URI
;
23 import eu
.etaxonomy
.cdm
.model
.agent
.Contact
;
24 import eu
.etaxonomy
.cdm
.model
.agent
.ORCID
;
25 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
26 import eu
.etaxonomy
.cdm
.model
.common
.ExternallyManaged
;
27 import eu
.etaxonomy
.cdm
.model
.common
.LSID
;
28 import eu
.etaxonomy
.cdm
.model
.common
.TimePeriod
;
29 import eu
.etaxonomy
.cdm
.model
.common
.VerbatimTimePeriod
;
31 public abstract class StrategyBase
32 implements IStrategy
, Serializable
{
34 private static final long serialVersionUID
= -274791080847215663L;
35 @SuppressWarnings("unused")
36 private static final Logger logger
= LogManager
.getLogger();
38 abstract protected UUID
getUuid();
40 // ************************** CONSTRUCTOR ********************************/
42 protected StrategyBase(){}
44 // ************************* METHODS ****************************************/
49 protected static boolean isCollection(Class
<?
> fieldType
) {
50 if (Collection
.class.isAssignableFrom(fieldType
) ){
57 protected boolean isPrimitive(Class
<?
> fieldType
) {
58 if (fieldType
.isPrimitive()){
65 protected boolean isSingleCdmBaseObject(Class
<?
> fieldType
) {
66 if (CdmBase
.class.isAssignableFrom(fieldType
)){
73 protected boolean isUserType(Class
<?
> fieldType
) {
74 if ( fieldType
== TimePeriod
.class ||
75 fieldType
== VerbatimTimePeriod
.class ||
76 fieldType
== DateTime
.class ||
77 fieldType
== LSID
.class ||
78 fieldType
== Contact
.class ||
79 fieldType
== URI
.class ||
80 fieldType
== DOI
.class ||
81 fieldType
== ORCID
.class ||
82 fieldType
== ExternallyManaged
.class
91 * Null safe string. Returns the given string if it is not <code>null</code>.
92 * Empty string otherwise.
93 * @see CdmUtils#Nz(String)
94 * @return the null-safe string
96 protected String
Nz(String str
){
97 return CdmUtils
.Nz(str
);
101 * Checks if a string is not blank.
102 * @see StringUtils#isNotBlank(String)
104 protected boolean isNotBlank(String str
){
105 return StringUtils
.isNotBlank(str
);
109 * Checks if a string is blank.
110 * @see StringUtils#isNotBlank(String)
112 protected static boolean isBlank(String str
){
113 return StringUtils
.isBlank(str
);
116 protected String
removeTrailingDots(String str
){
117 return CdmUtils
.removeTrailingDots(str
);