ref #8369 SpecimenTypeDesignationDTO: adding missing getters and basing on TypedEntit...
[cdmlib.git] / cdmlib-services / src / main / java / eu / etaxonomy / cdm / api / service / dto / RegistrationType.java
1 /**
2 * Copyright (C) 2017 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
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.
8 */
9 package eu.etaxonomy.cdm.api.service.dto;
10
11 import eu.etaxonomy.cdm.model.name.Registration;
12
13 /**
14 * @author a.kohlbecker
15 * @since Mar 3, 2017
16 *
17 */
18 public enum RegistrationType {
19
20 /**
21 * A <code>Registration</code> for a new name
22 */
23 NAME,
24 /**
25 * A <code>Registration</code> for a new name and one or more according
26 * typifications.
27 */
28 NAME_AND_TYPIFICATION,
29 /**
30 * A <code>Registration</code> for one or more typifications for an
31 * previously published name.
32 */
33 TYPIFICATION,
34 /**
35 * A newly created <code>Registration</code> without any name and
36 * typification.
37 */
38 EMPTY;
39
40 /**
41 * @param reg
42 * @return
43 */
44 public static RegistrationType from(Registration reg) {
45
46 if (reg.getName() != null && reg.getTypeDesignations() != null && reg.getTypeDesignations().size() > 0) {
47 return NAME_AND_TYPIFICATION;
48 }
49 if (reg.getName() != null) {
50 return NAME;
51 }
52 if (reg.getTypeDesignations().size() > 0) {
53 return TYPIFICATION;
54 }
55 return EMPTY;
56 }
57
58 /**
59 * @return
60 */
61 public boolean isName() {
62 return NAME.equals(this);
63
64 }
65
66 /**
67 * @return
68 */
69 public boolean isTypification() {
70 return TYPIFICATION.equals(this);
71 }
72
73 /**
74 * @return
75 */
76 public boolean isNameAndTypification() {
77 return NAME_AND_TYPIFICATION.equals(this);
78 }
79
80 /**
81 * @return
82 */
83 public boolean isEnmpty() {
84 return EMPTY.equals(this);
85 }
86
87 }