blob: 7f7c8c50d31f676409a37600dc4e7d6fcf017fad [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2008, 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.eclipselink.core.internal.context.java;
import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
import org.eclipse.jpt.jpa.core.context.java.DefaultJavaAttributeMappingDefinition;
import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMappingDefinition;
import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
import org.eclipse.jpt.jpa.core.internal.context.java.JavaAttributeMappingDefinitionWrapper;
import org.eclipse.jpt.jpa.core.internal.context.java.JavaOneToManyMappingDefinition;
import org.eclipse.jpt.jpa.eclipselink.core.resource.java.ConverterAnnotation;
import org.eclipse.jpt.jpa.eclipselink.core.resource.java.JoinFetchAnnotation;
import org.eclipse.jpt.jpa.eclipselink.core.resource.java.ObjectTypeConverterAnnotation;
import org.eclipse.jpt.jpa.eclipselink.core.resource.java.PrivateOwnedAnnotation;
import org.eclipse.jpt.jpa.eclipselink.core.resource.java.StructConverterAnnotation;
import org.eclipse.jpt.jpa.eclipselink.core.resource.java.TypeConverterAnnotation;
public class EclipseLinkJavaOneToManyMappingDefinition
extends JavaAttributeMappingDefinitionWrapper
implements DefaultJavaAttributeMappingDefinition
{
private static final JavaAttributeMappingDefinition DELEGATE = JavaOneToManyMappingDefinition.instance();
// singleton
private static final DefaultJavaAttributeMappingDefinition INSTANCE = new EclipseLinkJavaOneToManyMappingDefinition();
/**
* Return the singleton.
*/
public static DefaultJavaAttributeMappingDefinition instance() {
return INSTANCE;
}
/**
* Enforce singleton usage
*/
private EclipseLinkJavaOneToManyMappingDefinition() {
super();
}
@Override
protected JavaAttributeMappingDefinition getDelegate() {
return DELEGATE;
}
@Override
public Iterable<String> getSupportingAnnotationNames() {
return COMBINED_SUPPORTING_ANNOTATION_NAMES;
}
private static final String[] ECLIPSE_LINK_SUPPORTING_ANNOTATION_NAMES_ARRAY = new String[] {
ConverterAnnotation.ANNOTATION_NAME,
JoinFetchAnnotation.ANNOTATION_NAME,
ObjectTypeConverterAnnotation.ANNOTATION_NAME,
PrivateOwnedAnnotation.ANNOTATION_NAME,
StructConverterAnnotation.ANNOTATION_NAME,
TypeConverterAnnotation.ANNOTATION_NAME,
};
public static final Iterable<String> ECLIPSE_LINK_SUPPORTING_ANNOTATION_NAMES = IterableTools.iterable(ECLIPSE_LINK_SUPPORTING_ANNOTATION_NAMES_ARRAY);
@SuppressWarnings("unchecked")
private static final Iterable<String> COMBINED_SUPPORTING_ANNOTATION_NAMES = IterableTools.concatenate(
DELEGATE.getSupportingAnnotationNames(),
ECLIPSE_LINK_SUPPORTING_ANNOTATION_NAMES
);
public boolean isDefault(JavaSpecifiedPersistentAttribute persistentAttribute) {
String targetEntity = persistentAttribute.getMultiReferenceTargetTypeName();
return (targetEntity != null)
&& (persistentAttribute.getPersistenceUnit().getEntity(targetEntity) != null);
}
}