blob: 437c432f1ab6a01928c2fa88d0dfba9f957ee418 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 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.eclipselink.core.internal.context.java;
import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
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.internal.context.java.JavaBasicMappingDefinition;
import org.eclipse.jpt.jpa.eclipselink.core.EclipseLinkMappingKeys;
import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkArrayAnnotation2_3;
import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkConvertAnnotation;
import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkConverterAnnotation;
import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkObjectTypeConverterAnnotation;
import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkStructConverterAnnotation;
import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkTypeConverterAnnotation;
public class EclipseLinkJavaArrayMappingDefinition2_3
implements JavaAttributeMappingDefinition
{
// singleton
private static final JavaAttributeMappingDefinition INSTANCE = new EclipseLinkJavaArrayMappingDefinition2_3();
/**
* Return the singleton.
*/
public static JavaAttributeMappingDefinition instance() {
return INSTANCE;
}
/**
* Enforce singleton usage
*/
private EclipseLinkJavaArrayMappingDefinition2_3() {
super();
}
public String getKey() {
return EclipseLinkMappingKeys.ARRAY_ATTRIBUTE_MAPPING_KEY;
}
public String getAnnotationName() {
return EclipseLinkArrayAnnotation2_3.ANNOTATION_NAME;
}
public boolean isSpecified(JavaPersistentAttribute persistentAttribute) {
return persistentAttribute.getResourceAttribute().getAnnotation(this.getAnnotationName()) != null;
}
public Iterable<String> getSupportingAnnotationNames() {
return COMBINED_SUPPORTING_ANNOTATION_NAMES;
}
private static final String[] ECLIPSE_LINK_SUPPORTING_ANNOTATION_NAMES_ARRAY = new String[] {
EclipseLinkConvertAnnotation.ANNOTATION_NAME,
EclipseLinkConverterAnnotation.ANNOTATION_NAME,
EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME,
EclipseLinkStructConverterAnnotation.ANNOTATION_NAME,
EclipseLinkTypeConverterAnnotation.ANNOTATION_NAME
};
private static final Iterable<String> ECLIPSE_LINK_SUPPORTING_ANNOTATION_NAMES = new ArrayIterable<String>(ECLIPSE_LINK_SUPPORTING_ANNOTATION_NAMES_ARRAY);
public JavaAttributeMapping buildMapping(JavaPersistentAttribute persistentAttribute, JpaFactory factory) {
return new JavaEclipseLinkArrayMapping2_3(persistentAttribute);
}
@SuppressWarnings("unchecked")
private static final Iterable<String> COMBINED_SUPPORTING_ANNOTATION_NAMES = new CompositeIterable<String>(
JavaBasicMappingDefinition.instance().getSupportingAnnotationNames(),
ECLIPSE_LINK_SUPPORTING_ANNOTATION_NAMES
);
@Override
public String toString() {
return this.getClass().getSimpleName();
}
}