blob: 6dc5549eda00d15d3b6e46350622eb3899a57b5b [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2007, 2011 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.source;
import org.eclipse.jpt.common.core.internal.utility.jdt.CombinationIndexedDeclarationAnnotationAdapter;
import org.eclipse.jpt.common.core.internal.utility.jdt.ElementIndexedAnnotationAdapter;
import org.eclipse.jpt.common.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
import org.eclipse.jpt.common.core.resource.java.JavaResourceNode;
import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
import org.eclipse.jpt.common.core.utility.jdt.AnnotationAdapter;
import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationAdapter;
import org.eclipse.jpt.common.core.utility.jdt.IndexedAnnotationAdapter;
import org.eclipse.jpt.common.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
import org.eclipse.jpt.jpa.core.resource.java.JPA;
import org.eclipse.jpt.jpa.core.resource.java.NamedQueryAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.QueryHintAnnotation;
/**
* <code>javax.persistence.NamedQuery</code>
*/
public abstract class SourceNamedQueryAnnotation
extends SourceQueryAnnotation
implements NamedQueryAnnotation
{
private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
private static final DeclarationAnnotationAdapter CONTAINER_DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(JPA.NAMED_QUERIES);
protected SourceNamedQueryAnnotation(JavaResourceNode parent, AnnotatedElement element, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
super(parent, element, daa, annotationAdapter);
}
public String getAnnotationName() {
return ANNOTATION_NAME;
}
// ********** AbstractBaseNamedQueryAnnotation implementation **********
@Override
String getNameElementName() {
return JPA.NAMED_QUERY__NAME;
}
@Override
String getQueryElementName() {
return JPA.NAMED_QUERY__QUERY;
}
@Override
String getHintsElementName() {
return JPA.NAMED_QUERY__HINTS;
}
@Override
QueryHintAnnotation buildHint(int index) {
return SourceQueryHintAnnotation.buildNamedQueryQueryHint(this, this.annotatedElement, this.daa, index);
}
protected static IndexedAnnotationAdapter buildNamedQueryAnnotationAdapter(AnnotatedElement annotatedElement, IndexedDeclarationAnnotationAdapter idaa) {
return new ElementIndexedAnnotationAdapter(annotatedElement, idaa);
}
protected static IndexedDeclarationAnnotationAdapter buildNamedQueryDeclarationAnnotationAdapter(int index) {
IndexedDeclarationAnnotationAdapter idaa =
new CombinationIndexedDeclarationAnnotationAdapter(
DECLARATION_ANNOTATION_ADAPTER,
CONTAINER_DECLARATION_ANNOTATION_ADAPTER,
index,
ANNOTATION_NAME);
return idaa;
}
}