Skip to main content
summaryrefslogtreecommitdiffstats
blob: 4e759a79b337d22b84e657753fa1fd2d74dc3044 (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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
/*******************************************************************************
 * Copyright (c) 2009 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.eclipselink.core.internal.resource.java.binary;

import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.common.core.utility.TextRange;
import org.eclipse.jpt.jpa.core.internal.resource.java.binary.BinaryAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType;
import org.eclipse.jpt.jpa.eclipselink.core.resource.java.CacheCoordinationType;
import org.eclipse.jpt.jpa.eclipselink.core.resource.java.CacheType;
import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkCacheAnnotation;
import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkTimeOfDayAnnotation;

/**
 * org.eclipse.persistence.annotations.Cache
 */
public final class BinaryEclipseLinkCacheAnnotation
	extends BinaryAnnotation
	implements EclipseLinkCacheAnnotation
{
	private CacheType type;
	private Integer size;
	private Boolean shared;
	private Integer expiry;
	private EclipseLinkTimeOfDayAnnotation expiryTimeOfDay;
	private Boolean alwaysRefresh;
	private Boolean refreshOnlyIfNewer;
	private Boolean disableHits;
	private CacheCoordinationType coordinationType;


	public BinaryEclipseLinkCacheAnnotation(JavaResourcePersistentType parent, IAnnotation jdtAnnotation) {
		super(parent, jdtAnnotation);
		this.type = this.buildType();
		this.size = this.buildSize();
		this.shared = this.buildShared();
		this.expiry = this.buildExpiry();
		this.expiryTimeOfDay = this.buildExpiryTimeOfDay();
		this.alwaysRefresh = this.buildAlwaysRefresh();
		this.refreshOnlyIfNewer = this.buildRefreshOnlyIfNewer();
		this.disableHits = this.buildDisableHits();
		this.coordinationType = this.buildCoordinationType();
	}

	public String getAnnotationName() {
		return ANNOTATION_NAME;
	}

	// TODO
	@Override
	public void update() {
		super.update();
		this.setType_(this.buildType());
		this.setSize_(this.buildSize());
		this.setShared_(this.buildShared());
		this.setExpiry_(this.buildExpiry());
		this.updateExpiryTimeOfDay();
		this.setAlwaysRefresh_(this.buildAlwaysRefresh());
		this.setRefreshOnlyIfNewer_(this.buildRefreshOnlyIfNewer());
		this.setDisableHits_(this.buildDisableHits());
		this.setCoordinationType_(this.buildCoordinationType());
	}


	// ********** CacheAnnotation implementation **********

	// ***** type
	public CacheType getType() {
		return this.type;
	}

	public void setType(CacheType type) {
		throw new UnsupportedOperationException();
	}

	private void setType_(CacheType type) {
		CacheType old = this.type;
		this.type = type;
		this.firePropertyChanged(TYPE_PROPERTY, old, type);
	}

	private CacheType buildType() {
		return CacheType.fromJavaAnnotationValue(this.getJdtMemberValue(EclipseLink.CACHE__TYPE));
	}

	public TextRange getTypeTextRange(CompilationUnit astRoot) {
		throw new UnsupportedOperationException();
	}

	// ***** size
	public Integer getSize() {
		return this.size;
	}

	public void setSize(Integer size) {
		throw new UnsupportedOperationException();
	}

	private void setSize_(Integer size) {
		Integer old = this.size;
		this.size = size;
		this.firePropertyChanged(SIZE_PROPERTY, old, size);
	}

	private Integer buildSize() {
		return (Integer) this.getJdtMemberValue(EclipseLink.CACHE__SIZE);
	}

	public TextRange getSizeTextRange(CompilationUnit astRoot) {
		throw new UnsupportedOperationException();
	}

	// ***** shared
	public Boolean getShared() {
		return this.shared;
	}

	public void setShared(Boolean shared) {
		throw new UnsupportedOperationException();
	}

	private void setShared_(Boolean shared) {
		Boolean old = this.shared;
		this.shared = shared;
		this.firePropertyChanged(SHARED_PROPERTY, old, shared);
	}

	private Boolean buildShared() {
		return (Boolean) this.getJdtMemberValue(EclipseLink.CACHE__SHARED);
	}

	public TextRange getSharedTextRange(CompilationUnit astRoot) {
		throw new UnsupportedOperationException();
	}

	// ***** expiry
	public Integer getExpiry() {
		return this.expiry;
	}

	public void setExpiry(Integer expiry) {
		throw new UnsupportedOperationException();
	}

	private void setExpiry_(Integer expiry) {
		Integer old = this.expiry;
		this.expiry = expiry;
		this.firePropertyChanged(EXPIRY_PROPERTY, old, expiry);
	}

	private Integer buildExpiry() {
		return (Integer) this.getJdtMemberValue(EclipseLink.CACHE__EXPIRY);
	}

	public TextRange getExpiryTextRange(CompilationUnit astRoot) {
		throw new UnsupportedOperationException();
	}

	// ***** expiry time of day
	public EclipseLinkTimeOfDayAnnotation getExpiryTimeOfDay() {
		return this.expiryTimeOfDay;
	}

	public EclipseLinkTimeOfDayAnnotation addExpiryTimeOfDay() {
		throw new UnsupportedOperationException();
	}

	public void removeExpiryTimeOfDay() {
		throw new UnsupportedOperationException();
	}

	private EclipseLinkTimeOfDayAnnotation buildExpiryTimeOfDay() {
		IAnnotation jdtTimeOfDay = this.getJdtExpiryTimeOfDay();
		return (jdtTimeOfDay == null) ? null : this.buildTimeOfDay(jdtTimeOfDay);
	}

	private EclipseLinkTimeOfDayAnnotation buildTimeOfDay(IAnnotation jdtTimeOfDay) {
		return new BinaryEclipseLinkTimeOfDayAnnotation(this, jdtTimeOfDay);
	}

	private IAnnotation getJdtExpiryTimeOfDay() {
		return (IAnnotation) this.getJdtMemberValue(EclipseLink.CACHE__EXPIRY_TIME_OF_DAY);
	}

	private void setExpiryTimeOfDay(EclipseLinkTimeOfDayAnnotation expiryTimeOfDay) {
		EclipseLinkTimeOfDayAnnotation old = this.expiryTimeOfDay;
		this.expiryTimeOfDay = expiryTimeOfDay;
		this.firePropertyChanged(EXPIRY_TIME_OF_DAY_PROPERTY, old, expiryTimeOfDay);
	}

	// TODO
	private void updateExpiryTimeOfDay() {
		throw new UnsupportedOperationException();
//		IAnnotation jdtTimeOfDay = this.getJdtExpiryTimeOfDay();
//		if (jdtTimeOfDay == null) {
//			this.setExpiryTimeOfDay(null);
//		} else {
//			if (this.expiryTimeOfDay == null) {
//				this.setExpiryTimeOfDay(this.buildTimeOfDay(jdtTimeOfDay));
//			} else {
//				this.expiryTimeOfDay.update(jdtTimeOfDay);
//			}
//		}
	}

	public TextRange getExpiryTimeOfDayTextRange(CompilationUnit astRoot) {
		throw new UnsupportedOperationException();
	}

	// ***** always refresh
	public Boolean getAlwaysRefresh() {
		return this.alwaysRefresh;
	}

	public void setAlwaysRefresh(Boolean alwaysRefresh) {
		throw new UnsupportedOperationException();
	}

	private void setAlwaysRefresh_(Boolean alwaysRefresh) {
		Boolean old = this.alwaysRefresh;
		this.alwaysRefresh = alwaysRefresh;
		this.firePropertyChanged(ALWAYS_REFRESH_PROPERTY, old, alwaysRefresh);
	}

	private Boolean buildAlwaysRefresh() {
		return (Boolean) this.getJdtMemberValue(EclipseLink.CACHE__ALWAYS_REFRESH);
	}

	public TextRange getAlwaysRefreshTextRange(CompilationUnit astRoot) {
		throw new UnsupportedOperationException();
	}

	// ***** refresh only if newer
	public Boolean getRefreshOnlyIfNewer() {
		return this.refreshOnlyIfNewer;
	}

	public void setRefreshOnlyIfNewer(Boolean refreshOnlyIfNewer) {
		throw new UnsupportedOperationException();
	}

	private void setRefreshOnlyIfNewer_(Boolean refreshOnlyIfNewer) {
		Boolean old = this.refreshOnlyIfNewer;
		this.refreshOnlyIfNewer = refreshOnlyIfNewer;
		this.firePropertyChanged(REFRESH_ONLY_IF_NEWER_PROPERTY, old, refreshOnlyIfNewer);
	}

	private Boolean buildRefreshOnlyIfNewer() {
		return (Boolean) this.getJdtMemberValue(EclipseLink.CACHE__REFRESH_ONLY_IF_NEWER);
	}

	public TextRange getRefreshOnlyIfNewerTextRange(CompilationUnit astRoot) {
		throw new UnsupportedOperationException();
	}

	// ***** disable hits
	public Boolean getDisableHits() {
		return this.disableHits;
	}

	public void setDisableHits(Boolean disableHits) {
		throw new UnsupportedOperationException();
	}

	private void setDisableHits_(Boolean disableHits) {
		Boolean old = this.disableHits;
		this.disableHits = disableHits;
		this.firePropertyChanged(DISABLE_HITS_PROPERTY, old, disableHits);
	}

	private Boolean buildDisableHits() {
		return (Boolean) this.getJdtMemberValue(EclipseLink.CACHE__DISABLE_HITS);
	}

	public TextRange getDisablesHitsTextRange(CompilationUnit astRoot) {
		throw new UnsupportedOperationException();
	}

	// ***** coordination type
	public CacheCoordinationType getCoordinationType() {
		return this.coordinationType;
	}

	public void setCoordinationType(CacheCoordinationType coordinationType) {
		throw new UnsupportedOperationException();
	}

	private void setCoordinationType_(CacheCoordinationType coordinationType) {
		CacheCoordinationType old = this.coordinationType;
		this.coordinationType = coordinationType;
		this.firePropertyChanged(TYPE_PROPERTY, old, coordinationType);
	}

	private CacheCoordinationType buildCoordinationType() {
		return CacheCoordinationType.fromJavaAnnotationValue(this.getJdtMemberValue(EclipseLink.CACHE__COORDINATION_TYPE));
	}

	public TextRange getCoordinationTypeTextRange(CompilationUnit astRoot) {
		throw new UnsupportedOperationException();
	}

}

Back to the top