blob: 639cf4d929971b05a78a386ff9e898dac4769514 (
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
/*******************************************************************************
* Copyright (c) 2007, 2012 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.jpa.core.internal.jpa1.context.java;
import org.eclipse.jpt.common.core.utility.TextRange;
import org.eclipse.jpt.common.utility.internal.Tools;
import org.eclipse.jpt.jpa.core.context.QueryHint;
import org.eclipse.jpt.jpa.core.context.java.JavaQuery;
import org.eclipse.jpt.jpa.core.context.java.JavaQueryHint;
import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaJpaContextNode;
import org.eclipse.jpt.jpa.core.resource.java.QueryHintAnnotation;
/**
* Java query hing
*/
public class GenericJavaQueryHint
extends AbstractJavaJpaContextNode
implements JavaQueryHint
{
protected final QueryHintAnnotation queryHintAnnotation;
protected String name;
protected String value;
public GenericJavaQueryHint(JavaQuery parent, QueryHintAnnotation queryHintAnnotation) {
super(parent);
this.queryHintAnnotation = queryHintAnnotation;
this.name = queryHintAnnotation.getName();
this.value = queryHintAnnotation.getValue();
}
// ********** synchronize/update **********
@Override
public void synchronizeWithResourceModel() {
super.synchronizeWithResourceModel();
this.setName_(this.queryHintAnnotation.getName());
this.setValue_(this.queryHintAnnotation.getValue());
}
// ********** name **********
public String getName() {
return this.name;
}
public void setName(String name) {
this.queryHintAnnotation.setName(name);
this.setName_(name);
}
protected void setName_(String name) {
String old = this.name;
this.name = name;
this.firePropertyChanged(NAME_PROPERTY, old, name);
}
// ********** value **********
public String getValue() {
return this.value;
}
public void setValue(String value) {
this.queryHintAnnotation.setValue(value);
this.setValue_(value);
}
protected void setValue_(String value) {
String old = this.value;
this.value = value;
this.firePropertyChanged(VALUE_PROPERTY, old, value);
}
// ********** validation **********
public TextRange getValidationTextRange() {
TextRange textRange = this.queryHintAnnotation.getTextRange();
return (textRange != null) ? textRange : this.getQuery().getValidationTextRange();
}
public boolean isEquivalentTo(QueryHint hint) {
return Tools.valuesAreEqual(this.name, hint.getName()) &&
Tools.valuesAreEqual(this.value, hint.getValue()) ;
}
// ********** misc **********
@Override
public JavaQuery getParent() {
return (JavaQuery) super.getParent();
}
protected JavaQuery getQuery() {
return this.getParent();
}
public QueryHintAnnotation getQueryHintAnnotation() {
return this.queryHintAnnotation;
}
@Override
public void toString(StringBuilder sb) {
sb.append(this.name);
}
}
|