blob: 6ce75a03cb1e0baeaf7b70144ccd7ddb442108f3 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2009, 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.jpa2.context.java;
import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
import org.eclipse.jpt.jpa.core.JpaFactory;
import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMapping;
import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMappingDefinition;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
import org.eclipse.jpt.jpa.core.jpa2.JpaFactory2_0;
import org.eclipse.jpt.jpa.core.jpa2.MappingKeys2_0;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.Access2_0Annotation;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.CollectionTable2_0Annotation;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.ElementCollection2_0Annotation;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.JPA2_0;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.MapKeyClass2_0Annotation;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.MapKeyColumn2_0Annotation;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.MapKeyEnumerated2_0Annotation;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.MapKeyJoinColumn2_0Annotation;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.MapKeyTemporal2_0Annotation;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.OrderColumn2_0Annotation;
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.ColumnAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.EnumeratedAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.JPA;
import org.eclipse.jpt.jpa.core.resource.java.LobAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.MapKeyAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.OrderByAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.TemporalAnnotation;
public class JavaElementCollectionMappingDefinition2_0
implements JavaAttributeMappingDefinition
{
// singleton
private static final JavaAttributeMappingDefinition INSTANCE = new JavaElementCollectionMappingDefinition2_0();
/**
* Return the singleton.
*/
public static JavaAttributeMappingDefinition instance() {
return INSTANCE;
}
/**
* Enforce singleton usage
*/
private JavaElementCollectionMappingDefinition2_0() {
super();
}
public String getKey() {
return MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY;
}
public String getAnnotationName() {
return ElementCollection2_0Annotation.ANNOTATION_NAME;
}
public boolean isSpecified(JavaPersistentAttribute persistentAttribute) {
return persistentAttribute.getResourceAttribute().getAnnotation(this.getAnnotationName()) != null;
}
public Iterable<String> getSupportingAnnotationNames() {
return SUPPORTING_ANNOTATION_NAMES;
}
private static final String[] SUPPORTING_ANNOTATION_NAMES_ARRAY = new String[] {
Access2_0Annotation.ANNOTATION_NAME,
AssociationOverrideAnnotation.ANNOTATION_NAME,
JPA.ASSOCIATION_OVERRIDES,
AttributeOverrideAnnotation.ANNOTATION_NAME,
JPA.ATTRIBUTE_OVERRIDES,
CollectionTable2_0Annotation.ANNOTATION_NAME,
ColumnAnnotation.ANNOTATION_NAME,
EnumeratedAnnotation.ANNOTATION_NAME,
LobAnnotation.ANNOTATION_NAME,
MapKeyAnnotation.ANNOTATION_NAME,
MapKeyClass2_0Annotation.ANNOTATION_NAME,
MapKeyColumn2_0Annotation.ANNOTATION_NAME,
MapKeyEnumerated2_0Annotation.ANNOTATION_NAME,
MapKeyJoinColumn2_0Annotation.ANNOTATION_NAME,
JPA2_0.MAP_KEY_JOIN_COLUMNS,
MapKeyTemporal2_0Annotation.ANNOTATION_NAME,
OrderByAnnotation.ANNOTATION_NAME,
OrderColumn2_0Annotation.ANNOTATION_NAME,
TemporalAnnotation.ANNOTATION_NAME
};
private static final Iterable<String> SUPPORTING_ANNOTATION_NAMES = new ArrayIterable<String>(SUPPORTING_ANNOTATION_NAMES_ARRAY);
public JavaAttributeMapping buildMapping(JavaPersistentAttribute persistentAttribute, JpaFactory factory) {
return ((JpaFactory2_0) factory).buildJavaElementCollectionMapping2_0(persistentAttribute);
}
@Override
public String toString() {
return this.getClass().getSimpleName();
}
}