blob: 8c10a7a29b3c3edeec95d26140cfbbadf9aecd55 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
/*******************************************************************************
* Copyright (c) 2010 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
*
* Contributors:
* Oracle - initial API and implementation
******************************************************************************/
package org.eclipse.jpt.jaxb.core.internal.context.java;
import org.eclipse.jpt.jaxb.core.context.JaxbEnumConstant;
import org.eclipse.jpt.jaxb.core.context.JaxbPersistentEnum;
import org.eclipse.jpt.jaxb.core.internal.context.AbstractJaxbContextNode;
import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceEnumConstant;
import org.eclipse.jpt.jaxb.core.resource.java.XmlEnumValueAnnotation;
public class GenericJavaEnumConstant
extends AbstractJaxbContextNode
implements JaxbEnumConstant {
final protected JavaResourceEnumConstant resourceEnumConstant;
protected String specifiedValue;
public GenericJavaEnumConstant(JaxbPersistentEnum parent, JavaResourceEnumConstant resourceEnumConstant) {
super(parent);
this.resourceEnumConstant = resourceEnumConstant;
this.specifiedValue = this.getResourceEnumValue();
}
public JavaResourceEnumConstant getResourceEnumConstant() {
return this.resourceEnumConstant;
}
// ********** synchronize/update **********
@Override
public void synchronizeWithResourceModel() {
super.synchronizeWithResourceModel();
this.setSpecifiedValue_(this.getResourceEnumValue());
}
// ********** xml enum value annotation **********
protected XmlEnumValueAnnotation getXmlEnumValueAnnotation() {
return (XmlEnumValueAnnotation) this.getResourceEnumConstant().getNonNullAnnotation(XmlEnumValueAnnotation.ANNOTATION_NAME);
}
// ********** name **********
public String getName() {
return this.resourceEnumConstant.getName();
}
// ********** value **********
public String getValue() {
return this.getSpecifiedValue() != null ? this.getSpecifiedValue() : this.getDefaultValue();
}
public String getDefaultValue() {
return this.getName();
}
public String getSpecifiedValue() {
return this.specifiedValue;
}
public void setSpecifiedValue(String value) {
this.getXmlEnumValueAnnotation().setValue(value);
this.setSpecifiedValue_(value);
}
protected void setSpecifiedValue_(String value) {
String old = this.specifiedValue;
this.specifiedValue = value;
this.firePropertyChanged(SPECIFIED_VALUE_PROPERTY, old, value);
}
protected String getResourceEnumValue() {
return this.getXmlEnumValueAnnotation().getValue();
}
}
|