blob: 264faad066b3f14e1fe79ab840c4761444f9e023 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2006, 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.context.java;
import org.eclipse.jpt.common.core.resource.java.Annotation;
import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
import org.eclipse.jpt.jpa.core.JpaFactory;
import org.eclipse.jpt.jpa.core.MappingKeys;
import org.eclipse.jpt.jpa.core.context.java.JavaEntity;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
import org.eclipse.jpt.jpa.core.context.java.JavaTypeMappingDefinition;
import org.eclipse.jpt.jpa.core.resource.java.AssociationOverrideAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.AttributeOverrideAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.DiscriminatorColumnAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.DiscriminatorValueAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.EntityAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.IdClassAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.InheritanceAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.JPA;
import org.eclipse.jpt.jpa.core.resource.java.NamedNativeQueryAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.NamedQueryAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.PrimaryKeyJoinColumnAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.SecondaryTableAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.SequenceGeneratorAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.TableAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.TableGeneratorAnnotation;
public class JavaEntityDefinition
implements JavaTypeMappingDefinition
{
// singleton
private static final JavaEntityDefinition INSTANCE = new JavaEntityDefinition();
/**
* Return the singleton
*/
public static JavaTypeMappingDefinition instance() {
return INSTANCE;
}
/**
* Enforce singleton usage
*/
private JavaEntityDefinition() {
super();
}
public String getKey() {
return MappingKeys.ENTITY_TYPE_MAPPING_KEY;
}
public String getAnnotationName() {
return EntityAnnotation.ANNOTATION_NAME;
}
public Iterable<String> getSupportingAnnotationNames() {
return SUPPORTING_ANNOTATION_NAMES;
}
private static final String[] SUPPORTING_ANNOTATION_NAMES_ARRAY = new String[] {
TableAnnotation.ANNOTATION_NAME,
SecondaryTableAnnotation.ANNOTATION_NAME,
JPA.SECONDARY_TABLES,
PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME,
JPA.PRIMARY_KEY_JOIN_COLUMNS,
IdClassAnnotation.ANNOTATION_NAME,
InheritanceAnnotation.ANNOTATION_NAME,
DiscriminatorValueAnnotation.ANNOTATION_NAME,
DiscriminatorColumnAnnotation.ANNOTATION_NAME,
SequenceGeneratorAnnotation.ANNOTATION_NAME,
TableGeneratorAnnotation.ANNOTATION_NAME,
NamedQueryAnnotation.ANNOTATION_NAME,
JPA.NAMED_QUERIES,
NamedNativeQueryAnnotation.ANNOTATION_NAME,
JPA.NAMED_NATIVE_QUERIES,
JPA.SQL_RESULT_SET_MAPPING,
JPA.EXCLUDE_DEFAULT_LISTENERS,
JPA.EXCLUDE_SUPERCLASS_LISTENERS,
JPA.ENTITY_LISTENERS,
JPA.PRE_PERSIST,
JPA.POST_PERSIST,
JPA.PRE_REMOVE,
JPA.POST_REMOVE,
JPA.PRE_UPDATE,
JPA.POST_UPDATE,
JPA.POST_LOAD,
AttributeOverrideAnnotation.ANNOTATION_NAME,
JPA.ATTRIBUTE_OVERRIDES,
AssociationOverrideAnnotation.ANNOTATION_NAME,
JPA.ASSOCIATION_OVERRIDES
};
private static final Iterable<String> SUPPORTING_ANNOTATION_NAMES = new ArrayIterable<String>(SUPPORTING_ANNOTATION_NAMES_ARRAY);
public JavaEntity buildMapping(JavaPersistentType persistentType, Annotation mappingAnnotation, JpaFactory factory) {
return factory.buildJavaEntity(persistentType, (EntityAnnotation) mappingAnnotation);
}
@Override
public String toString() {
return this.getClass().getSimpleName();
}
}