Project

General

Profile

Download (3.57 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2019 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.model.description;
10

    
11
import javax.persistence.Entity;
12
import javax.persistence.FetchType;
13
import javax.persistence.ManyToOne;
14
import javax.validation.constraints.NotNull;
15
import javax.xml.bind.annotation.XmlAccessType;
16
import javax.xml.bind.annotation.XmlAccessorType;
17
import javax.xml.bind.annotation.XmlElement;
18
import javax.xml.bind.annotation.XmlIDREF;
19
import javax.xml.bind.annotation.XmlRootElement;
20
import javax.xml.bind.annotation.XmlSchemaType;
21
import javax.xml.bind.annotation.XmlType;
22

    
23
import org.apache.log4j.Logger;
24
import org.hibernate.envers.Audited;
25

    
26
import eu.etaxonomy.cdm.model.common.VersionableEntity;
27
import eu.etaxonomy.cdm.model.term.TermNode;
28

    
29
/**
30
 * A class representing a state for a given feature. As instances of {@link State state}
31
 * are reusable they may represent multiple states in e.g. a given feature tree.
32
 * By handling them as a pair with feature it is expected to be explicit within a certain
33
 * feature tree branch and therefore can be used to define values like {@link TermNode#getInapplicableIf()}
34
 * or {@link TermNode#getOnlyApplicableIf()}.
35
 *
36
 * @author a.mueller
37
 * @since 08.08.2019
38
 */
39
@XmlAccessorType(XmlAccessType.FIELD)
40
@XmlType(name="FeatureState", factoryMethod="NewInstance", propOrder = {
41
        "feature",
42
        "state"
43
})
44
@XmlRootElement(name = "FeatureState")
45
@Entity
46
@Audited
47
public class FeatureState extends VersionableEntity {
48

    
49
    private static final long serialVersionUID = -421832597710084356L;
50
    @SuppressWarnings("unused")
51
    private static final Logger logger = Logger.getLogger(FeatureState.class);
52

    
53
    @XmlElement(name = "Feature")
54
    @XmlIDREF
55
    @XmlSchemaType(name = "IDREF")
56
    @ManyToOne(fetch = FetchType.LAZY, targetEntity=Feature.class)
57
    @NotNull
58
    private Feature feature;
59

    
60
    @XmlElement(name = "State")
61
    @XmlIDREF
62
    @XmlSchemaType(name = "IDREF")
63
    @ManyToOne(fetch = FetchType.LAZY, targetEntity=State.class)
64
    @NotNull
65
    private State state;
66

    
67
//*************** CONSTRUCTOR AND FACTORY METHODS **********************************/
68

    
69
    public static FeatureState NewInstance() {
70
        return new FeatureState();
71
    }
72

    
73
    public static FeatureState NewInstance(Feature feature, State state){
74
        return new FeatureState(feature, state);
75
    }
76

    
77

    
78
    //for hibernate use only
79
    @Deprecated
80
    protected FeatureState() {}
81

    
82
    protected FeatureState(Feature feature, State state) {
83
        this.feature = feature;
84
        this.state = state;
85
    }
86

    
87

    
88
/* *********************************** GETTER /SETTER ***************************************/
89

    
90
    public Feature getFeature() {
91
        return feature;
92
    }
93
    public void setFeature(Feature feature) {
94
        this.feature = feature;
95
    }
96

    
97
    public State getState() {
98
        return state;
99
    }
100
    public void setState(State state) {
101
        this.state = state;
102
    }
103

    
104

    
105
// ******************************* TO STRING *******************************************/
106
    @Override
107
    public String toString() {
108
        return "FeatureState [feature=" + feature + ", state=" + state + "]";
109
    }
110

    
111
//*********************************** CLONE ********************************************/
112

    
113

    
114
    @Override
115
    public Object clone() throws CloneNotSupportedException {
116
        FeatureState result = (FeatureState)super.clone();
117

    
118
        //no changes to: feature, state
119
        return result;
120
    }
121

    
122
}
(12-12/38)