blob: f9e5b4c0004362aaae13f3301be474d51a612917 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2009, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0, which accompanies this distribution
* and is available at https://www.eclipse.org/legal/epl-2.0/.
*
* Contributors:
* Oracle - initial API and implementation
******************************************************************************/
package org.eclipse.jpt.jpa.core.internal.jpa2.context.java;
import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
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.JavaSpecifiedPersistentAttribute;
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.AccessAnnotation2_0;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.CollectionTableAnnotation2_0;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.ElementCollectionAnnotation2_0;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.JPA2_0;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.MapKeyClassAnnotation2_0;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.MapKeyColumnAnnotation2_0;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.MapKeyEnumeratedAnnotation2_0;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.MapKeyJoinColumnAnnotation2_0;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.MapKeyTemporalAnnotation2_0;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.OrderColumnAnnotation2_0;
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 ElementCollectionAnnotation2_0.ANNOTATION_NAME;
}
public boolean isSpecified(JavaSpecifiedPersistentAttribute 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[] {
AccessAnnotation2_0.ANNOTATION_NAME,
AssociationOverrideAnnotation.ANNOTATION_NAME,
JPA.ASSOCIATION_OVERRIDES,
AttributeOverrideAnnotation.ANNOTATION_NAME,
JPA.ATTRIBUTE_OVERRIDES,
CollectionTableAnnotation2_0.ANNOTATION_NAME,
ColumnAnnotation.ANNOTATION_NAME,
EnumeratedAnnotation.ANNOTATION_NAME,
LobAnnotation.ANNOTATION_NAME,
MapKeyAnnotation.ANNOTATION_NAME,
MapKeyClassAnnotation2_0.ANNOTATION_NAME,
MapKeyColumnAnnotation2_0.ANNOTATION_NAME,
MapKeyEnumeratedAnnotation2_0.ANNOTATION_NAME,
MapKeyJoinColumnAnnotation2_0.ANNOTATION_NAME,
JPA2_0.MAP_KEY_JOIN_COLUMNS,
MapKeyTemporalAnnotation2_0.ANNOTATION_NAME,
OrderByAnnotation.ANNOTATION_NAME,
OrderColumnAnnotation2_0.ANNOTATION_NAME,
TemporalAnnotation.ANNOTATION_NAME
};
private static final Iterable<String> SUPPORTING_ANNOTATION_NAMES = IterableTools.iterable(SUPPORTING_ANNOTATION_NAMES_ARRAY);
public JavaAttributeMapping buildMapping(JavaSpecifiedPersistentAttribute persistentAttribute, JpaFactory factory) {
return ((JpaFactory2_0) factory).buildJavaElementCollectionMapping(persistentAttribute);
}
@Override
public String toString() {
return this.getClass().getSimpleName();
}
}