blob: 5c98ccf8b3a43208af333d10b9ffa910ebbb59f7 [file] [log] [blame]
/*******************************************************************************
* 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.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.resource.java.JavaResourceNode;
import org.eclipse.jpt.jpa.core.resource.java.TemporalAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.TemporalType;
/**
* javax.persistence.Temporal
* javax.persistence.MapKeyTemporal
*/
public abstract class BinaryBaseTemporalAnnotation
extends BinaryAnnotation
implements TemporalAnnotation
{
private TemporalType value;
protected BinaryBaseTemporalAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) {
super(parent, jdtAnnotation);
this.value = this.buildValue();
}
@Override
public void update() {
super.update();
this.setValue_(this.buildValue());
}
// ********** TemporalAnnotation implementation **********
// ***** value
public TemporalType getValue() {
return this.value;
}
public void setValue(TemporalType value) {
throw new UnsupportedOperationException();
}
private void setValue_(TemporalType value) {
TemporalType old = this.value;
this.value = value;
this.firePropertyChanged(VALUE_PROPERTY, old, value);
}
private TemporalType buildValue() {
return TemporalType.fromJavaAnnotationValue(this.getJdtMemberValue(getValueElementName()));
}
public TextRange getValueTextRange(CompilationUnit astRoot) {
throw new UnsupportedOperationException();
}
protected abstract String getValueElementName();
}