| /******************************************************************************* |
| * Copyright (c) 2009 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.core.internal.resource.java; |
| |
| import org.eclipse.jdt.core.IAnnotation; |
| import org.eclipse.jpt.core.internal.resource.java.binary.BinaryOneToOneAnnotation; |
| import org.eclipse.jpt.core.internal.resource.java.source.SourceOneToOneAnnotation; |
| import org.eclipse.jpt.core.resource.java.Annotation; |
| import org.eclipse.jpt.core.resource.java.AnnotationDefinition; |
| import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; |
| import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; |
| import org.eclipse.jpt.core.resource.java.OneToOneAnnotation; |
| import org.eclipse.jpt.core.utility.jdt.Attribute; |
| import org.eclipse.jpt.core.utility.jdt.Member; |
| |
| /** |
| * javax.persistence.OneToOne |
| */ |
| public class OneToOneAnnotationDefinition |
| implements AnnotationDefinition |
| { |
| // singleton |
| private static final AnnotationDefinition INSTANCE = new OneToOneAnnotationDefinition(); |
| |
| /** |
| * Return the singleton. |
| */ |
| public static AnnotationDefinition instance() { |
| return INSTANCE; |
| } |
| |
| /** |
| * Ensure single instance. |
| */ |
| private OneToOneAnnotationDefinition() { |
| super(); |
| } |
| |
| public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { |
| return new SourceOneToOneAnnotation((JavaResourcePersistentAttribute) parent, (Attribute) member); |
| } |
| |
| public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { |
| return new NullOneToOneAnnotation((JavaResourcePersistentAttribute) parent); |
| } |
| |
| public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { |
| return new BinaryOneToOneAnnotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); |
| } |
| |
| public String getAnnotationName() { |
| return OneToOneAnnotation.ANNOTATION_NAME; |
| } |
| |
| } |