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.
10 package eu
.etaxonomy
.cdm
.strategy
;
12 import java
.io
.Serializable
;
14 import java
.util
.Collection
;
15 import java
.util
.UUID
;
17 import org
.apache
.commons
.lang
.StringUtils
;
18 import org
.apache
.log4j
.Logger
;
19 import org
.joda
.time
.DateTime
;
21 import eu
.etaxonomy
.cdm
.common
.CdmUtils
;
22 import eu
.etaxonomy
.cdm
.common
.DOI
;
23 import eu
.etaxonomy
.cdm
.model
.agent
.Contact
;
24 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
25 import eu
.etaxonomy
.cdm
.model
.common
.LSID
;
26 import eu
.etaxonomy
.cdm
.model
.common
.TimePeriod
;
29 public abstract class StrategyBase
implements IStrategy
, Serializable
{
30 private static final long serialVersionUID
= -274791080847215663L;
31 @SuppressWarnings("unused")
32 private static final Logger logger
= Logger
.getLogger(StrategyBase
.class);
34 final static UUID uuid
= UUID
.fromString("2ff2b1d6-17a6-4807-a55f-f6b45bf429b7");
36 abstract protected UUID
getUuid();
38 protected StrategyBase(){
48 protected static boolean isCollection(Class
<?
> fieldType
) {
49 if (Collection
.class.isAssignableFrom(fieldType
) ){
60 protected boolean isPrimitive(Class
<?
> fieldType
) {
61 if (fieldType
.isPrimitive()){
72 protected boolean isSingleCdmBaseObject(Class
<?
> fieldType
) {
73 if (CdmBase
.class.isAssignableFrom(fieldType
)){
84 protected boolean isUserType(Class
<?
> fieldType
) {
85 if ( fieldType
== TimePeriod
.class ||
86 fieldType
== DateTime
.class ||
87 fieldType
== LSID
.class ||
88 fieldType
== Contact
.class ||
89 fieldType
== URI
.class ||
90 fieldType
== DOI
.class
100 * Null safe string. Returns the given string if it is not <code>null</code>.
101 * Empty string otherwise.
102 * @see CdmUtils#Nz(String)
103 * @return the null-safe string
105 protected String
Nz(String str
){
106 return CdmUtils
.Nz(str
);
110 * Checks if a string is not blank.
111 * @see StringUtils#isNotBlank(String)
113 protected boolean isNotBlank(String str
){
114 return StringUtils
.isNotBlank(str
);
118 * Checks if a string is blank.
119 * @see StringUtils#isNotBlank(String)
121 protected boolean isBlank(String str
){
122 return StringUtils
.isBlank(str
);