diff options
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource')
208 files changed, 0 insertions, 23432 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/ModuleResourceLocator.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/ModuleResourceLocator.java deleted file mode 100644 index 1b65b98f26..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/ModuleResourceLocator.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 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; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.internal.utility.PlatformTools; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualFile; -import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; -import org.eclipse.wst.common.componentcore.resources.IVirtualResource; - -public class ModuleResourceLocator - extends SimpleJavaResourceLocator { - - /** - * Return the folder representing the "META-INF" runtime location - */ - @Override - public IContainer getDefaultResourceLocation(IProject project) { - IVirtualComponent component = ComponentCore.createComponent(project); - return component.getRootFolder().getFolder(META_INF_PATH).getUnderlyingFolder(); - } - - @Override - public IPath getResourcePath(IProject project, IPath runtimePath) { - IVirtualComponent component = ComponentCore.createComponent(project); - return component.getRootFolder().getFile(runtimePath).getWorkspaceRelativePath(); - } - - @Override - public IPath getRuntimePath(IProject project, IPath resourcePath) { - IFile file = PlatformTools.getFile(resourcePath); - IVirtualComponent component = ComponentCore.createComponent(project); - IVirtualFolder root = component.getRootFolder(); - IVirtualFile vFile = findVirtualFile(root, file); - if (vFile != null) { - return vFile.getRuntimePath().makeRelative(); - } - // couldn't find it. try the super-case - return super.getRuntimePath(project, resourcePath); - } - - private IVirtualFile findVirtualFile(IVirtualFolder vFolder, IFile file) { - try { - for (IVirtualResource vResource : vFolder.members()) { - if (vResource.getType() == IVirtualResource.FILE) { - IVirtualFile vFile = (IVirtualFile) vResource; - if (file.equals(vFile.getUnderlyingResource())) { - return vFile; - } - } - else if (vResource.getType() == IVirtualResource.FOLDER) { - IVirtualFile vFile = findVirtualFile((IVirtualFolder) vResource, file); - if (vFile != null) { - return vFile; - } - } - } - } - catch (CoreException ce) { - // fall through - JptCorePlugin.log(ce); - } - return null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/PluginResourceLocator.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/PluginResourceLocator.java deleted file mode 100644 index 7e4ff5eda3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/PluginResourceLocator.java +++ /dev/null @@ -1,93 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 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; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.internal.utility.PlatformTools; -import org.eclipse.pde.core.project.IBundleProjectDescription; -import org.eclipse.pde.core.project.IBundleProjectService; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; - -public class PluginResourceLocator - extends SimpleJavaResourceLocator { - - @Override - public IContainer getDefaultResourceLocation(IProject project) { - try { - IContainer root = getBundleRoot(project); - return root.getFolder(META_INF_PATH); - } - catch (CoreException ce) { - // fall through - JptCorePlugin.log(ce); - } - return super.getDefaultResourceLocation(project); - } - - @Override - public IPath getResourcePath(IProject project, IPath runtimePath) { - try { - IContainer root = getBundleRoot(project); - IPath resourcePath = root.getFullPath().append(runtimePath); - if (project.getWorkspace().getRoot().getFile(resourcePath).exists()) { - return resourcePath; - } - } - catch (CoreException ce) { - // fall through - JptCorePlugin.log(ce); - } - return super.getResourcePath(project, runtimePath); - } - - @Override - public IPath getRuntimePath(IProject project, IPath resourcePath) { - IFile file = PlatformTools.getFile(resourcePath); - try { - IContainer root = getBundleRoot(project); - if (root.contains(file)) { - return resourcePath.makeRelativeTo(root.getFullPath()); - } - } - catch (CoreException ce) { - // fall through - JptCorePlugin.log(ce); - } - return super.getRuntimePath(project, resourcePath); - } - - protected IContainer getBundleRoot(IProject project) - throws CoreException { - - IBundleProjectService service = getBundleProjectService(); - IBundleProjectDescription description = service.getDescription(project); - IPath path = description.getBundleRoot(); - return (path == null) ? project : project.getFolder(path); - } - - protected IBundleProjectService getBundleProjectService() { - BundleContext context = JptCorePlugin.instance().getBundle().getBundleContext(); - ServiceReference reference = context.getServiceReference(IBundleProjectService.class.getName()); - if (reference == null) { - return null; - } - IBundleProjectService service = (IBundleProjectService) context.getService(reference); - if (service != null) { - context.ungetService(reference); - } - return service; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/ResourceLocatorConfig.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/ResourceLocatorConfig.java deleted file mode 100644 index 38ec1469f8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/ResourceLocatorConfig.java +++ /dev/null @@ -1,168 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 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; - -import static org.eclipse.jst.common.project.facet.core.internal.FacetedProjectFrameworkJavaPlugin.log; -import org.eclipse.core.expressions.EvaluationContext; -import org.eclipse.core.expressions.EvaluationResult; -import org.eclipse.core.expressions.Expression; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.internal.XPointUtil; -import org.eclipse.jpt.core.resource.ResourceLocator; -import org.eclipse.jpt.utility.internal.StringTools; - -public class ResourceLocatorConfig - implements Comparable<ResourceLocatorConfig> { - - public static final String PROJECT_ENABLEMENT_VARIABLE = "project"; //$NON-NLS-1$ - - private String id; - private String pluginId; - private String className; - private Priority priority; - private Expression enablementCondition; - - - ResourceLocatorConfig() { - super(); - } - - - public String getId() { - return this.id; - } - - void setId(String id) { - this.id = id; - } - - public String getPluginId() { - return this.pluginId; - } - - void setPluginId(String pluginId) { - this.pluginId = pluginId; - } - - public String getClassName() { - return this.className; - } - - void setClassName(String className) { - this.className = className; - } - - public Priority getPriority() { - return priority; - } - - void setPriority(Priority priority) { - this.priority = priority; - } - - public Expression getEnablementCondition() { - return this.enablementCondition; - } - - void setEnablementCondition(Expression enablementCondition) { - this.enablementCondition = enablementCondition; - } - - public ResourceLocator getResourceLocator() { - return XPointUtil.instantiate( - JptCorePlugin.PLUGIN_ID, ResourceLocatorManager.QUALIFIED_EXTENSION_POINT_ID, - this.className, ResourceLocator.class); - } - - public boolean isEnabledFor(IProject project) { - EvaluationContext evalContext = new EvaluationContext(null, project); - evalContext.setAllowPluginActivation(true); - evalContext.addVariable(PROJECT_ENABLEMENT_VARIABLE, project); - - if (this.enablementCondition != null) { - try { - EvaluationResult evalResult = this.enablementCondition.evaluate(evalContext); - - if (evalResult == EvaluationResult.FALSE) { - return false; - } - } - catch (CoreException e) { - log(e); - } - } - - return true; - } - - public int compareTo(ResourceLocatorConfig other) { - return Priority.compare(this.priority, other.priority); - } - - - public static enum Priority { - - /* The lowest priority for a resource locator */ - LOWEST(6, "lowest"), - - /* The second lowest priority for a resource locator */ - LOWER(5, "lower"), - - /* The third lowest priority for a resource locator */ - LOW(4, "low"), - - /* The default priority for a resource locator */ - NORMAL(3, "normal"), - - /* The third highest priority for a resource locator */ - HIGH(2, "high"), - - /* The second highest priority for a resource locator */ - HIGHER(1, "higher"), - - /* The highest priority for a resource locator */ - HIGHEST(0, "highest"); - - - public static int compare(Priority priority1, Priority priority2) { - return priority1.value.compareTo(priority2.value); - } - - public static Priority get(String literal) { - if (literal == null) { - return NORMAL; - } - for (Priority priority : values()) { - if (StringTools.stringsAreEqual(literal, priority.literal)) { - return priority; - } - } - return null; - } - - - private Integer value; - private String literal; - - - private Priority(int value, String literal) { - this.value = Integer.valueOf(value); - this.literal = literal; - } - - - @Override - public String toString() { - return this.literal; - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/ResourceLocatorManager.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/ResourceLocatorManager.java deleted file mode 100644 index 97768037a1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/ResourceLocatorManager.java +++ /dev/null @@ -1,164 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 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; - -import static org.eclipse.jpt.core.internal.XPointUtil.*; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.TreeSet; -import org.eclipse.core.expressions.Expression; -import org.eclipse.core.expressions.ExpressionConverter; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IExtensionRegistry; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.internal.XPointUtil.XPointException; -import org.eclipse.jpt.core.internal.resource.ResourceLocatorConfig.Priority; -import org.eclipse.jpt.core.resource.ResourceLocator; -import org.eclipse.jpt.utility.internal.KeyedSet; -import org.eclipse.jpt.utility.internal.iterables.FilteringIterable; -import org.eclipse.jpt.utility.internal.iterables.TransformationIterable; - -public class ResourceLocatorManager { - - public static final String EXTENSION_POINT_ID = "resourceLocators"; - public static final String QUALIFIED_EXTENSION_POINT_ID = JptCorePlugin.PLUGIN_ID_ + EXTENSION_POINT_ID; - public static final String RESOURCE_LOCATOR_ELEMENT = "resourceLocator"; - public static final String ID_ATTRIBUTE = "id"; - public static final String CLASS_ATTRIBUTE = "class"; - public static final String PRIORITY_ATTRIBUTE = "priority"; - public static final String ENABLEMENT_ELEMENT = "enablement"; - - - private static ResourceLocatorManager INSTANCE = new ResourceLocatorManager(); - - - public static ResourceLocatorManager instance() { - return INSTANCE; - } - - - private KeyedSet<String, ResourceLocatorConfig> resourceLocatorConfigs; - - - private ResourceLocatorManager() { - this.resourceLocatorConfigs = new KeyedSet<String, ResourceLocatorConfig>(); - readExtensions(); - } - - - /** - * Return the {@link ResourceLocator} of highest priority that is acceptable - * for the given project - */ - public ResourceLocator getResourceLocator(final IProject project) { - Iterator<ResourceLocator> stream = new FilteringIterable<ResourceLocator>( - new TransformationIterable<ResourceLocatorConfig, ResourceLocator>( - new FilteringIterable<ResourceLocatorConfig>( - new TreeSet<ResourceLocatorConfig>(this.resourceLocatorConfigs.getItemSet())) { - @Override - protected boolean accept(ResourceLocatorConfig o) { - return o.isEnabledFor(project); - } - }) { - @Override - protected ResourceLocator transform(ResourceLocatorConfig o) { - return o.getResourceLocator(); - } - }) { - @Override - protected boolean accept(ResourceLocator o) { - return o != null; - } - }.iterator(); - return (stream.hasNext()) ? stream.next() : null; - } - - private void readExtensions() { - final IExtensionRegistry registry = Platform.getExtensionRegistry(); - - final IExtensionPoint xpoint - = registry.getExtensionPoint(JptCorePlugin.PLUGIN_ID, EXTENSION_POINT_ID); - - if (xpoint == null) { - throw new IllegalStateException(); - } - - final List<IConfigurationElement> configs = new ArrayList<IConfigurationElement>(); - - for (IExtension extension : xpoint.getExtensions()) { - for (IConfigurationElement element : extension.getConfigurationElements()) { - configs.add(element); - } - } - - for (IConfigurationElement element : configs) { - if (element.getName().equals(RESOURCE_LOCATOR_ELEMENT)) { - readExtension(element); - } - } - } - - private void readExtension(IConfigurationElement element) { - try { - final ResourceLocatorConfig rlConfig = new ResourceLocatorConfig(); - - // plug-in id - rlConfig.setPluginId(element.getContributor().getName()); - - // resource locator id - rlConfig.setId(findRequiredAttribute(element, ID_ATTRIBUTE)); - - if (this.resourceLocatorConfigs.containsKey(rlConfig.getId())) { - logDuplicateExtension(QUALIFIED_EXTENSION_POINT_ID, rlConfig.getId()); - throw new XPointException(); - } - - // resource locator class name - rlConfig.setClassName(findRequiredAttribute(element, CLASS_ATTRIBUTE)); - - // priority - String priorityString = element.getAttribute(PRIORITY_ATTRIBUTE).trim(); - Priority priority = Priority.get(priorityString); - if (priority == null) { - logInvalidValue(element, PRIORITY_ATTRIBUTE, priorityString); - throw new XPointException(); - } - rlConfig.setPriority(priority); - - // enablement - for (IConfigurationElement child : element.getChildren()) { - String childName = child.getName(); - if (childName.equals(ENABLEMENT_ELEMENT)) { - Expression expr; - try { - expr = ExpressionConverter.getDefault().perform(child); - } - catch (CoreException e) { - log(e); - throw new XPointException(); - } - rlConfig.setEnablementCondition(expr); - } - } - - this.resourceLocatorConfigs.addItem(rlConfig.getId(), rlConfig); - } - catch (XPointException e) { - // Ignore and continue. The problem has already been reported to the user - // in the log. - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/SimpleJavaResourceLocator.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/SimpleJavaResourceLocator.java deleted file mode 100644 index bc83e0be94..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/SimpleJavaResourceLocator.java +++ /dev/null @@ -1,152 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 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; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.internal.utility.PlatformTools; -import org.eclipse.jpt.core.resource.ResourceLocator; -import org.eclipse.jst.j2ee.internal.J2EEConstants; - -public class SimpleJavaResourceLocator - implements ResourceLocator { - - protected static IPath META_INF_PATH = new Path(J2EEConstants.META_INF); - - /** - * Simply ensure the container is either: - * - on the java project classpath - * or - * - in the non-java resources, but not in the project output location - */ - public boolean acceptResourceLocation(IProject project, IContainer container) { - IJavaProject javaProject = getJavaProject(project); - if (javaProject.isOnClasspath(container)) { - return true; - } - try { - IPath outputLocation = javaProject.getOutputLocation(); - if (container.equals(project) && outputLocation.isPrefixOf(container.getFullPath())) { - return true; - } - for (Object resource : javaProject.getNonJavaResources()) { - if (resource instanceof IFolder) { - IFolder folder = (IFolder) resource; - if ((folder.equals(container) || folder.contains(container)) - && ! outputLocation.isPrefixOf(container.getFullPath())) { - return true; - } - } - } - } - catch (JavaModelException jme) { - JptCorePlugin.log(jme); - // only happens if the java project doesn't exist. fall through. - } - return false; - } - - /** - * Return - * - the first package fragment root (source folder) META-INF folder if it exists, - * or - * - the project rooted META-INF folder if it exists - * or - * - the non-existent META-INF folder in the first package fragment root (source folder) - */ - public IContainer getDefaultResourceLocation(IProject project) { - IJavaProject javaProject = getJavaProject(project); - IContainer defaultLocation = null; - try { - for (IPackageFragmentRoot root : javaProject.getPackageFragmentRoots()) { - if (root.getKind() == IPackageFragmentRoot.K_SOURCE) { - IContainer rootContainer = (IContainer) root.getUnderlyingResource(); - IFolder metaInfFolder = rootContainer.getFolder(META_INF_PATH); - if (metaInfFolder.exists()) { - return metaInfFolder; - } - if (defaultLocation == null) { - // hold on to this in case the META-INF folder can't be found - defaultLocation = metaInfFolder; - } - } - } - IFolder metaInfFolder = project.getFolder(META_INF_PATH); - if (metaInfFolder.exists()) { - return metaInfFolder; - } - } - catch (JavaModelException jme) { - // only happens if the java project doesn't exist or there is some problem with the - // java resources. fall through. - JptCorePlugin.log(jme); - } - - return defaultLocation; - } - - public IPath getResourcePath(IProject project, IPath runtimePath) { - IJavaProject javaProject = getJavaProject(project); - IPath firstResourcePath = null; - try { - for (IPackageFragmentRoot root : javaProject.getPackageFragmentRoots()) { - if (root.getKind() == IPackageFragmentRoot.K_SOURCE) { - IContainer rootContainer = (IContainer) root.getUnderlyingResource(); - IPath resourcePath = rootContainer.getFullPath().append(runtimePath); - if (firstResourcePath == null) { - firstResourcePath = resourcePath; - } - IFile file = project.getWorkspace().getRoot().getFile(resourcePath); - if (file.exists()) { - return file.getFullPath(); - } - } - } - } - catch (JavaModelException jme) { - JptCorePlugin.log(jme); - return null; - } - return firstResourcePath; - } - - public IPath getRuntimePath(IProject project, IPath resourcePath) { - IJavaProject javaProject = getJavaProject(project); - IFile file = PlatformTools.getFile(resourcePath); - try { - for (IPackageFragmentRoot root : javaProject.getPackageFragmentRoots()) { - if (root.getKind() == IPackageFragmentRoot.K_SOURCE) { - IContainer rootContainer = (IContainer) root.getUnderlyingResource(); - if (rootContainer.contains(file)) { - return resourcePath.makeRelativeTo(rootContainer.getFullPath()); - } - } - } - } - catch (JavaModelException jme) { - // fall through - JptCorePlugin.log(jme); - } - return resourcePath.makeRelativeTo(project.getFullPath()); - } - - private IJavaProject getJavaProject(IProject project) { - return JavaCore.create(project); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/WebModuleResourceLocator.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/WebModuleResourceLocator.java deleted file mode 100644 index 3e1139e24e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/WebModuleResourceLocator.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 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; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jst.j2ee.internal.J2EEConstants; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; - -public class WebModuleResourceLocator - extends ModuleResourceLocator{ - - protected static IPath WEB_INF_CLASSES_PATH = new Path(J2EEConstants.WEB_INF_CLASSES); - - /** - * Return the folder representing the "WEB-INF/classes/META-INF" location - */ - @Override - public IContainer getDefaultResourceLocation(IProject project) { - IVirtualComponent component = ComponentCore.createComponent(project); - return component.getRootFolder().getFolder(WEB_INF_CLASSES_PATH.append(META_INF_PATH)).getUnderlyingFolder(); - } - - /** - * Return the full resource path representing the given runtime location appended - * to the "WEB-INF/classes" location - */ - @Override - public IPath getResourcePath(IProject project, IPath runtimePath) { - return super.getResourcePath(project, WEB_INF_CLASSES_PATH.append(runtimePath)); - } - - /** - * - */ - @Override - public IPath getRuntimePath(IProject project, IPath resourcePath) { - IPath runtimePath = super.getRuntimePath(project, resourcePath); - if (WEB_INF_CLASSES_PATH.isPrefixOf(runtimePath)) { - return runtimePath.makeRelativeTo(WEB_INF_CLASSES_PATH); - } - return runtimePath; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/contenttypes/IndeterminateContentDescriber.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/contenttypes/IndeterminateContentDescriber.java deleted file mode 100644 index 79cd8932d0..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/contenttypes/IndeterminateContentDescriber.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2010 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.contenttypes; - -import java.io.InputStream; -import java.io.Reader; -import org.eclipse.core.runtime.QualifiedName; -import org.eclipse.core.runtime.content.IContentDescription; -import org.eclipse.core.runtime.content.ITextContentDescriber; - -/** - * This class simply returns INDETERMINATE for any contents it receives. - * - * It is used currently for org.eclipse.jpt.core.content.baseJpaContent in order - * to make that content type act as an "abstract" content type. - * - * This is in its own package so that it can be excluded from bundle activation in the plugin.xml. - * Content describers must be self-contained and not trigger auto-activation. - */ -public class IndeterminateContentDescriber implements ITextContentDescriber -{ - public int describe(InputStream contents, IContentDescription description) { - return INDETERMINATE; - } - - public int describe(Reader contents, IContentDescription description) { - return INDETERMINATE; - } - - public QualifiedName[] getSupportedOptions() { - return new QualifiedName[0]; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/AbstractJavaResourceNode.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/AbstractJavaResourceNode.java deleted file mode 100644 index f047f4d8ef..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/AbstractJavaResourceNode.java +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.core.resources.IFile; -import org.eclipse.jpt.core.JpaAnnotationProvider; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.utility.internal.model.AbstractModel; -import org.eclipse.jpt.utility.internal.model.CallbackChangeSupport; -import org.eclipse.jpt.utility.internal.model.ChangeSupport; - -/** - * Java resource containment hierarchy - */ -public abstract class AbstractJavaResourceNode - extends AbstractModel - implements JavaResourceNode -{ - protected final JavaResourceNode parent; - - - // ********** constructor ********** - - protected AbstractJavaResourceNode(JavaResourceNode parent) { - super(); - this.checkParent(parent); - this.parent = parent; - } - - - // ********** parent ********** - - protected void checkParent(JavaResourceNode p) { - if (p == null) { - if (this.requiresParent()) { - throw new IllegalArgumentException("'parent' cannot be null"); //$NON-NLS-1$ - } - } else { - if (this.forbidsParent()) { - throw new IllegalArgumentException("'parent' must be null"); //$NON-NLS-1$ - } - } - } - - protected boolean requiresParent() { - return true; - } - - protected boolean forbidsParent() { - return ! this.requiresParent(); // assume 'parent' is not optional - } - - - // ********** change support callback hook ********** - - @Override - protected final ChangeSupport buildChangeSupport() { - return new CallbackChangeSupport(this, this.buildChangeSupportListener()); - } - - private CallbackChangeSupport.Listener buildChangeSupportListener() { - return new CallbackChangeSupport.Listener() { - public void aspectChanged(String aspectName) { - AbstractJavaResourceNode.this.aspectChanged(aspectName); - } - }; - } - - /** - * ignore the aspect name, we notify listeners of *every* change - */ - protected void aspectChanged(@SuppressWarnings("unused") String aspectName) { - this.getRoot().resourceModelChanged(); - } - - - // ********** JavaResourceNode implementation ********** - - /** - * @see org.eclipse.jpt.core.internal.resource.java.source.SourceCompilationUnit#getRoot() - * @see org.eclipse.jpt.core.internal.resource.java.binary.BinaryPackageFragmentRoot#getRoot() - * @see org.eclipse.jpt.core.internal.resource.java.binary.BinaryPersistentTypeCache#getRoot() - */ - public Root getRoot() { - return this.parent.getRoot(); - } - - public IFile getFile() { - return this.getRoot().getFile(); - } - - - // ********** convenience methods ********** - - protected JpaAnnotationProvider getAnnotationProvider() { - return this.getRoot().getAnnotationProvider(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/AssociationOverrideAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/AssociationOverrideAnnotationDefinition.java deleted file mode 100644 index 50711510e4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/AssociationOverrideAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.jpa1.resource.java.binary.BinaryAssociationOverride1_0Annotation; -import org.eclipse.jpt.core.internal.jpa1.resource.java.source.SourceAssociationOverride1_0Annotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.AssociationOverrideAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.AssociationOverride - */ -public final class AssociationOverrideAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new AssociationOverrideAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private AssociationOverrideAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return SourceAssociationOverride1_0Annotation.buildAssociationOverride((JavaResourcePersistentMember) parent, (Member) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryAssociationOverride1_0Annotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return AssociationOverrideAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/AssociationOverridesAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/AssociationOverridesAnnotationDefinition.java deleted file mode 100644 index 1c22e47f57..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/AssociationOverridesAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.jpa1.resource.java.binary.BinaryAssociationOverrides1_0Annotation; -import org.eclipse.jpt.core.internal.jpa1.resource.java.source.SourceAssociationOverrides1_0Annotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.AssociationOverridesAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.AssociationOverrides - */ -public final class AssociationOverridesAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new AssociationOverridesAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private AssociationOverridesAnnotationDefinition() { - super(); - } - - public AssociationOverridesAnnotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceAssociationOverrides1_0Annotation((JavaResourcePersistentMember) parent, (Member) annotatedElement); - } - - public AssociationOverridesAnnotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryAssociationOverrides1_0Annotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return AssociationOverridesAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/AttributeOverrideAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/AttributeOverrideAnnotationDefinition.java deleted file mode 100644 index 9cff112d36..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/AttributeOverrideAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.BinaryAttributeOverrideAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceAttributeOverrideAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.AttributeOverrideAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.AttributeOverride - */ -public final class AttributeOverrideAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new AttributeOverrideAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private AttributeOverrideAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return SourceAttributeOverrideAnnotation.buildAttributeOverride((JavaResourcePersistentMember) parent, (Member) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryAttributeOverrideAnnotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return AttributeOverrideAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/AttributeOverridesAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/AttributeOverridesAnnotationDefinition.java deleted file mode 100644 index 4076edf941..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/AttributeOverridesAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.BinaryAttributeOverridesAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceAttributeOverridesAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.AttributeOverridesAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.AttributeOverrides - */ -public final class AttributeOverridesAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new AttributeOverridesAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private AttributeOverridesAnnotationDefinition() { - super(); - } - - public AttributeOverridesAnnotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceAttributeOverridesAnnotation((JavaResourcePersistentMember) parent, (Member) annotatedElement); - } - - public AttributeOverridesAnnotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryAttributeOverridesAnnotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return AttributeOverridesAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/BasicAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/BasicAnnotationDefinition.java deleted file mode 100644 index d42a2e93b2..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/BasicAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.BinaryBasicAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceBasicAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.BasicAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Attribute; - -/** - * javax.persistence.Basic - */ -public final class BasicAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new BasicAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private BasicAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceBasicAnnotation((JavaResourcePersistentAttribute) parent, (Attribute) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - return new NullBasicAnnotation((JavaResourcePersistentAttribute) parent); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryBasicAnnotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return BasicAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/ColumnAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/ColumnAnnotationDefinition.java deleted file mode 100644 index 5de550cfff..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/ColumnAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.BinaryColumnAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceColumnAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.ColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.Column - */ -public final class ColumnAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new ColumnAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private ColumnAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceColumnAnnotation((JavaResourcePersistentMember) parent, (Member) annotatedElement, SourceColumnAnnotation.MAPPING_DECLARATION_ANNOTATION_ADAPTER); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - return new NullColumnAnnotation(parent); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryColumnAnnotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return ColumnAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/DiscriminatorColumnAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/DiscriminatorColumnAnnotationDefinition.java deleted file mode 100644 index 9aa2710a3a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/DiscriminatorColumnAnnotationDefinition.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.BinaryDiscriminatorColumnAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceDiscriminatorColumnAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.DiscriminatorColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.DiscriminatorColumn - */ -public final class DiscriminatorColumnAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new DiscriminatorColumnAnnotationDefinition(); - - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private DiscriminatorColumnAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceDiscriminatorColumnAnnotation((JavaResourcePersistentType) parent, (Type) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - return new NullDiscriminatorColumnAnnotation((JavaResourcePersistentType) parent); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryDiscriminatorColumnAnnotation((JavaResourcePersistentType) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return DiscriminatorColumnAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/DiscriminatorValueAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/DiscriminatorValueAnnotationDefinition.java deleted file mode 100644 index 3bf48b53a5..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/DiscriminatorValueAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.BinaryDiscriminatorValueAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceDiscriminatorValueAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.DiscriminatorValueAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.DiscriminatorValue - */ -public final class DiscriminatorValueAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new DiscriminatorValueAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private DiscriminatorValueAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceDiscriminatorValueAnnotation((JavaResourcePersistentType) parent, (Type) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - return new NullDiscriminatorValueAnnotation((JavaResourcePersistentType) parent); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryDiscriminatorValueAnnotation((JavaResourcePersistentType) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return DiscriminatorValueAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/EmbeddableAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/EmbeddableAnnotationDefinition.java deleted file mode 100644 index d46f5fb42e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/EmbeddableAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.BinaryEmbeddableAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceEmbeddableAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.EmbeddableAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.Embeddable - */ -public final class EmbeddableAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new EmbeddableAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private EmbeddableAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceEmbeddableAnnotation((JavaResourcePersistentType) parent, (Type) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryEmbeddableAnnotation((JavaResourcePersistentType) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return EmbeddableAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/EmbeddedAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/EmbeddedAnnotationDefinition.java deleted file mode 100644 index 1f8f1894bd..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/EmbeddedAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.BinaryEmbeddedAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceEmbeddedAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.EmbeddedAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Attribute; - -/** - * javax.persistence.Embedded - */ -public final class EmbeddedAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new EmbeddedAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private EmbeddedAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceEmbeddedAnnotation((JavaResourcePersistentAttribute) parent, (Attribute) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - return new NullEmbeddedAnnotation((JavaResourcePersistentAttribute) parent); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryEmbeddedAnnotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return EmbeddedAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/EmbeddedIdAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/EmbeddedIdAnnotationDefinition.java deleted file mode 100644 index 254060b91b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/EmbeddedIdAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.BinaryEmbeddedIdAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceEmbeddedIdAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.EmbeddedIdAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Attribute; - -/** - * javax.persistence.EmbeddedId - */ -public final class EmbeddedIdAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new EmbeddedIdAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private EmbeddedIdAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceEmbeddedIdAnnotation((JavaResourcePersistentAttribute) parent, (Attribute) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryEmbeddedIdAnnotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return EmbeddedIdAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/EntityAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/EntityAnnotationDefinition.java deleted file mode 100644 index be9463071d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/EntityAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.BinaryEntityAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceEntityAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.EntityAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.Entity - */ -public final class EntityAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new EntityAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private EntityAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceEntityAnnotation((JavaResourcePersistentType) parent, (Type) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryEntityAnnotation((JavaResourcePersistentType) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return EntityAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/EnumeratedAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/EnumeratedAnnotationDefinition.java deleted file mode 100644 index a3ff9bee5c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/EnumeratedAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.BinaryEnumeratedAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceEnumeratedAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.EnumeratedAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Attribute; - -/** - * javax.persistence.Enumerated - */ -public final class EnumeratedAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new EnumeratedAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private EnumeratedAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceEnumeratedAnnotation((JavaResourcePersistentAttribute) parent, (Attribute) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - return new NullEnumeratedAnnotation((JavaResourcePersistentAttribute) parent); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryEnumeratedAnnotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return EnumeratedAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/GeneratedValueAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/GeneratedValueAnnotationDefinition.java deleted file mode 100644 index db490cd11a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/GeneratedValueAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.BinaryGeneratedValueAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceGeneratedValueAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.GeneratedValueAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Attribute; - -/** - * javax.persistence.GeneratedValue - */ -public final class GeneratedValueAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new GeneratedValueAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private GeneratedValueAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceGeneratedValueAnnotation((JavaResourcePersistentAttribute) parent, (Attribute) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryGeneratedValueAnnotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return GeneratedValueAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/IdAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/IdAnnotationDefinition.java deleted file mode 100644 index 24a22d40cb..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/IdAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.BinaryIdAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceIdAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.IdAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Attribute; - -/** - * javax.persistence.Id - */ -public final class IdAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new IdAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private IdAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceIdAnnotation((JavaResourcePersistentAttribute) parent, (Attribute) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryIdAnnotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return IdAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/IdClassAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/IdClassAnnotationDefinition.java deleted file mode 100644 index 5df915d4e9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/IdClassAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.BinaryIdClassAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceIdClassAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.IdClassAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.IdClass - */ -public final class IdClassAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new IdClassAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private IdClassAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceIdClassAnnotation((JavaResourcePersistentType) parent, (Type) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryIdClassAnnotation((JavaResourcePersistentType) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return IdClassAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/InheritanceAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/InheritanceAnnotationDefinition.java deleted file mode 100644 index d69eb2b90c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/InheritanceAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.BinaryInheritanceAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceInheritanceAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.InheritanceAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.Inheritance - */ -public final class InheritanceAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new InheritanceAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private InheritanceAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceInheritanceAnnotation((JavaResourcePersistentType) parent, (Type) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - return new NullInheritanceAnnotation((JavaResourcePersistentType) parent); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryInheritanceAnnotation((JavaResourcePersistentType) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return InheritanceAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/JoinColumnAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/JoinColumnAnnotationDefinition.java deleted file mode 100644 index 3886b290aa..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/JoinColumnAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.BinaryJoinColumnAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceJoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.JoinColumn - */ -public final class JoinColumnAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new JoinColumnAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private JoinColumnAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return SourceJoinColumnAnnotation.createJoinColumn((JavaResourcePersistentMember) parent, (Member) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryJoinColumnAnnotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return JoinColumnAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/JoinColumnsAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/JoinColumnsAnnotationDefinition.java deleted file mode 100644 index a68ca888a6..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/JoinColumnsAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.BinaryJoinColumnsAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceJoinColumnsAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.JoinColumnsAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.JoinColumns - */ -public final class JoinColumnsAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new JoinColumnsAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private JoinColumnsAnnotationDefinition() { - super(); - } - - public JoinColumnsAnnotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceJoinColumnsAnnotation((JavaResourcePersistentMember) parent, (Member) annotatedElement); - } - - public JoinColumnsAnnotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryJoinColumnsAnnotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return JoinColumnsAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/JoinTableAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/JoinTableAnnotationDefinition.java deleted file mode 100644 index fd30d5041a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/JoinTableAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.BinaryJoinTableAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceJoinTableAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.JoinTableAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.JoinTable - */ -public final class JoinTableAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new JoinTableAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private JoinTableAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceJoinTableAnnotation((JavaResourcePersistentMember) parent, (Member) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - return new NullJoinTableAnnotation(parent); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryJoinTableAnnotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return JoinTableAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/LobAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/LobAnnotationDefinition.java deleted file mode 100644 index 241312d2c1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/LobAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.BinaryLobAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceLobAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.LobAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Attribute; - -/** - * javax.persistence.Lob - */ -public final class LobAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new LobAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private LobAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceLobAnnotation((JavaResourcePersistentAttribute) parent, (Attribute) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryLobAnnotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return LobAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/ManyToManyAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/ManyToManyAnnotationDefinition.java deleted file mode 100644 index 0fae712ccd..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/ManyToManyAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.BinaryManyToManyAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceManyToManyAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.ManyToManyAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Attribute; - -/** - * javax.persistence.ManyToMany - */ -public final class ManyToManyAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new ManyToManyAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private ManyToManyAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceManyToManyAnnotation((JavaResourcePersistentAttribute) parent, (Attribute) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryManyToManyAnnotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return ManyToManyAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/ManyToOneAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/ManyToOneAnnotationDefinition.java deleted file mode 100644 index db3b4663fe..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/ManyToOneAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.BinaryManyToOneAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceManyToOneAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.ManyToOneAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Attribute; - -/** - * javax.persistence.ManyToOne - */ -public final class ManyToOneAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new ManyToOneAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private ManyToOneAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceManyToOneAnnotation((JavaResourcePersistentAttribute) parent, (Attribute) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryManyToOneAnnotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return ManyToOneAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/MapKeyAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/MapKeyAnnotationDefinition.java deleted file mode 100644 index a6caec3309..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/MapKeyAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.BinaryMapKeyAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceMapKeyAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.MapKeyAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Attribute; - -/** - * javax.persistence.MapKey - */ -public final class MapKeyAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new MapKeyAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private MapKeyAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceMapKeyAnnotation((JavaResourcePersistentAttribute) parent, (Attribute) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryMapKeyAnnotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return MapKeyAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/MappedSuperclassAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/MappedSuperclassAnnotationDefinition.java deleted file mode 100644 index 844ac6aaed..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/MappedSuperclassAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.BinaryMappedSuperclassAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceMappedSuperclassAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.resource.java.MappedSuperclassAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.MappedSuperclass - */ -public final class MappedSuperclassAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new MappedSuperclassAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private MappedSuperclassAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceMappedSuperclassAnnotation((JavaResourcePersistentType) parent, (Type) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryMappedSuperclassAnnotation((JavaResourcePersistentType) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return MappedSuperclassAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NamedNativeQueriesAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NamedNativeQueriesAnnotationDefinition.java deleted file mode 100644 index d503efdb6a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NamedNativeQueriesAnnotationDefinition.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.BinaryNamedNativeQueriesAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceNamedNativeQueriesAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.NamedNativeQueriesAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.NamedNativeQueries - */ -public final class NamedNativeQueriesAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new NamedNativeQueriesAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private NamedNativeQueriesAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceNamedNativeQueriesAnnotation(parent, (Type) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryNamedNativeQueriesAnnotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return NamedNativeQueriesAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NamedNativeQueryAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NamedNativeQueryAnnotationDefinition.java deleted file mode 100644 index c8e63fc6a1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NamedNativeQueryAnnotationDefinition.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.BinaryNamedNativeQueryAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceNamedNativeQueryAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.NamedNativeQueryAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.NamedNativeQuery - */ -public final class NamedNativeQueryAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new NamedNativeQueryAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private NamedNativeQueryAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return SourceNamedNativeQueryAnnotation.createNamedNativeQuery(parent, (Type) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryNamedNativeQueryAnnotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return NamedNativeQueryAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NamedQueriesAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NamedQueriesAnnotationDefinition.java deleted file mode 100644 index 17b84bc2b3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NamedQueriesAnnotationDefinition.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.jpa1.resource.java.binary.BinaryNamedQueries1_0Annotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceNamedQueries1_0Annotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.NamedQueriesAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.NamedQueries - */ -public final class NamedQueriesAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new NamedQueriesAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private NamedQueriesAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceNamedQueries1_0Annotation(parent, (Type) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryNamedQueries1_0Annotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return NamedQueriesAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NamedQueryAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NamedQueryAnnotationDefinition.java deleted file mode 100644 index 0f16c9c625..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NamedQueryAnnotationDefinition.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.jpa1.resource.java.binary.BinaryNamedQuery1_0Annotation; -import org.eclipse.jpt.core.internal.jpa1.resource.java.source.SourceNamedQuery1_0Annotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.NamedQueryAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.NamedQuery - */ -public final class NamedQueryAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new NamedQueryAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private NamedQueryAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceNamedQuery1_0Annotation(parent, (Type) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryNamedQuery1_0Annotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return NamedQueryAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullAnnotation.java deleted file mode 100644 index f2036b030f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullAnnotation.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourceCompilationUnit; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * Simplify null annotation classes - */ -public abstract class NullAnnotation - extends AbstractJavaResourceNode - implements Annotation -{ - - protected NullAnnotation(JavaResourceNode parent) { - super(parent); - } - - public void initialize(CompilationUnit astRoot) { - // do nothing - } - - public org.eclipse.jdt.core.dom.Annotation getAstAnnotation(CompilationUnit astRoot) { - return null; - } - - public JavaResourceCompilationUnit getJavaResourceCompilationUnit() { - throw new UnsupportedOperationException(); - } - - public void newAnnotation() { - throw new UnsupportedOperationException(); - } - - public void removeAnnotation() { - throw new UnsupportedOperationException(); - } - - public TextRange getTextRange(CompilationUnit astRoot) { - return null; - } - - public void synchronizeWith(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - /** - * Convenience method: Cast the annotation's parent to a - * persistent member. - */ - protected JavaResourcePersistentMember getMember() { - return (JavaResourcePersistentMember) this.parent; - } - - /** - * Convenience method: Add the type or attribute's annotation - * and return it. - * Pre-condition: The annotation's parent must be a persistent member - * (type or attribute). - */ - protected Annotation addAnnotation() { - return this.getMember().addAnnotation(this.getAnnotationName()); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullAttributeOverrideColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullAttributeOverrideColumnAnnotation.java deleted file mode 100644 index 85f0c6fe08..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullAttributeOverrideColumnAnnotation.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpt.core.resource.java.AttributeOverrideAnnotation; -import org.eclipse.jpt.core.resource.java.ColumnAnnotation; - -/** - * javax.persistence.Column - */ -public class NullAttributeOverrideColumnAnnotation - extends NullColumnAnnotation -{ - public NullAttributeOverrideColumnAnnotation(AttributeOverrideAnnotation parent) { - super(parent); - } - - private AttributeOverrideAnnotation getAttributeOverrideAnnotation() { - return (AttributeOverrideAnnotation) this.parent; - } - - @Override - protected ColumnAnnotation addAnnotation() { - return this.getAttributeOverrideAnnotation().addColumn(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullBaseColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullBaseColumnAnnotation.java deleted file mode 100644 index 477b7f8da0..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullBaseColumnAnnotation.java +++ /dev/null @@ -1,113 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.BaseColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.Column - * javax.persistence.JoinColumn - */ -public abstract class NullBaseColumnAnnotation - extends NullNamedColumnAnnotation - implements BaseColumnAnnotation -{ - protected NullBaseColumnAnnotation(JavaResourceNode parent) { - super(parent); - } - - @Override - protected BaseColumnAnnotation addAnnotation() { - return (BaseColumnAnnotation) super.addAnnotation(); - } - - // ***** table - public String getTable() { - return null; - } - - public void setTable(String table) { - if (table != null) { - this.addAnnotation().setTable(table); - } - } - - public TextRange getTableTextRange(CompilationUnit astRoot) { - return null; - } - - public boolean tableTouches(int pos, CompilationUnit astRoot) { - return false; - } - - // ***** unique - public Boolean getUnique() { - return null; - } - - public void setUnique(Boolean unique) { - if (unique != null) { - this.addAnnotation().setUnique(unique); - } - } - - public TextRange getUniqueTextRange(CompilationUnit astRoot) { - return null; - } - - // ***** updatable - public Boolean getUpdatable() { - return null; - } - - public void setUpdatable(Boolean updatable) { - if (updatable != null) { - this.addAnnotation().setUpdatable(updatable); - } - } - - public TextRange getUpdatableTextRange(CompilationUnit astRoot) { - return null; - } - - // ***** insertable - public Boolean getInsertable() { - return null; - } - - public void setInsertable(Boolean insertable) { - if (insertable != null) { - this.addAnnotation().setInsertable(insertable); - } - } - - public TextRange getInsertableTextRange(CompilationUnit astRoot) { - return null; - } - - // ***** nullable - public Boolean getNullable() { - return null; - } - - public void setNullable(Boolean nullable) { - if (nullable != null) { - this.addAnnotation().setNullable(nullable); - } - } - - public TextRange getNullableTextRange(CompilationUnit astRoot) { - return null; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullBaseTableAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullBaseTableAnnotation.java deleted file mode 100644 index 93160b0452..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullBaseTableAnnotation.java +++ /dev/null @@ -1,127 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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 java.util.ListIterator; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.BaseTableAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.UniqueConstraintAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator; - -/** - * javax.persistence.Table - * javax.persistence.JoinTable - */ -public abstract class NullBaseTableAnnotation - extends NullAnnotation - implements BaseTableAnnotation -{ - protected NullBaseTableAnnotation(JavaResourceNode parent) { - super(parent); - } - - @Override - protected BaseTableAnnotation addAnnotation() { - return (BaseTableAnnotation) super.addAnnotation(); - } - - public boolean isSpecified() { - return false; - } - - // ***** name - public String getName() { - return null; - } - - public void setName(String name) { - if (name != null) { - this.addAnnotation().setName(name); - } - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - return null; - } - - public boolean nameTouches(int pos, CompilationUnit astRoot) { - return false; - } - - // ***** schema - public String getSchema() { - return null; - } - - public void setSchema(String schema) { - if (schema != null) { - this.addAnnotation().setSchema(schema); - } - } - - public TextRange getSchemaTextRange(CompilationUnit astRoot) { - return null; - } - - public boolean schemaTouches(int pos, CompilationUnit astRoot) { - return false; - } - - // ***** catalog - public String getCatalog() { - return null; - } - - public void setCatalog(String catalog) { - if (catalog != null) { - this.addAnnotation().setCatalog(catalog); - } - } - - public TextRange getCatalogTextRange(CompilationUnit astRoot) { - return null; - } - - public boolean catalogTouches(int pos, CompilationUnit astRoot) { - return false; - } - - // ***** unique constraints - public ListIterator<UniqueConstraintAnnotation> uniqueConstraints() { - return EmptyListIterator.instance(); - } - - public int uniqueConstraintsSize() { - return 0; - } - - public UniqueConstraintAnnotation uniqueConstraintAt(int index) { - throw new UnsupportedOperationException(); - } - - public int indexOfUniqueConstraint(UniqueConstraintAnnotation uniqueConstraint) { - throw new UnsupportedOperationException(); - } - - public UniqueConstraintAnnotation addUniqueConstraint(int index) { - return this.addAnnotation().addUniqueConstraint(index); - } - - public void moveUniqueConstraint(int targetIndex, int sourceIndex) { - throw new UnsupportedOperationException(); - } - - public void removeUniqueConstraint(int index) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullBasicAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullBasicAnnotation.java deleted file mode 100644 index 0e16de1e07..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullBasicAnnotation.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.BasicAnnotation; -import org.eclipse.jpt.core.resource.java.FetchType; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * null javax.persistence.Basic - */ -public final class NullBasicAnnotation - extends NullAnnotation - implements BasicAnnotation -{ - protected NullBasicAnnotation(JavaResourcePersistentAttribute parent) { - super(parent); - } - - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - protected BasicAnnotation addAnnotation() { - return (BasicAnnotation) super.addAnnotation(); - } - - - // ***** fetch - - public FetchType getFetch() { - return null; - } - - public void setFetch(FetchType fetch) { - if (fetch != null) { - this.addAnnotation().setFetch(fetch); - } - } - - public TextRange getFetchTextRange(CompilationUnit astRoot) { - return null; - } - - - // ***** optional - - public Boolean getOptional() { - return null; - } - - public void setOptional(Boolean optional) { - if (optional != null) { - this.addAnnotation().setOptional(optional); - } - } - - public TextRange getOptionalTextRange(CompilationUnit astRoot) { - return null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullColumnAnnotation.java deleted file mode 100644 index 3bf5452a0b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullColumnAnnotation.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.ColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.Column - */ -public class NullColumnAnnotation - extends NullBaseColumnAnnotation - implements ColumnAnnotation -{ - public NullColumnAnnotation(JavaResourceNode parent) { - super(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - protected ColumnAnnotation addAnnotation() { - return (ColumnAnnotation) super.addAnnotation(); - } - - // ***** length - public Integer getLength() { - return null; - } - - public void setLength(Integer length) { - if (length != null) { - this.addAnnotation().setLength(length); - } - } - - public TextRange getLengthTextRange(CompilationUnit astRoot) { - return null; - } - - // ***** scale - public Integer getScale() { - return null; - } - - public void setScale(Integer scale) { - if (scale != null) { - this.addAnnotation().setScale(scale); - } - } - - public TextRange getScaleTextRange(CompilationUnit astRoot) { - return null; - } - - // ***** precision - public Integer getPrecision() { - return null; - } - - public void setPrecision(Integer precision) { - if (precision != null) { - this.addAnnotation().setPrecision(precision); - } - } - - public TextRange getPrecisionTextRange(CompilationUnit astRoot) { - return null; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullDiscriminatorColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullDiscriminatorColumnAnnotation.java deleted file mode 100644 index 126ad60814..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullDiscriminatorColumnAnnotation.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpt.core.resource.java.DiscriminatorColumnAnnotation; -import org.eclipse.jpt.core.resource.java.DiscriminatorType; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; - -/** - * javax.persistence.DiscriminatorColumn - */ -public final class NullDiscriminatorColumnAnnotation - extends NullNamedColumnAnnotation - implements DiscriminatorColumnAnnotation -{ - public NullDiscriminatorColumnAnnotation(JavaResourcePersistentType parent) { - super(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - protected DiscriminatorColumnAnnotation addAnnotation() { - return (DiscriminatorColumnAnnotation) super.addAnnotation(); - } - - // ***** discriminator type - public DiscriminatorType getDiscriminatorType() { - return null; - } - - public void setDiscriminatorType(DiscriminatorType discriminatorType) { - if (discriminatorType != null) { - this.addAnnotation().setDiscriminatorType(discriminatorType); - } - } - - // ***** length - public Integer getLength() { - return null; - } - - public void setLength(Integer length) { - if (length != null) { - this.addAnnotation().setLength(length); - } - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullDiscriminatorValueAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullDiscriminatorValueAnnotation.java deleted file mode 100644 index 7a68d3d2dc..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullDiscriminatorValueAnnotation.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.DiscriminatorValueAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.DiscriminatorValue - */ -public final class NullDiscriminatorValueAnnotation - extends NullAnnotation - implements DiscriminatorValueAnnotation -{ - - protected NullDiscriminatorValueAnnotation(JavaResourcePersistentType parent) { - super(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - protected DiscriminatorValueAnnotation addAnnotation() { - return (DiscriminatorValueAnnotation) super.addAnnotation(); - } - - // ***** value - public String getValue() { - return null; - } - - public void setValue(String value) { - if (value != null) { - this.addAnnotation().setValue(value); - } - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return null; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullEmbeddedAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullEmbeddedAnnotation.java deleted file mode 100644 index 029d2a6ffd..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullEmbeddedAnnotation.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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.jpt.core.resource.java.EmbeddedAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; - -/** - * javax.persistence.Embedded - */ -public final class NullEmbeddedAnnotation - extends NullAnnotation - implements EmbeddedAnnotation -{ - protected NullEmbeddedAnnotation(JavaResourcePersistentAttribute parent) { - super(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullEnumeratedAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullEnumeratedAnnotation.java deleted file mode 100644 index 1e45dd51a9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullEnumeratedAnnotation.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.EnumType; -import org.eclipse.jpt.core.resource.java.EnumeratedAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.Enumerated - */ -public final class NullEnumeratedAnnotation - extends NullAnnotation - implements EnumeratedAnnotation -{ - protected NullEnumeratedAnnotation(JavaResourcePersistentAttribute parent) { - super(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - protected EnumeratedAnnotation addAnnotation() { - return (EnumeratedAnnotation) super.addAnnotation(); - } - - // ***** value - public EnumType getValue() { - return null; - } - - public void setValue(EnumType value) { - if (value != null) { - this.addAnnotation().setValue(value); - } - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return null; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullInheritanceAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullInheritanceAnnotation.java deleted file mode 100644 index a4130b1b6e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullInheritanceAnnotation.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.InheritanceAnnotation; -import org.eclipse.jpt.core.resource.java.InheritanceType; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.Inheritance - */ -public final class NullInheritanceAnnotation - extends NullAnnotation - implements InheritanceAnnotation -{ - protected NullInheritanceAnnotation(JavaResourcePersistentType parent) { - super(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - protected InheritanceAnnotation addAnnotation() { - return (InheritanceAnnotation) super.addAnnotation(); - } - - // ***** strategy - public InheritanceType getStrategy() { - return null; - } - - public void setStrategy(InheritanceType strategy) { - if (strategy != null) { - this.addAnnotation().setStrategy(strategy); - } - } - - public TextRange getStrategyTextRange(CompilationUnit astRoot) { - return null; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullJoinColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullJoinColumnAnnotation.java deleted file mode 100644 index 32c74fa036..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullJoinColumnAnnotation.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.JoinColumn - */ -public final class NullJoinColumnAnnotation - extends NullBaseColumnAnnotation - implements JoinColumnAnnotation -{ - public NullJoinColumnAnnotation(JavaResourceNode parent) { - super(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - protected JoinColumnAnnotation addAnnotation() { - throw new UnsupportedOperationException(); - } - - // ***** referenced column name - public String getReferencedColumnName() { - return null; - } - - public void setReferencedColumnName(String referencedColumnName) { - throw new UnsupportedOperationException(); - } - - public TextRange getReferencedColumnNameTextRange(CompilationUnit astRoot) { - return null; - } - - public boolean referencedColumnNameTouches(int pos, CompilationUnit astRoot) { - return false; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullJoinTableAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullJoinTableAnnotation.java deleted file mode 100644 index 2f678c8f37..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullJoinTableAnnotation.java +++ /dev/null @@ -1,99 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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 java.util.ListIterator; - -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JoinTableAnnotation; -import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator; - -/** - * javax.persistence.JoinTable - */ -public class NullJoinTableAnnotation - extends NullBaseTableAnnotation - implements JoinTableAnnotation -{ - public NullJoinTableAnnotation(JavaResourceNode parent) { - super(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - protected JoinTableAnnotation addAnnotation() { - return (JoinTableAnnotation) super.addAnnotation(); - } - - // ***** join columns - public ListIterator<JoinColumnAnnotation> joinColumns() { - return EmptyListIterator.instance(); - } - - public int joinColumnsSize() { - return 0; - } - - public JoinColumnAnnotation joinColumnAt(int index) { - return null; - } - - public int indexOfJoinColumn(JoinColumnAnnotation joinColumn) { - throw new UnsupportedOperationException(); - } - - public JoinColumnAnnotation addJoinColumn(int index) { - // the JoinTable annotation is missing, add both it and a join column at the same time - return this.addAnnotation().addJoinColumn(index); - } - - public void moveJoinColumn(int targetIndex, int sourceIndex) { - throw new UnsupportedOperationException(); - } - - public void removeJoinColumn(int index) { - throw new UnsupportedOperationException(); - } - - // ***** inverse join columns - public ListIterator<JoinColumnAnnotation> inverseJoinColumns() { - return EmptyListIterator.instance(); - } - - public int inverseJoinColumnsSize() { - return 0; - } - - public JoinColumnAnnotation inverseJoinColumnAt(int index) { - return null; - } - - public int indexOfInverseJoinColumn(JoinColumnAnnotation joinColumn) { - throw new UnsupportedOperationException(); - } - - public JoinColumnAnnotation addInverseJoinColumn(int index) { - // the JoinTable annotation is missing, add both it and a join column at the same time - return this.addAnnotation().addInverseJoinColumn(index); - } - - public void moveInverseJoinColumn(int targetIndex, int sourceIndex) { - throw new UnsupportedOperationException(); - } - - public void removeInverseJoinColumn(int index) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullNamedColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullNamedColumnAnnotation.java deleted file mode 100644 index 0ae2b8cf38..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullNamedColumnAnnotation.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NamedColumnAnnotation; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.Column - * javax.persistence.JoinColumn - * javax.persistence.DiscriminatorColumn - * javax.persistence.PrimaryKeyJoinColumn. - */ -public abstract class NullNamedColumnAnnotation - extends NullAnnotation - implements NamedColumnAnnotation -{ - protected NullNamedColumnAnnotation(JavaResourceNode parent) { - super(parent); - } - - public boolean isSpecified() { - return false; - } - - @Override - protected NamedColumnAnnotation addAnnotation() { - return (NamedColumnAnnotation) super.addAnnotation(); - } - - // ***** name - public String getName() { - return null; - } - - public void setName(String name) { - if (name != null) { - this.addAnnotation().setName(name); - } - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - return null; - } - - public boolean nameTouches(int pos, CompilationUnit astRoot) { - return false; - } - - // ***** column definition - public String getColumnDefinition() { - return null; - } - - public void setColumnDefinition(String columnDefinition) { - if (columnDefinition != null) { - this.addAnnotation().setColumnDefinition(columnDefinition); - } - } - - public TextRange getColumnDefinitionTextRange(CompilationUnit astRoot) { - return null; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullOneToManyAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullOneToManyAnnotation.java deleted file mode 100644 index e8970e7665..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullOneToManyAnnotation.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2010 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.dom.CompilationUnit; -import org.eclipse.jpt.core.jpa2.resource.java.OneToMany2_0Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.OneToMany - */ -public final class NullOneToManyAnnotation - extends NullOwnableRelationshipMappingAnnotation - implements OneToMany2_0Annotation -{ - public NullOneToManyAnnotation(JavaResourcePersistentAttribute parent) { - super(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - - // ********** JPA 2.0 - OrphanRemovable2_0 implementation ********** - public Boolean getOrphanRemoval() { - return null; - } - - public void setOrphanRemoval(Boolean orphanRemoval) { - if (orphanRemoval != null) { - this.addAnnotation().setOrphanRemoval(orphanRemoval); - } - } - - public TextRange getOrphanRemovalTextRange(CompilationUnit astRoot) { - return null; - } - - @Override - protected OneToMany2_0Annotation addAnnotation() { - return (OneToMany2_0Annotation) super.addAnnotation(); - } - - // ***** cascade detach - JPA 2.0 - - public boolean isCascadeDetach() { - return false; - } - - public void setCascadeDetach(boolean detach) { - this.addAnnotation().setCascadeDetach(detach); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullOneToOneAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullOneToOneAnnotation.java deleted file mode 100644 index 2cd39e4298..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullOneToOneAnnotation.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2010 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.dom.CompilationUnit; -import org.eclipse.jpt.core.jpa2.resource.java.OneToOne2_0Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.OneToOne - */ -public final class NullOneToOneAnnotation - extends NullOwnableRelationshipMappingAnnotation - implements OneToOne2_0Annotation -{ - public NullOneToOneAnnotation(JavaResourcePersistentAttribute parent) { - super(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - protected OneToOne2_0Annotation addAnnotation() { - return (OneToOne2_0Annotation) super.addAnnotation(); - } - - // ***** optional - public Boolean getOptional() { - return null; - } - - public void setOptional(Boolean optional) { - if (optional != null) { - this.addAnnotation().setOptional(optional); - } - } - - public TextRange getOptionalTextRange(CompilationUnit astRoot) { - return null; - } - - // ********** JPA 2.0 - OrphanRemovable2_0 implementation ********** - public Boolean getOrphanRemoval() { - return null; - } - - public void setOrphanRemoval(Boolean orphanRemoval) { - if (orphanRemoval != null) { - this.addAnnotation().setOrphanRemoval(orphanRemoval); - } - } - - public TextRange getOrphanRemovalTextRange(CompilationUnit astRoot) { - return null; - } - - // ***** cascade detach - JPA 2.0 - - public boolean isCascadeDetach() { - return false; - } - - public void setCascadeDetach(boolean detach) { - this.addAnnotation().setCascadeDetach(detach); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullOwnableRelationshipMappingAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullOwnableRelationshipMappingAnnotation.java deleted file mode 100644 index dd29a044d7..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullOwnableRelationshipMappingAnnotation.java +++ /dev/null @@ -1,156 +0,0 @@ -/******************************************************************************* - * 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.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.FetchType; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.OwnableRelationshipMappingAnnotation; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.OneToMany - * javax.persistence.OneToOne - */ -public abstract class NullOwnableRelationshipMappingAnnotation - extends NullAnnotation - implements OwnableRelationshipMappingAnnotation -{ - protected NullOwnableRelationshipMappingAnnotation(JavaResourcePersistentAttribute parent) { - super(parent); - } - - - @Override - protected OwnableRelationshipMappingAnnotation addAnnotation() { - return (OwnableRelationshipMappingAnnotation) super.addAnnotation(); - } - - - // ***** target entity - - public String getTargetEntity() { - return null; - } - - public void setTargetEntity(String targetEntity) { - if (targetEntity != null) { - this.addAnnotation().setTargetEntity(targetEntity); - } - } - - public TextRange getTargetEntityTextRange(CompilationUnit astRoot) { - return null; - } - - - // ***** fully-qualified target entity class name - - public String getFullyQualifiedTargetEntityClassName() { - return null; - } - - - // ***** mapped by - - public String getMappedBy() { - return null; - } - - public void setMappedBy(String mappedBy) { - if (mappedBy != null) { - this.addAnnotation().setMappedBy(mappedBy); - } - } - - public TextRange getMappedByTextRange(CompilationUnit astRoot) { - return null; - } - - public boolean mappedByTouches(int pos, CompilationUnit astRoot) { - return false; - } - - - // ***** fetch - - public FetchType getFetch() { - return null; - } - - public void setFetch(FetchType fetch) { - if (fetch != null) { - this.addAnnotation().setFetch(fetch); - } - } - - public TextRange getFetchTextRange(CompilationUnit astRoot) { - return null; - } - - - // ***** cascade all - - public boolean isCascadeAll() { - return false; - } - - public void setCascadeAll(boolean all) { - this.addAnnotation().setCascadeAll(all); - } - - - // ***** cascade merge - - public boolean isCascadeMerge() { - return false; - } - - public void setCascadeMerge(boolean merge) { - this.addAnnotation().setCascadeMerge(merge); - } - - - // ***** cascade persist - - public boolean isCascadePersist() { - return false; - } - - public void setCascadePersist(boolean persist) { - this.addAnnotation().setCascadePersist(persist); - } - - - // ***** cascade refresh - - public boolean isCascadeRefresh() { - return false; - } - - public void setCascadeRefresh(boolean refresh) { - this.addAnnotation().setCascadeRefresh(refresh); - } - - - // ***** cascade remove - - public boolean isCascadeRemove() { - return false; - } - - public void setCascadeRemove(boolean remove) { - this.addAnnotation().setCascadeRemove(remove); - } - - public TextRange getCascadeTextRange(CompilationUnit astRoot) { - return null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullPrimaryKeyJoinColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullPrimaryKeyJoinColumnAnnotation.java deleted file mode 100644 index a2ff594c03..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullPrimaryKeyJoinColumnAnnotation.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NamedColumnAnnotation; -import org.eclipse.jpt.core.resource.java.PrimaryKeyJoinColumnAnnotation; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.PrimaryKeyJoinColumn - */ -public final class NullPrimaryKeyJoinColumnAnnotation - extends NullNamedColumnAnnotation - implements PrimaryKeyJoinColumnAnnotation -{ - public NullPrimaryKeyJoinColumnAnnotation(JavaResourceNode parent) { - super(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - protected NamedColumnAnnotation addAnnotation() { - throw new UnsupportedOperationException(); - } - - // ***** referenced column name - public String getReferencedColumnName() { - return null; - } - - public void setReferencedColumnName(String referencedColumnName) { - throw new UnsupportedOperationException(); - } - - public TextRange getReferencedColumnNameTextRange(CompilationUnit astRoot) { - return null; - } - - public boolean referencedColumnNameTouches(int pos, CompilationUnit astRoot) { - return false; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullTableAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullTableAnnotation.java deleted file mode 100644 index 7e829e2fe5..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullTableAnnotation.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.resource.java.TableAnnotation; - -/** - * javax.persistence.Table - */ -public final class NullTableAnnotation - extends NullBaseTableAnnotation - implements TableAnnotation -{ - protected NullTableAnnotation(JavaResourcePersistentType parent) { - super(parent); - } - - @Override - protected TableAnnotation addAnnotation() { - return (TableAnnotation) super.addAnnotation(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullTemporalAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullTemporalAnnotation.java deleted file mode 100644 index ec38b00a84..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullTemporalAnnotation.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.TemporalAnnotation; -import org.eclipse.jpt.core.resource.java.TemporalType; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.Temporal - */ -public final class NullTemporalAnnotation - extends NullAnnotation - implements TemporalAnnotation -{ - protected NullTemporalAnnotation(JavaResourcePersistentAttribute parent) { - super(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - protected TemporalAnnotation addAnnotation() { - return (TemporalAnnotation) super.addAnnotation(); - } - - - // ********** TemporalAnnotation implementation ********** - - // ***** value - public TemporalType getValue() { - return null; - } - - public void setValue(TemporalType value) { - if (value != null) { - this.addAnnotation().setValue(value); - } - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return null; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/OneToManyAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/OneToManyAnnotationDefinition.java deleted file mode 100644 index f577b6c278..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/OneToManyAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.BinaryOneToManyAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceOneToManyAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.OneToManyAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Attribute; - -/** - * javax.persistence.OneToMany - */ -public final class OneToManyAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new OneToManyAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private OneToManyAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceOneToManyAnnotation((JavaResourcePersistentAttribute) parent, (Attribute) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - return new NullOneToManyAnnotation((JavaResourcePersistentAttribute) parent); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryOneToManyAnnotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return OneToManyAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/OneToOneAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/OneToOneAnnotationDefinition.java deleted file mode 100644 index 64892f8892..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/OneToOneAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.OneToOneAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Attribute; - -/** - * javax.persistence.OneToOne - */ -public final 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(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceOneToOneAnnotation((JavaResourcePersistentAttribute) parent, (Attribute) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - return new NullOneToOneAnnotation((JavaResourcePersistentAttribute) parent); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryOneToOneAnnotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return OneToOneAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/OrderByAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/OrderByAnnotationDefinition.java deleted file mode 100644 index 46bc3accb4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/OrderByAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.BinaryOrderByAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceOrderByAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.OrderByAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Attribute; - -/** - * javax.persistence.OrderBy - */ -public final class OrderByAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new OrderByAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private OrderByAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceOrderByAnnotation((JavaResourcePersistentAttribute) parent, (Attribute) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryOrderByAnnotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return OrderByAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/PrimaryKeyJoinColumnAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/PrimaryKeyJoinColumnAnnotationDefinition.java deleted file mode 100644 index e2ecdc3bdb..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/PrimaryKeyJoinColumnAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.BinaryPrimaryKeyJoinColumnAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourcePrimaryKeyJoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.PrimaryKeyJoinColumnAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.PrimaryKeyJoinColumn - */ -public final class PrimaryKeyJoinColumnAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new PrimaryKeyJoinColumnAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private PrimaryKeyJoinColumnAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return SourcePrimaryKeyJoinColumnAnnotation.createPrimaryKeyJoinColumn((JavaResourcePersistentMember) parent, (Member) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryPrimaryKeyJoinColumnAnnotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/PrimaryKeyJoinColumnsAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/PrimaryKeyJoinColumnsAnnotationDefinition.java deleted file mode 100644 index a88725f801..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/PrimaryKeyJoinColumnsAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.BinaryPrimaryKeyJoinColumnsAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourcePrimaryKeyJoinColumnsAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.PrimaryKeyJoinColumnsAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.PrimaryKeyJoinColumns - */ -public final class PrimaryKeyJoinColumnsAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new PrimaryKeyJoinColumnsAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private PrimaryKeyJoinColumnsAnnotationDefinition() { - super(); - } - - public PrimaryKeyJoinColumnsAnnotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourcePrimaryKeyJoinColumnsAnnotation((JavaResourcePersistentMember) parent, (Member) annotatedElement); - } - - public PrimaryKeyJoinColumnsAnnotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryPrimaryKeyJoinColumnsAnnotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/SecondaryTableAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/SecondaryTableAnnotationDefinition.java deleted file mode 100644 index 173c92027e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/SecondaryTableAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.BinarySecondaryTableAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceSecondaryTableAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.SecondaryTableAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.SecondaryTable - */ -public final class SecondaryTableAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new SecondaryTableAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private SecondaryTableAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return SourceSecondaryTableAnnotation.createSecondaryTable((JavaResourcePersistentMember) parent, (Member) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinarySecondaryTableAnnotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return SecondaryTableAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/SecondaryTablesAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/SecondaryTablesAnnotationDefinition.java deleted file mode 100644 index 2fceff310b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/SecondaryTablesAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.BinarySecondaryTablesAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceSecondaryTablesAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.resource.java.SecondaryTablesAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.SecondaryTables - */ -public final class SecondaryTablesAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new SecondaryTablesAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private SecondaryTablesAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceSecondaryTablesAnnotation((JavaResourcePersistentType) parent, (Member) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinarySecondaryTablesAnnotation((JavaResourcePersistentType) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return SecondaryTablesAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/SequenceGeneratorAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/SequenceGeneratorAnnotationDefinition.java deleted file mode 100644 index a2a549b431..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/SequenceGeneratorAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.jpa1.resource.java.binary.BinarySequenceGenerator1_0Annotation; -import org.eclipse.jpt.core.internal.jpa1.resource.java.source.SourceSequenceGenerator1_0Annotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.SequenceGeneratorAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.SequenceGenerator - */ -public final class SequenceGeneratorAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new SequenceGeneratorAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - protected SequenceGeneratorAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceSequenceGenerator1_0Annotation((JavaResourcePersistentMember) parent, (Member) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinarySequenceGenerator1_0Annotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return SequenceGeneratorAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/TableAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/TableAnnotationDefinition.java deleted file mode 100644 index 7c90087be1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/TableAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.BinaryTableAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceTableAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.resource.java.TableAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.Table - */ -public final class TableAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new TableAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private TableAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceTableAnnotation((JavaResourcePersistentType) parent, (Type) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - return new NullTableAnnotation((JavaResourcePersistentType) parent); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryTableAnnotation((JavaResourcePersistentType) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return TableAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/TableGeneratorAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/TableGeneratorAnnotationDefinition.java deleted file mode 100644 index e272f037eb..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/TableGeneratorAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.BinaryTableGeneratorAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceTableGeneratorAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.TableGeneratorAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.TableGenerator - */ -public final class TableGeneratorAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new TableGeneratorAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private TableGeneratorAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceTableGeneratorAnnotation((JavaResourcePersistentMember) parent, (Member) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryTableGeneratorAnnotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return TableGeneratorAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/TemporalAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/TemporalAnnotationDefinition.java deleted file mode 100644 index ed951dc1d4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/TemporalAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.BinaryTemporalAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceTemporalAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.TemporalAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Attribute; - -/** - * javax.persistence.Temporal - */ -public final class TemporalAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new TemporalAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private TemporalAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceTemporalAnnotation((JavaResourcePersistentAttribute) parent, (Attribute) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - return new NullTemporalAnnotation((JavaResourcePersistentAttribute) parent); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryTemporalAnnotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return TemporalAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/TransientAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/TransientAnnotationDefinition.java deleted file mode 100644 index 414a2c6ac3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/TransientAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.BinaryTransientAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceTransientAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.TransientAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Attribute; - -/** - * javax.persistence.Transient - */ -public final class TransientAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new TransientAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private TransientAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceTransientAnnotation((JavaResourcePersistentAttribute) parent, (Attribute) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryTransientAnnotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return TransientAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/VersionAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/VersionAnnotationDefinition.java deleted file mode 100644 index 1147e36a4a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/VersionAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.BinaryVersionAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceVersionAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.VersionAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Attribute; - -/** - * javax.persistence.Version - */ -public final class VersionAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new VersionAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private VersionAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceVersionAnnotation((JavaResourcePersistentAttribute) parent, (Attribute) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryVersionAnnotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return VersionAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAnnotatedElement.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAnnotatedElement.java deleted file mode 100644 index 0c0ae97db6..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAnnotatedElement.java +++ /dev/null @@ -1,207 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 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.binary; - -import java.util.Iterator; -import java.util.Vector; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.ContainerAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable; -import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator; -import org.eclipse.jpt.utility.internal.iterators.SingleElementIterator; - -/** - * binary annotated element - */ -abstract class BinaryAnnotatedElement - extends BinaryNode - implements JavaResourceAnnotatedElement -{ - /** JDT annotated element adapter */ - final Adapter adapter; - - /** annotations */ - final Vector<Annotation> annotations = new Vector<Annotation>(); - - - // ********** construction/initialization ********** - - public BinaryAnnotatedElement(JavaResourceNode parent, Adapter adapter) { - super(parent); - this.adapter = adapter; - this.initializeAnnotations(); - } - - private void initializeAnnotations() { - for (IAnnotation annotation : this.getJdtAnnotations()) { - this.addAnnotation(annotation); - } - } - - private void addAnnotation(IAnnotation jdtAnnotation) { - if (this.annotationIsValid(jdtAnnotation)) { - this.annotations.add(this.buildAnnotation(jdtAnnotation)); - } - } - - - // ********** updating ********** - - @Override - public void update() { - super.update(); - this.updateAnnotations(); - } - - // TODO - private void updateAnnotations() { - throw new UnsupportedOperationException(); - } - - - // ********** annotations ********** - - public Iterator<Annotation> annotations() { - return this.getAnnotations().iterator(); - } - - private Iterable<Annotation> getAnnotations() { - return new LiveCloneIterable<Annotation>(this.annotations); - } - - public int annotationsSize() { - return this.annotations.size(); - } - - public Annotation getAnnotation(String annotationName) { - return this.selectAnnotationNamed(this.getAnnotations(), annotationName); - } - - public Annotation getNonNullAnnotation(String annotationName) { - Annotation annotation = this.getAnnotation(annotationName); - return (annotation != null) ? annotation : this.buildNullAnnotation(annotationName); - } - - public Iterator<NestableAnnotation> annotations(String nestableAnnotationName, String containerAnnotationName) { - ContainerAnnotation<NestableAnnotation> containerAnnotation = this.getContainerAnnotation(containerAnnotationName); - if (containerAnnotation != null) { - return containerAnnotation.getNestedAnnotations().iterator(); - } - NestableAnnotation nestableAnnotation = this.getNestableAnnotation(nestableAnnotationName); - return (nestableAnnotation == null) ? - EmptyListIterator.<NestableAnnotation>instance() : - new SingleElementIterator<NestableAnnotation>(nestableAnnotation); - } - - private NestableAnnotation getNestableAnnotation(String annotationName) { - return (NestableAnnotation) this.getAnnotation(annotationName); - } - - @SuppressWarnings("unchecked") - private ContainerAnnotation<NestableAnnotation> getContainerAnnotation(String annotationName) { - return (ContainerAnnotation<NestableAnnotation>) this.getAnnotation(annotationName); - } - - private boolean annotationIsValid(IAnnotation jdtAnnotation) { - return CollectionTools.contains(this.validAnnotationNames(), jdtAnnotation.getElementName()); - } - - abstract Iterator<String> validAnnotationNames(); - - abstract Annotation buildAnnotation(IAnnotation jdtAnnotation); - - abstract Annotation buildNullAnnotation(String annotationName); - - - // ********** simple state ********** - - public boolean isAnnotated() { - return ! this.annotations.isEmpty(); - } - - - // ********** miscellaneous ********** - - IJavaElement getAnnotatedElement() { - return this.adapter.getElement(); - } - - private Annotation selectAnnotationNamed(Iterable<Annotation> annotationList, String annotationName) { - for (Annotation annotation : annotationList) { - if (annotation.getAnnotationName().equals(annotationName)) { - return annotation; - } - } - return null; - } - - private IAnnotation[] getJdtAnnotations() { - try { - return this.adapter.getAnnotations(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return EMPTY_JDT_ANNOTATION_ARRAY; - } - } - private static final IAnnotation[] EMPTY_JDT_ANNOTATION_ARRAY = new IAnnotation[0]; - - - // ********** IJavaElement adapter ********** - - interface Adapter { - /** - * Return the adapter's JDT element (IPackageFragment, IType, IField, IMethod). - */ - IJavaElement getElement(); - - /** - * Return the adapter's element's JDT annotations. - */ - IAnnotation[] getAnnotations() throws JavaModelException; - } - - - // ********** unsupported JavaResourcePersistentMember implementation ********** - - public Annotation addAnnotation(String annotationName) { - throw new UnsupportedOperationException(); - } - - public NestableAnnotation addAnnotation(int index, String nestableAnnotationName, String containerAnnotationName) { - throw new UnsupportedOperationException(); - } - - public void moveAnnotation(int targetIndex, int sourceIndex, String containerAnnotationName) { - throw new UnsupportedOperationException(); - } - - public void removeAnnotation(String annotationName) { - throw new UnsupportedOperationException(); - } - - public void removeAnnotation(int index, String nestableAnnotationName, String containerAnnotationName) { - throw new UnsupportedOperationException(); - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAnnotation.java deleted file mode 100644 index db134fd8b8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAnnotation.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.IMemberValuePair; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; - -/** - * JAR annotation - */ -public abstract class BinaryAnnotation - extends BinaryNode - implements Annotation -{ - final IAnnotation jdtAnnotation; - - protected BinaryAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent); - this.jdtAnnotation = jdtAnnotation; - } - - - // ********** convenience methods ********** - - /** - * Return the values of the JDT annotation's member with the specified name. - */ - protected Object[] getJdtMemberValues(String memberName) { - Object[] values = (Object[]) this.getJdtMemberValue(memberName); - return (values != null) ? values : EMPTY_OBJECT_ARRAY; - } - private static final Object[] EMPTY_OBJECT_ARRAY = new Object[0]; - - /** - * Return the value of the JDT annotation's member with the specified name. - */ - protected Object getJdtMemberValue(String memberName) { - IMemberValuePair pair = this.getJdtMemberValuePair(memberName); - return (pair == null) ? null : pair.getValue(); - } - - /** - * Return the JDT annotation's member-value pair with the specified name. - */ - private IMemberValuePair getJdtMemberValuePair(String memberName) { - for (IMemberValuePair pair : this.getJdtMemberValuePairs()) { - if (pair.getMemberName().equals(memberName)) { - return pair; - } - } - return null; - } - - private IMemberValuePair[] getJdtMemberValuePairs() { - try { - return this.jdtAnnotation.getMemberValuePairs(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return EMPTY_MEMBER_VALUE_PAIR_ARRAY; - } - } - private static final IMemberValuePair[] EMPTY_MEMBER_VALUE_PAIR_ARRAY = new IMemberValuePair[0]; - - - // ********** Annotation implementation ********** - public org.eclipse.jdt.core.dom.Annotation getAstAnnotation(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - public void newAnnotation() { - throw new UnsupportedOperationException(); - } - public void removeAnnotation() { - throw new UnsupportedOperationException(); - } - - // ********** NestableAnnotation implementation ********** - public void moveAnnotation(@SuppressWarnings("unused") int index) { - throw new UnsupportedOperationException(); - } - public void initializeFrom(@SuppressWarnings("unused") NestableAnnotation oldAnnotation) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAssociationOverrideAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAssociationOverrideAnnotation.java deleted file mode 100644 index 439b0442b3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAssociationOverrideAnnotation.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.NestableAssociationOverrideAnnotation; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.AssociationOverride - */ -public abstract class BinaryAssociationOverrideAnnotation - extends BinaryOverrideAnnotation - implements NestableAssociationOverrideAnnotation -{ - private final Vector<JoinColumnAnnotation> joinColumns; - - - protected BinaryAssociationOverrideAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.joinColumns = this.buildJoinColumns(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.updateJoinColumns(); - } - - - // ********** BinaryOverrideAnnotation implementation ********** - - @Override - protected String getNameElementName() { - return JPA.ASSOCIATION_OVERRIDE__NAME; - } - - - // ********** AssociationOverrideAnnotation implementation ********** - - // ***** join columns - public ListIterator<JoinColumnAnnotation> joinColumns() { - return new CloneListIterator<JoinColumnAnnotation>(this.joinColumns); - } - - public int joinColumnsSize() { - return this.joinColumns.size(); - } - - public JoinColumnAnnotation joinColumnAt(int index) { - return this.joinColumns.get(index); - } - - public int indexOfJoinColumn(JoinColumnAnnotation joinColumn) { - return this.joinColumns.indexOf(joinColumn); - } - - public JoinColumnAnnotation addJoinColumn(int index) { - throw new UnsupportedOperationException(); - } - - public void moveJoinColumn(int targetIndex, int sourceIndex) { - throw new UnsupportedOperationException(); - } - - public void removeJoinColumn(int index) { - throw new UnsupportedOperationException(); - } - - private Vector<JoinColumnAnnotation> buildJoinColumns() { - Object[] jdtJoinColumns = this.getJdtMemberValues(JPA.ASSOCIATION_OVERRIDE__JOIN_COLUMNS); - Vector<JoinColumnAnnotation> result = new Vector<JoinColumnAnnotation>(jdtJoinColumns.length); - for (Object jdtJoinColumn : jdtJoinColumns) { - result.add(new BinaryJoinColumnAnnotation(this, (IAnnotation) jdtJoinColumn)); - } - return result; - } - - // TODO - private void updateJoinColumns() { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAssociationOverridesAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAssociationOverridesAnnotation.java deleted file mode 100644 index f4894e174d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAssociationOverridesAnnotation.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.binary; - -import java.util.Vector; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.AssociationOverridesAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableAssociationOverrideAnnotation; -import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable; - -/** - * javax.persistence.AssociationOverrides - */ -public abstract class BinaryAssociationOverridesAnnotation - extends BinaryContainerAnnotation<NestableAssociationOverrideAnnotation> - implements AssociationOverridesAnnotation -{ - private final Vector<NestableAssociationOverrideAnnotation> associationOverrides; - - - protected BinaryAssociationOverridesAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.associationOverrides = this.buildAssociationOverrides(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public Iterable<NestableAssociationOverrideAnnotation> getNestedAnnotations() { - return new LiveCloneIterable<NestableAssociationOverrideAnnotation>(this.associationOverrides); - } - - public int getNestedAnnotationsSize() { - return this.associationOverrides.size(); - } - - private Vector<NestableAssociationOverrideAnnotation> buildAssociationOverrides() { - Object[] jdtAssociationOverrides = this.getJdtMemberValues(JPA.ASSOCIATION_OVERRIDES__VALUE); - Vector<NestableAssociationOverrideAnnotation> result = new Vector<NestableAssociationOverrideAnnotation>(jdtAssociationOverrides.length); - for (Object jdtAssociationOverride : jdtAssociationOverrides) { - result.add(buildAssociationOverride(jdtAssociationOverride)); - } - return result; - } - - protected abstract NestableAssociationOverrideAnnotation buildAssociationOverride(Object jdtAssociationOverride); - - @Override - public void update() { - super.update(); - this.updateAssociationOverrides(); - } - - // TODO - private void updateAssociationOverrides() { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAttributeOverrideAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAttributeOverrideAnnotation.java deleted file mode 100644 index 37add8b4d8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAttributeOverrideAnnotation.java +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.NullAttributeOverrideColumnAnnotation; -import org.eclipse.jpt.core.resource.java.ColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableAttributeOverrideAnnotation; - -/** - * javax.persistence.AttributeOverride - */ -public final class BinaryAttributeOverrideAnnotation - extends BinaryOverrideAnnotation - implements NestableAttributeOverrideAnnotation -{ - private ColumnAnnotation column; - - - public BinaryAttributeOverrideAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.column = this.buildColumn(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.updateColumn(); - } - - - //************ BinaryOverrideAnnotation implementation **************** - - @Override - protected String getNameElementName() { - return JPA.ATTRIBUTE_OVERRIDE__NAME; - } - - - //************ AttributeOverride implementation **************** - - // ***** column - public ColumnAnnotation getColumn() { - return this.column; - } - - public ColumnAnnotation getNonNullColumn() { - return (this.column != null) ? this.column : new NullAttributeOverrideColumnAnnotation(this); - } - - public ColumnAnnotation addColumn() { - throw new UnsupportedOperationException(); - } - - public void removeColumn() { - throw new UnsupportedOperationException(); - } - - private ColumnAnnotation buildColumn() { - IAnnotation jdtColumn = this.getJdtColumn(); - return (jdtColumn == null) ? null : this.buildColumn(jdtColumn); - } - - private ColumnAnnotation buildColumn(IAnnotation jdtColumn) { - return new BinaryColumnAnnotation(this, jdtColumn); - } - - private IAnnotation getJdtColumn() { - return (IAnnotation) this.getJdtMemberValue(JPA.ATTRIBUTE_OVERRIDE__COLUMN); - } - - private void setColumn(ColumnAnnotation column) { - ColumnAnnotation old = this.column; - this.column = column; - this.firePropertyChanged(COLUMN_PROPERTY, old, column); - } - - // TODO - private void updateColumn() { - throw new UnsupportedOperationException(); -// IAnnotation jdtColumn = this.getJdtColumn(); -// if (jdtColumn == null) { -// this.setColumn(null); -// } else { -// if (this.column == null) { -// this.setColumn(this.buildColumn(jdtColumn)); -// } else { -// this.column.update(jdtColumn); -// } -// } - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAttributeOverridesAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAttributeOverridesAnnotation.java deleted file mode 100644 index 1cecad35c4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAttributeOverridesAnnotation.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.binary; - -import java.util.Vector; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.AttributeOverridesAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableAttributeOverrideAnnotation; -import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable; - -/** - * javax.persistence.AttributeOverrides - */ -public final class BinaryAttributeOverridesAnnotation - extends BinaryContainerAnnotation<NestableAttributeOverrideAnnotation> - implements AttributeOverridesAnnotation -{ - private final Vector<NestableAttributeOverrideAnnotation> attributeOverrides; - - - public BinaryAttributeOverridesAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.attributeOverrides = this.buildAttributeOverrides(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public Iterable<NestableAttributeOverrideAnnotation> getNestedAnnotations() { - return new LiveCloneIterable<NestableAttributeOverrideAnnotation>(this.attributeOverrides); - } - - public int getNestedAnnotationsSize() { - return this.attributeOverrides.size(); - } - - private Vector<NestableAttributeOverrideAnnotation> buildAttributeOverrides() { - Object[] jdtAttributeOverrides = this.getJdtMemberValues(JPA.ATTRIBUTE_OVERRIDES__VALUE); - Vector<NestableAttributeOverrideAnnotation> result = new Vector<NestableAttributeOverrideAnnotation>(jdtAttributeOverrides.length); - for (Object jdtAttributeOverride : jdtAttributeOverrides) { - result.add(new BinaryAttributeOverrideAnnotation(this, (IAnnotation) jdtAttributeOverride)); - } - return result; - } - - @Override - public void update() { - super.update(); - this.updateAttributeOverrides(); - } - - // TODO - private void updateAttributeOverrides() { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBaseColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBaseColumnAnnotation.java deleted file mode 100644 index 2eb6eff7ec..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBaseColumnAnnotation.java +++ /dev/null @@ -1,184 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.BaseColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.Column - * javax.persistence.JoinColumn - */ -public abstract class BinaryBaseColumnAnnotation - extends BinaryNamedColumnAnnotation - implements BaseColumnAnnotation -{ - private String table; - private Boolean unique; - private Boolean nullable; - private Boolean insertable; - private Boolean updatable; - - - protected BinaryBaseColumnAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.table = this.buildTable(); - this.unique = this.buildUnique(); - this.nullable = this.buildNullable(); - this.insertable = this.buildInsertable(); - this.updatable = this.buildUpdatable(); - } - - @Override - public void update() { - super.update(); - this.setTable_(this.buildTable()); - this.setUnique_(this.buildUnique()); - this.setNullable_(this.buildNullable()); - this.setInsertable_(this.buildInsertable()); - this.setUpdatable_(this.buildUpdatable()); - } - - - //************* BaseColumnAnnotation implementation ************* - - // ***** table - public String getTable() { - return this.table; - } - - public void setTable(String table) { - throw new UnsupportedOperationException(); - } - - private void setTable_(String table) { - String old = this.table; - this.table = table; - this.firePropertyChanged(TABLE_PROPERTY, old, table); - } - - private String buildTable() { - return (String) this.getJdtMemberValue(this.getTableElementName()); - } - - protected abstract String getTableElementName(); - - public TextRange getTableTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean tableTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** unique - public Boolean getUnique() { - return this.unique; - } - - public void setUnique(Boolean unique) { - throw new UnsupportedOperationException(); - } - - private void setUnique_(Boolean unique) { - Boolean old = this.unique; - this.unique = unique; - this.firePropertyChanged(UNIQUE_PROPERTY, old, unique); - } - - private Boolean buildUnique() { - return (Boolean) this.getJdtMemberValue(this.getUniqueElementName()); - } - - protected abstract String getUniqueElementName(); - - public TextRange getUniqueTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** nullable - public Boolean getNullable() { - return this.nullable; - } - - public void setNullable(Boolean nullable) { - throw new UnsupportedOperationException(); - } - - private void setNullable_(Boolean nullable) { - Boolean old = this.nullable; - this.nullable = nullable; - this.firePropertyChanged(NULLABLE_PROPERTY, old, nullable); - } - - private Boolean buildNullable() { - return (Boolean) this.getJdtMemberValue(this.getNullableElementName()); - } - - protected abstract String getNullableElementName(); - - public TextRange getNullableTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** insertable - public Boolean getInsertable() { - return this.insertable; - } - - public void setInsertable(Boolean insertable) { - throw new UnsupportedOperationException(); - } - - private void setInsertable_(Boolean insertable) { - Boolean old = this.insertable; - this.insertable = insertable; - this.firePropertyChanged(INSERTABLE_PROPERTY, old, insertable); - } - - private Boolean buildInsertable() { - return (Boolean) this.getJdtMemberValue(this.getInsertableElementName()); - } - - protected abstract String getInsertableElementName(); - - public TextRange getInsertableTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** updatable - public Boolean getUpdatable() { - return this.updatable; - } - - public void setUpdatable(Boolean updatable) { - throw new UnsupportedOperationException(); - } - - private void setUpdatable_(Boolean updatable) { - Boolean old = this.updatable; - this.updatable = updatable; - this.firePropertyChanged(UPDATABLE_PROPERTY, old, updatable); - } - - private Boolean buildUpdatable() { - return (Boolean) this.getJdtMemberValue(this.getUpdatableElementName()); - } - - protected abstract String getUpdatableElementName(); - - public TextRange getUpdatableTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBaseEnumeratedAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBaseEnumeratedAnnotation.java deleted file mode 100644 index caa19cc127..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBaseEnumeratedAnnotation.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.EnumType; -import org.eclipse.jpt.core.resource.java.EnumeratedAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.Enumerated - */ -public abstract class BinaryBaseEnumeratedAnnotation - extends BinaryAnnotation - implements EnumeratedAnnotation -{ - private EnumType value; - - - protected BinaryBaseEnumeratedAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.value = this.buildValue(); - } - - @Override - public void update() { - super.update(); - this.setValue_(this.buildValue()); - } - - - // ********** EnumeratedAnnotation implementation ********** - - // ***** value - public EnumType getValue() { - return this.value; - } - - public void setValue(EnumType value) { - throw new UnsupportedOperationException(); - } - - private void setValue_(EnumType value) { - EnumType old = this.value; - this.value = value; - this.firePropertyChanged(VALUE_PROPERTY, old, value); - } - - private EnumType buildValue() { - return EnumType.fromJavaAnnotationValue(this.getJdtMemberValue(this.getValueElementName())); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - protected abstract String getValueElementName(); - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBaseJoinColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBaseJoinColumnAnnotation.java deleted file mode 100644 index 281ae2e77b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBaseJoinColumnAnnotation.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.BaseJoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.JoinColumn - * javax.persistence.MapKeyJoinColumn - */ -public abstract class BinaryBaseJoinColumnAnnotation - extends BinaryBaseColumnAnnotation - implements BaseJoinColumnAnnotation -{ - private String referencedColumnName; - - - public BinaryBaseJoinColumnAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.referencedColumnName = this.buildReferencedColumnName(); - } - - @Override - public void update() { - super.update(); - this.setReferencedColumnName_(this.buildReferencedColumnName()); - } - - protected abstract String getReferencedColumnNameElementName(); - - - //************ BaseJoinColumnAnnotation implementation *************** - - // referenced column name - public String getReferencedColumnName() { - return this.referencedColumnName; - } - - public void setReferencedColumnName(String referencedColumnName) { - throw new UnsupportedOperationException(); - } - - private void setReferencedColumnName_(String referencedColumnName) { - String old = this.referencedColumnName; - this.referencedColumnName = referencedColumnName; - this.firePropertyChanged(REFERENCED_COLUMN_NAME_PROPERTY, old, referencedColumnName); - } - - private String buildReferencedColumnName() { - return (String) this.getJdtMemberValue(JPA.JOIN_COLUMN__REFERENCED_COLUMN_NAME); - } - - public TextRange getReferencedColumnNameTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean referencedColumnNameTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBaseNamedQueryAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBaseNamedQueryAnnotation.java deleted file mode 100644 index cb7745ef78..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBaseNamedQueryAnnotation.java +++ /dev/null @@ -1,154 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.BaseNamedQueryAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.QueryHintAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.NamedQuery - * javax.persistence.NamedNativeQuery - */ -abstract class BinaryBaseNamedQueryAnnotation - extends BinaryAnnotation - implements BaseNamedQueryAnnotation -{ - String name; - String query; - final Vector<QueryHintAnnotation> hints; - - - BinaryBaseNamedQueryAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.name = this.buildName(); - this.query = this.buildQuery(); - this.hints = this.buildHints(); - } - - @Override - public void update() { - super.update(); - this.setName_(this.buildName()); - this.setQuery_(this.buildQuery()); - this.updateHints(); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - // ********** BaseNamedQueryAnnotation implementation ********** - - // ***** name - public String getName() { - return this.name; - } - - public void setName(String name) { - throw new UnsupportedOperationException(); - } - - private void setName_(String name) { - String old = this.name; - this.name = name; - this.firePropertyChanged(NAME_PROPERTY, old, name); - } - - private String buildName() { - return (String) this.getJdtMemberValue(this.getNameElementName()); - } - - abstract String getNameElementName(); - - public TextRange getNameTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** query - public String getQuery() { - return this.query; - } - - public void setQuery(String query) { - throw new UnsupportedOperationException(); - } - - private void setQuery_(String query) { - String old = this.query; - this.query = query; - this.firePropertyChanged(QUERY_PROPERTY, old, query); - } - - private String buildQuery() { - return (String) this.getJdtMemberValue(this.getQueryElementName()); - } - - abstract String getQueryElementName(); - - public TextRange getQueryTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** hints - public ListIterator<QueryHintAnnotation> hints() { - return new CloneListIterator<QueryHintAnnotation>(this.hints); - } - - public int hintsSize() { - return this.hints.size(); - } - - public QueryHintAnnotation hintAt(int index) { - return this.hints.get(index); - } - - public int indexOfHint(QueryHintAnnotation queryHint) { - return this.hints.indexOf(queryHint); - } - - public QueryHintAnnotation addHint(int index) { - throw new UnsupportedOperationException(); - } - - public void moveHint(int targetIndex, int sourceIndex) { - throw new UnsupportedOperationException(); - } - - public void removeHint(int index) { - throw new UnsupportedOperationException(); - } - - private Vector<QueryHintAnnotation> buildHints() { - Object[] jdtHints = this.getJdtMemberValues(this.getHintsElementName()); - Vector<QueryHintAnnotation> result = new Vector<QueryHintAnnotation>(jdtHints.length); - for (Object jdtHint : jdtHints) { - result.add(new BinaryQueryHintAnnotation(this, (IAnnotation) jdtHint)); - } - return result; - } - - abstract String getHintsElementName(); - - // TODO - private void updateHints() { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBaseTableAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBaseTableAnnotation.java deleted file mode 100644 index 490d800f7c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBaseTableAnnotation.java +++ /dev/null @@ -1,199 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.BaseTableAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.UniqueConstraintAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.Table - * javax.persistence.JoinTable - * javax.persistence.SecondaryTable - */ -public abstract class BinaryBaseTableAnnotation - extends BinaryAnnotation - implements BaseTableAnnotation -{ - String name; - String schema; - String catalog; - final Vector<UniqueConstraintAnnotation> uniqueConstraints; - - - protected BinaryBaseTableAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.name = this.buildName(); - this.schema = this.buildSchema(); - this.catalog = this.buildCatalog(); - this.uniqueConstraints = this.buildUniqueConstraints(); - } - - @Override - public void update() { - super.update(); - this.setName_(this.buildName()); - this.setSchema_(this.buildSchema()); - this.setCatalog_(this.buildCatalog()); - this.updateUniqueConstraints(); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - // ********** BaseTableAnnotation implementation ********** - - public boolean isSpecified() { - return true; - } - - // ***** name - public String getName() { - return this.name; - } - - public void setName(String name) { - throw new UnsupportedOperationException(); - } - - private void setName_(String name) { - String old = this.name; - this.name = name; - this.firePropertyChanged(NAME_PROPERTY, old, name); - } - - private String buildName() { - return (String) this.getJdtMemberValue(this.getNameElementName()); - } - - protected abstract String getNameElementName(); - - public TextRange getNameTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean nameTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** schema - public String getSchema() { - return this.schema; - } - - public void setSchema(String schema) { - throw new UnsupportedOperationException(); - } - - private void setSchema_(String schema) { - String old = this.schema; - this.schema = schema; - this.firePropertyChanged(SCHEMA_PROPERTY, old, schema); - } - - private String buildSchema() { - return (String) this.getJdtMemberValue(this.getSchemaElementName()); - } - - protected abstract String getSchemaElementName(); - - public TextRange getSchemaTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean schemaTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** catalog - public String getCatalog() { - return this.catalog; - } - - public void setCatalog(String catalog) { - throw new UnsupportedOperationException(); - } - - private void setCatalog_(String catalog) { - String old = this.catalog; - this.catalog = catalog; - this.firePropertyChanged(CATALOG_PROPERTY, old, catalog); - } - - private String buildCatalog() { - return (String) this.getJdtMemberValue(this.getCatalogElementName()); - } - - protected abstract String getCatalogElementName(); - - public TextRange getCatalogTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean catalogTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** unique constraints - public ListIterator<UniqueConstraintAnnotation> uniqueConstraints() { - return new CloneListIterator<UniqueConstraintAnnotation>(this.uniqueConstraints); - } - - public int uniqueConstraintsSize() { - return this.uniqueConstraints.size(); - } - - public UniqueConstraintAnnotation uniqueConstraintAt(int index) { - return this.uniqueConstraints.get(index); - } - - public int indexOfUniqueConstraint(UniqueConstraintAnnotation uniqueConstraint) { - return this.uniqueConstraints.indexOf(uniqueConstraint); - } - - public UniqueConstraintAnnotation addUniqueConstraint(int index) { - throw new UnsupportedOperationException(); - } - - public void moveUniqueConstraint(int targetIndex, int sourceIndex) { - throw new UnsupportedOperationException(); - } - - public void removeUniqueConstraint(int index) { - throw new UnsupportedOperationException(); - } - - private Vector<UniqueConstraintAnnotation> buildUniqueConstraints() { - Object[] jdtUniqueConstraints = this.getJdtMemberValues(this.getUniqueConstraintElementName()); - Vector<UniqueConstraintAnnotation> result = new Vector<UniqueConstraintAnnotation>(jdtUniqueConstraints.length); - for (Object jdtUniqueConstraint : jdtUniqueConstraints) { - result.add(new BinaryUniqueConstraintAnnotation(this, (IAnnotation) jdtUniqueConstraint)); - } - return result; - } - - protected abstract String getUniqueConstraintElementName(); - - // TODO - private void updateUniqueConstraints() { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBaseTemporalAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBaseTemporalAnnotation.java deleted file mode 100644 index cc57a8ca3d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBaseTemporalAnnotation.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.TemporalAnnotation; -import org.eclipse.jpt.core.resource.java.TemporalType; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.Temporal - * javax.persistence.MapKeyTemporal - */ -public abstract class BinaryBaseTemporalAnnotation - extends BinaryAnnotation - implements TemporalAnnotation -{ - private TemporalType value; - - - protected BinaryBaseTemporalAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.value = this.buildValue(); - } - - @Override - public void update() { - super.update(); - this.setValue_(this.buildValue()); - } - - - // ********** TemporalAnnotation implementation ********** - - // ***** value - public TemporalType getValue() { - return this.value; - } - - public void setValue(TemporalType value) { - throw new UnsupportedOperationException(); - } - - private void setValue_(TemporalType value) { - TemporalType old = this.value; - this.value = value; - this.firePropertyChanged(VALUE_PROPERTY, old, value); - } - - private TemporalType buildValue() { - return TemporalType.fromJavaAnnotationValue(this.getJdtMemberValue(getValueElementName())); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - protected abstract String getValueElementName(); -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBasicAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBasicAnnotation.java deleted file mode 100644 index 9db25330ce..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBasicAnnotation.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.BasicAnnotation; -import org.eclipse.jpt.core.resource.java.FetchType; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.Basic - */ -public final class BinaryBasicAnnotation - extends BinaryAnnotation - implements BasicAnnotation -{ - private Boolean optional; - private FetchType fetch; - - - public BinaryBasicAnnotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.optional = this.buildOptional(); - this.fetch = this.buildFetch(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setOptional_(this.buildOptional()); - this.setFetch_(this.buildFetch()); - } - - - //*************** Basic implementation **************** - - // ***** optional - public Boolean getOptional() { - return this.optional; - } - - public void setOptional(Boolean optional) { - throw new UnsupportedOperationException(); - } - - private void setOptional_(Boolean optional) { - Boolean old = this.optional; - this.optional = optional; - this.firePropertyChanged(OPTIONAL_PROPERTY, old, optional); - } - - private Boolean buildOptional() { - return (Boolean) this.getJdtMemberValue(JPA.BASIC__OPTIONAL); - } - - public TextRange getOptionalTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** fetch - public FetchType getFetch() { - return this.fetch; - } - - public void setFetch(FetchType fetch) { - throw new UnsupportedOperationException(); - } - - private void setFetch_(FetchType fetch) { - FetchType old = this.fetch; - this.fetch = fetch; - this.firePropertyChanged(FETCH_PROPERTY, old, fetch); - } - - private FetchType buildFetch() { - return FetchType.fromJavaAnnotationValue(this.getJdtMemberValue(JPA.BASIC__FETCH)); - } - - public TextRange getFetchTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryClassFile.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryClassFile.java deleted file mode 100644 index 037eda1ea4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryClassFile.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import org.eclipse.jdt.core.IClassFile; -import org.eclipse.jdt.core.IType; -import org.eclipse.jpt.core.resource.java.JavaResourceClassFile; -import org.eclipse.jpt.core.resource.java.JavaResourcePackageFragment; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; - -/** - * binary class file - */ -final class BinaryClassFile - extends BinaryNode - implements JavaResourceClassFile -{ - /** JDT class file */ - private final IClassFile classFile; - - /** class file's persistent type */ - private final JavaResourcePersistentType persistentType; - - - // ********** construction/initialization ********** - - /** - * The JDT type gets passed in because the package fragment inspects it - * beforehand to determine whether it is "persistable". (We only build - * class files for "persistable" types.) - */ - BinaryClassFile(JavaResourcePackageFragment parent, IClassFile classFile, IType jdtType) { - super(parent); - this.classFile = classFile; - this.persistentType = this.buildPersistentType(jdtType); - } - - private JavaResourcePersistentType buildPersistentType(IType jdtType) { - return new BinaryPersistentType(this, jdtType); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.classFile.getElementName()); - } - - - // ********** JavaResourceClassFile implementation ********** - - public JavaResourcePersistentType getPersistentType() { - return this.persistentType; - } - - // TODO - @Override - public void update() { - super.update(); -// this.persistentType.update(this.classFile.getType()); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryColumnAnnotation.java deleted file mode 100644 index 89b17e7a43..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryColumnAnnotation.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; - -/** - * javax.persistence.Column - */ -public final class BinaryColumnAnnotation - extends BinaryCompleteColumnAnnotation -{ - - public BinaryColumnAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - } - - @Override - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - - // ********** BinaryNamedColumnAnnotation implementation ********** - - @Override - protected String getNameElementName() { - return JPA.COLUMN__NAME; - } - - @Override - protected String getColumnDefinitionElementName() { - return JPA.COLUMN__COLUMN_DEFINITION; - } - - - // ********** BinaryBaseColumnAnnotation implementation ********** - - @Override - protected String getTableElementName() { - return JPA.COLUMN__TABLE; - } - - @Override - protected String getUniqueElementName() { - return JPA.COLUMN__UNIQUE; - } - - @Override - protected String getNullableElementName() { - return JPA.COLUMN__NULLABLE; - } - - @Override - protected String getInsertableElementName() { - return JPA.COLUMN__INSERTABLE; - } - - @Override - protected String getUpdatableElementName() { - return JPA.COLUMN__UPDATABLE; - } - - - // ********** BinaryCompleteColumnAnnotation implementation ********** - - @Override - protected String getLengthElementName() { - return JPA.COLUMN__LENGTH; - } - - @Override - protected String getPrecisionElementName() { - return JPA.COLUMN__PRECISION; - } - - @Override - protected String getScaleElementName() { - return JPA.COLUMN__SCALE; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryCompleteColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryCompleteColumnAnnotation.java deleted file mode 100644 index bda54d8eeb..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryCompleteColumnAnnotation.java +++ /dev/null @@ -1,128 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.ColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * Abstract implementation of ColumnAnnotation to be used for JPA annotations: - * javax.persistence.Column - * javax.persistence.MapKeyColumn - */ -public abstract class BinaryCompleteColumnAnnotation - extends BinaryBaseColumnAnnotation - implements ColumnAnnotation -{ - protected Integer length; - protected Integer precision; - protected Integer scale; - - - protected BinaryCompleteColumnAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.length = this.buildLength(); - this.precision = this.buildPrecision(); - this.scale = this.buildScale(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setLength_(this.buildLength()); - this.setPrecision_(this.buildPrecision()); - this.setScale_(this.buildScale()); - } - - - // ********** ColumnAnnotation implementation ********** - - // ***** length - public Integer getLength() { - return this.length; - } - - public void setLength(Integer length) { - throw new UnsupportedOperationException(); - } - - private void setLength_(Integer length) { - Integer old = this.length; - this.length = length; - this.firePropertyChanged(LENGTH_PROPERTY, old, length); - } - - private Integer buildLength() { - return (Integer) this.getJdtMemberValue(this.getLengthElementName()); - } - - public TextRange getLengthTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - protected abstract String getLengthElementName(); - - // ***** precision - public Integer getPrecision() { - return this.precision; - } - - public void setPrecision(Integer precision) { - throw new UnsupportedOperationException(); - } - - private void setPrecision_(Integer precision) { - Integer old = this.precision; - this.precision = precision; - this.firePropertyChanged(PRECISION_PROPERTY, old, precision); - } - - private Integer buildPrecision() { - return (Integer) this.getJdtMemberValue(this.getPrecisionElementName()); - } - - public TextRange getPrecisionTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - protected abstract String getPrecisionElementName(); - - // ***** scale - public Integer getScale() { - return this.scale; - } - - public void setScale(Integer scale) { - throw new UnsupportedOperationException(); - } - - private void setScale_(Integer scale) { - Integer old = this.scale; - this.scale = scale; - this.firePropertyChanged(SCALE_PROPERTY, old, scale); - } - - private Integer buildScale() { - return (Integer) this.getJdtMemberValue(this.getScaleElementName()); - } - - public TextRange getScaleTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - protected abstract String getScaleElementName(); -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryContainerAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryContainerAnnotation.java deleted file mode 100644 index b667810c42..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryContainerAnnotation.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.Annotation; -import org.eclipse.jpt.core.resource.java.ContainerAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; - -/** - * JAR annotations do not support most of the container annotation protocol. - */ -public abstract class BinaryContainerAnnotation<T extends NestableAnnotation> - extends BinaryAnnotation - implements ContainerAnnotation<T> -{ - - protected BinaryContainerAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - } - - public String getElementName() { - throw new UnsupportedOperationException(); - } - - public String getNestedAnnotationName() { - throw new UnsupportedOperationException(); - } - - public T addNestedAnnotation() { - throw new UnsupportedOperationException(); - } - - public void syncAddNestedAnnotation(Annotation astAnnotation) { - throw new UnsupportedOperationException(); - } - - public T moveNestedAnnotation(int targetIndex, int sourceIndex) { - throw new UnsupportedOperationException(); - } - - public T removeNestedAnnotation(int index) { - throw new UnsupportedOperationException(); - } - - public void syncRemoveNestedAnnotations(int index) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryDiscriminatorColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryDiscriminatorColumnAnnotation.java deleted file mode 100644 index ea3b6ce596..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryDiscriminatorColumnAnnotation.java +++ /dev/null @@ -1,100 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.DiscriminatorColumnAnnotation; -import org.eclipse.jpt.core.resource.java.DiscriminatorType; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; - -/** - * javax.persistence.DiscriminatorColumn - */ -public final class BinaryDiscriminatorColumnAnnotation - extends BinaryNamedColumnAnnotation - implements DiscriminatorColumnAnnotation -{ - private DiscriminatorType discriminatorType; - private Integer length; - - - public BinaryDiscriminatorColumnAnnotation(JavaResourcePersistentType parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.discriminatorType = this.buildDiscriminatorType(); - this.length = this.buildLength(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setDiscriminatorType_(this.buildDiscriminatorType()); - this.setLength_(this.buildLength()); - } - - - // ********** BinaryNamedColumnAnnotation implementation ********** - - @Override - protected String getNameElementName() { - return JPA.DISCRIMINATOR_COLUMN__NAME; - } - - @Override - protected String getColumnDefinitionElementName() { - return JPA.DISCRIMINATOR_COLUMN__COLUMN_DEFINITION; - } - - - // ********** DiscriminatorColumnAnnotation implementation ********** - - // ***** discriminator type - public DiscriminatorType getDiscriminatorType() { - return null; - } - - public void setDiscriminatorType(DiscriminatorType discriminatorType) { - throw new UnsupportedOperationException(); - } - - private void setDiscriminatorType_(DiscriminatorType discriminatorType) { - DiscriminatorType old = this.discriminatorType; - this.discriminatorType = discriminatorType; - this.firePropertyChanged(DISCRIMINATOR_TYPE_PROPERTY, old, discriminatorType); - } - - private DiscriminatorType buildDiscriminatorType() { - return DiscriminatorType.fromJavaAnnotationValue(this.getJdtMemberValue(JPA.DISCRIMINATOR_COLUMN__DISCRIMINATOR_TYPE)); - } - - // ***** length - public Integer getLength() { - return null; - } - - public void setLength(Integer length) { - throw new UnsupportedOperationException(); - } - - private void setLength_(Integer length) { - Integer old = this.length; - this.length = length; - this.firePropertyChanged(LENGTH_PROPERTY, old, length); - } - - private Integer buildLength() { - return (Integer) this.getJdtMemberValue(JPA.DISCRIMINATOR_COLUMN__LENGTH); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryDiscriminatorValueAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryDiscriminatorValueAnnotation.java deleted file mode 100644 index 287574f758..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryDiscriminatorValueAnnotation.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.DiscriminatorValueAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.DiscriminatorValue - */ -public final class BinaryDiscriminatorValueAnnotation - extends BinaryAnnotation - implements DiscriminatorValueAnnotation -{ - private String value; - - - public BinaryDiscriminatorValueAnnotation(JavaResourcePersistentType parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.value = this.buildValue(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setValue_(this.buildValue()); - } - - - // ********** DiscriminatorValueAnnotation implementation ********** - - // ***** value - public String getValue() { - return this.value; - } - - public void setValue(String value) { - throw new UnsupportedOperationException(); - } - - private void setValue_(String value) { - String old = this.value; - this.value = value; - this.firePropertyChanged(VALUE_PROPERTY, old, value); - } - - private String buildValue() { - return (String) this.getJdtMemberValue(JPA.DISCRIMINATOR_VALUE__VALUE); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEmbeddableAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEmbeddableAnnotation.java deleted file mode 100644 index 91db09f2a2..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEmbeddableAnnotation.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.EmbeddableAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; - -/** - * javax.persistence.Embeddable - */ -public final class BinaryEmbeddableAnnotation - extends BinaryAnnotation - implements EmbeddableAnnotation -{ - - public BinaryEmbeddableAnnotation(JavaResourcePersistentType parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEmbeddedAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEmbeddedAnnotation.java deleted file mode 100644 index 2fd143485d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEmbeddedAnnotation.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.EmbeddedAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; - -/** - * javax.persistence.Embedded - */ -public final class BinaryEmbeddedAnnotation - extends BinaryAnnotation - implements EmbeddedAnnotation -{ - - public BinaryEmbeddedAnnotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEmbeddedIdAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEmbeddedIdAnnotation.java deleted file mode 100644 index 604f5be572..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEmbeddedIdAnnotation.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.EmbeddedIdAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; - -/** - * javax.persistence.EmbeddedId - */ -public final class BinaryEmbeddedIdAnnotation - extends BinaryAnnotation - implements EmbeddedIdAnnotation -{ - - public BinaryEmbeddedIdAnnotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEntityAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEntityAnnotation.java deleted file mode 100644 index bd4acb47b9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEntityAnnotation.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.EntityAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.Entity - */ -public final class BinaryEntityAnnotation - extends BinaryAnnotation - implements EntityAnnotation -{ - private String name; - - - public BinaryEntityAnnotation(JavaResourcePersistentType parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.name = this.buildName(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setName_(this.buildName()); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - // ********** EntityAnnotation implementation ********** - - // ***** name - public String getName() { - return this.name; - } - - public void setName(String name) { - throw new UnsupportedOperationException(); - } - - private void setName_(String name) { - String old = this.name; - this.name = name; - this.firePropertyChanged(NAME_PROPERTY, old, name); - } - - private String buildName() { - return (String) this.getJdtMemberValue(JPA.ENTITY__NAME); - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEnumeratedAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEnumeratedAnnotation.java deleted file mode 100644 index 08ffef0291..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEnumeratedAnnotation.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.EnumeratedAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; - -/** - * javax.persistence.Enumerated - */ -public final class BinaryEnumeratedAnnotation - extends BinaryBaseEnumeratedAnnotation - implements EnumeratedAnnotation -{ - - public BinaryEnumeratedAnnotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - protected String getValueElementName() { - return JPA.ENUMERATED__VALUE; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryGeneratedValueAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryGeneratedValueAnnotation.java deleted file mode 100644 index 7ee085f303..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryGeneratedValueAnnotation.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.GeneratedValueAnnotation; -import org.eclipse.jpt.core.resource.java.GenerationType; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.GeneratedValue - */ -public final class BinaryGeneratedValueAnnotation - extends BinaryAnnotation - implements GeneratedValueAnnotation -{ - private GenerationType strategy; - private String generator; - - - public BinaryGeneratedValueAnnotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.strategy = this.buildStrategy(); - this.generator = this.buildGenerator(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setStrategy_(this.buildStrategy()); - this.setGenerator_(this.buildGenerator()); - } - - - // ********** GeneratedValueAnnotation implementation ********** - - // ***** strategy - public GenerationType getStrategy() { - return this.strategy; - } - - public void setStrategy(GenerationType strategy) { - throw new UnsupportedOperationException(); - } - - private void setStrategy_(GenerationType strategy) { - GenerationType old = this.strategy; - this.strategy = strategy; - this.firePropertyChanged(STRATEGY_PROPERTY, old, strategy); - } - - private GenerationType buildStrategy() { - return GenerationType.fromJavaAnnotationValue(this.getJdtMemberValue(JPA.GENERATED_VALUE__STRATEGY)); - } - - public TextRange getStrategyTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** generator - public String getGenerator() { - return this.generator; - } - - public void setGenerator(String generator) { - throw new UnsupportedOperationException(); - } - - private void setGenerator_(String generator) { - String old = this.generator; - this.generator = generator; - this.firePropertyChanged(GENERATOR_PROPERTY, old, generator); - } - - private String buildGenerator() { - return (String) this.getJdtMemberValue(JPA.GENERATED_VALUE__GENERATOR); - } - - public TextRange getGeneratorTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean generatorTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryGeneratorAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryGeneratorAnnotation.java deleted file mode 100644 index d89cff9ec8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryGeneratorAnnotation.java +++ /dev/null @@ -1,129 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.GeneratorAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.SequenceGenerator - * javax.persistence.TableGenerator - */ -abstract class BinaryGeneratorAnnotation - extends BinaryAnnotation - implements GeneratorAnnotation -{ - String name; - Integer initialValue; - Integer allocationSize; - - - BinaryGeneratorAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.name = this.buildName(); - this.initialValue = this.buildInitialValue(); - this.allocationSize = this.buildAllocationSize(); - } - - @Override - public void update() { - super.update(); - this.setName_(this.buildName()); - this.setInitialValue_(this.buildInitialValue()); - this.setAllocationSize_(this.buildAllocationSize()); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - // ********** GeneratorAnnotation implementation ********** - - // ***** name - public String getName() { - return this.name; - } - - public void setName(String name) { - throw new UnsupportedOperationException(); - } - - private void setName_(String name) { - String old = this.name; - this.name = name; - this.firePropertyChanged(NAME_PROPERTY, old, name); - } - - private String buildName() { - return (String) this.getJdtMemberValue(this.getNameElementName()); - } - - abstract String getNameElementName(); - - public TextRange getNameTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** initial value - public Integer getInitialValue() { - return this.initialValue; - } - - public void setInitialValue(Integer initialValue) { - throw new UnsupportedOperationException(); - } - - private void setInitialValue_(Integer initialValue) { - Integer old = this.initialValue; - this.initialValue = initialValue; - this.firePropertyChanged(INITIAL_VALUE_PROPERTY, old, initialValue); - } - - private Integer buildInitialValue() { - return (Integer) this.getJdtMemberValue(this.getInitialValueElementName()); - } - - abstract String getInitialValueElementName(); - - public TextRange getInitialValueTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** name - public Integer getAllocationSize() { - return this.allocationSize; - } - - public void setAllocationSize(Integer allocationSize) { - throw new UnsupportedOperationException(); - } - - private void setAllocationSize_(Integer allocationSize) { - Integer old = this.allocationSize; - this.allocationSize = allocationSize; - this.firePropertyChanged(NAME_PROPERTY, old, allocationSize); - } - - private Integer buildAllocationSize() { - return (Integer) this.getJdtMemberValue(this.getAllocationSizeElementName()); - } - - abstract String getAllocationSizeElementName(); - - public TextRange getAllocationSizeTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryIdAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryIdAnnotation.java deleted file mode 100644 index 95946b447e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryIdAnnotation.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.IdAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; - -/** - * javax.persistence.Id - */ -public final class BinaryIdAnnotation - extends BinaryAnnotation - implements IdAnnotation -{ - - public BinaryIdAnnotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryIdClassAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryIdClassAnnotation.java deleted file mode 100644 index 95b56dea9c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryIdClassAnnotation.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.IdClassAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.IdClass - */ -public final class BinaryIdClassAnnotation - extends BinaryAnnotation - implements IdClassAnnotation -{ - private String value; - - - public BinaryIdClassAnnotation(JavaResourcePersistentType parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.value = this.buildValue(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setValue_(this.buildValue()); - } - - - // ********** IdClassAnnotation implementation ********** - - // ***** value - public String getValue() { - return this.value; - } - - public void setValue(String value) { - throw new UnsupportedOperationException(); - } - - private void setValue_(String value) { - String old = this.value; - this.value = value; - this.firePropertyChanged(VALUE_PROPERTY, old, value); - this.firePropertyChanged(FULLY_QUALIFIED_CLASS_NAME_PROPERTY, old, value); - } - - private String buildValue() { - return (String) this.getJdtMemberValue(JPA.ID_CLASS__VALUE); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** fully-qualified class name - /** - * binary is already fully-qualified - */ - public String getFullyQualifiedClassName() { - return this.value; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryInheritanceAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryInheritanceAnnotation.java deleted file mode 100644 index 81711643ed..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryInheritanceAnnotation.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.InheritanceAnnotation; -import org.eclipse.jpt.core.resource.java.InheritanceType; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.Inheritance - */ -public final class BinaryInheritanceAnnotation - extends BinaryAnnotation - implements InheritanceAnnotation -{ - private InheritanceType strategy; - - - public BinaryInheritanceAnnotation(JavaResourcePersistentType parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.strategy = this.buildStrategy(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setStrategy_(this.buildStrategy()); - } - - - // ********** InheritanceAnnotation implementation ********** - - // ***** strategy - public InheritanceType getStrategy() { - return this.strategy; - } - - public void setStrategy(InheritanceType strategy) { - throw new UnsupportedOperationException(); - } - - private void setStrategy_(InheritanceType strategy) { - InheritanceType old = this.strategy; - this.strategy = strategy; - this.firePropertyChanged(STRATEGY_PROPERTY, old, strategy); - } - - private InheritanceType buildStrategy() { - return InheritanceType.fromJavaAnnotationValue(this.getJdtMemberValue(JPA.INHERITANCE__STRATEGY)); - } - - public TextRange getStrategyTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryJoinColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryJoinColumnAnnotation.java deleted file mode 100644 index f78bbe483e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryJoinColumnAnnotation.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableJoinColumnAnnotation; - -/** - * javax.persistence.JoinColumn - */ -public final class BinaryJoinColumnAnnotation - extends BinaryBaseJoinColumnAnnotation - implements NestableJoinColumnAnnotation -{ - - public BinaryJoinColumnAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - - // ********** BinaryNamedColumnAnnotation implementation ********** - - @Override - protected String getNameElementName() { - return JPA.JOIN_COLUMN__NAME; - } - - @Override - protected String getColumnDefinitionElementName() { - return JPA.JOIN_COLUMN__COLUMN_DEFINITION; - } - - - // ********** BinaryBaseColumnAnnotation implementation ********** - - @Override - protected String getTableElementName() { - return JPA.JOIN_COLUMN__TABLE; - } - - @Override - protected String getUniqueElementName() { - return JPA.JOIN_COLUMN__UNIQUE; - } - - @Override - protected String getNullableElementName() { - return JPA.JOIN_COLUMN__NULLABLE; - } - - @Override - protected String getInsertableElementName() { - return JPA.JOIN_COLUMN__INSERTABLE; - } - - @Override - protected String getUpdatableElementName() { - return JPA.JOIN_COLUMN__UPDATABLE; - } - - - // ********** BinaryBaseJoinColumnAnnotation implementation ********** - - @Override - protected String getReferencedColumnNameElementName() { - return JPA.JOIN_COLUMN__REFERENCED_COLUMN_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryJoinColumnsAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryJoinColumnsAnnotation.java deleted file mode 100644 index 28a12e517d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryJoinColumnsAnnotation.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.binary; - -import java.util.Vector; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JoinColumnsAnnotation; -import org.eclipse.jpt.core.resource.java.NestableJoinColumnAnnotation; -import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable; - -/** - * javax.persistence.JoinColumns - */ -public final class BinaryJoinColumnsAnnotation - extends BinaryContainerAnnotation<NestableJoinColumnAnnotation> - implements JoinColumnsAnnotation -{ - private final Vector<NestableJoinColumnAnnotation> joinColumns; - - - public BinaryJoinColumnsAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.joinColumns = this.buildJoinColumns(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public Iterable<NestableJoinColumnAnnotation> getNestedAnnotations() { - return new LiveCloneIterable<NestableJoinColumnAnnotation>(this.joinColumns); - } - - public int getNestedAnnotationsSize() { - return this.joinColumns.size(); - } - - private Vector<NestableJoinColumnAnnotation> buildJoinColumns() { - Object[] jdtJoinColumns = this.getJdtMemberValues(JPA.JOIN_COLUMNS__VALUE); - Vector<NestableJoinColumnAnnotation> result = new Vector<NestableJoinColumnAnnotation>(jdtJoinColumns.length); - for (Object jdtJoinColumn : jdtJoinColumns) { - result.add(new BinaryJoinColumnAnnotation(this, (IAnnotation) jdtJoinColumn)); - } - return result; - } - - @Override - public void update() { - super.update(); - this.updateJoinColumns(); - } - - // TODO - private void updateJoinColumns() { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryJoinTableAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryJoinTableAnnotation.java deleted file mode 100644 index 12957724d1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryJoinTableAnnotation.java +++ /dev/null @@ -1,163 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.binary; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JoinTableAnnotation; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.JoinTable - */ -public final class BinaryJoinTableAnnotation - extends BinaryBaseTableAnnotation - implements JoinTableAnnotation -{ - private final Vector<JoinColumnAnnotation> joinColumns; - private final Vector<JoinColumnAnnotation> inverseJoinColumns; - - - public BinaryJoinTableAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.joinColumns = this.buildJoinColumns(); - this.inverseJoinColumns = this.buildInverseJoinColumns(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.updateJoinColumns(); - this.updateInverseJoinColumns(); - } - - - // ********** BinaryBaseTableAnnotation implementation ********** - - @Override - protected String getNameElementName() { - return JPA.JOIN_TABLE__NAME; - } - - @Override - protected String getSchemaElementName() { - return JPA.JOIN_TABLE__SCHEMA; - } - - @Override - protected String getCatalogElementName() { - return JPA.JOIN_TABLE__CATALOG; - } - - @Override - protected String getUniqueConstraintElementName() { - return JPA.JOIN_TABLE__UNIQUE_CONSTRAINTS; - } - - - // ********** JoinTableAnnotation implementation ********** - - // ***** join columns - public ListIterator<JoinColumnAnnotation> joinColumns() { - return new CloneListIterator<JoinColumnAnnotation>(this.joinColumns); - } - - public int joinColumnsSize() { - return this.joinColumns.size(); - } - - public JoinColumnAnnotation joinColumnAt(int index) { - return this.joinColumns.get(index); - } - - public int indexOfJoinColumn(JoinColumnAnnotation joinColumn) { - return this.joinColumns.indexOf(joinColumn); - } - - public JoinColumnAnnotation addJoinColumn(int index) { - throw new UnsupportedOperationException(); - } - - public void moveJoinColumn(int targetIndex, int sourceIndex) { - throw new UnsupportedOperationException(); - } - - public void removeJoinColumn(int index) { - throw new UnsupportedOperationException(); - } - - private Vector<JoinColumnAnnotation> buildJoinColumns() { - Object[] jdtJoinColumns = this.getJdtMemberValues(JPA.JOIN_TABLE__JOIN_COLUMNS); - Vector<JoinColumnAnnotation> result = new Vector<JoinColumnAnnotation>(jdtJoinColumns.length); - for (Object jdtJoinColumn : jdtJoinColumns) { - result.add(new BinaryJoinColumnAnnotation(this, (IAnnotation) jdtJoinColumn)); - } - return result; - } - - // TODO - private void updateJoinColumns() { - throw new UnsupportedOperationException(); - } - - - // ***** inverse join columns - public ListIterator<JoinColumnAnnotation> inverseJoinColumns() { - return new CloneListIterator<JoinColumnAnnotation>(this.inverseJoinColumns); - } - - public int inverseJoinColumnsSize() { - return this.inverseJoinColumns.size(); - } - - public JoinColumnAnnotation inverseJoinColumnAt(int index) { - return this.inverseJoinColumns.get(index); - } - - public int indexOfInverseJoinColumn(JoinColumnAnnotation joinColumn) { - return this.inverseJoinColumns.indexOf(joinColumn); - } - - public JoinColumnAnnotation addInverseJoinColumn(int index) { - throw new UnsupportedOperationException(); - } - - public void moveInverseJoinColumn(int targetIndex, int sourceIndex) { - throw new UnsupportedOperationException(); - } - - public void removeInverseJoinColumn(int index) { - throw new UnsupportedOperationException(); - } - - private Vector<JoinColumnAnnotation> buildInverseJoinColumns() { - Object[] jdtJoinColumns = this.getJdtMemberValues(JPA.JOIN_TABLE__INVERSE_JOIN_COLUMNS); - Vector<JoinColumnAnnotation> result = new Vector<JoinColumnAnnotation>(jdtJoinColumns.length); - for (Object jdtJoinColumn : jdtJoinColumns) { - result.add(new BinaryJoinColumnAnnotation(this, (IAnnotation) jdtJoinColumn)); - } - return result; - } - - // TODO - private void updateInverseJoinColumns() { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryLobAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryLobAnnotation.java deleted file mode 100644 index 0936195b51..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryLobAnnotation.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.LobAnnotation; - -/** - * javax.persistence.Lob - */ -public final class BinaryLobAnnotation - extends BinaryAnnotation - implements LobAnnotation -{ - public BinaryLobAnnotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryManyToManyAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryManyToManyAnnotation.java deleted file mode 100644 index 42593c2c95..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryManyToManyAnnotation.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.jpa2.resource.java.ManyToMany2_0Annotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.ManyToMany - */ -public final class BinaryManyToManyAnnotation - extends BinaryRelationshipMappingAnnotation - implements ManyToMany2_0Annotation -{ - private String mappedBy; - - - public BinaryManyToManyAnnotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.mappedBy = this.buildMappedBy(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setMappedBy_(this.buildMappedBy()); - } - - - // ********** BinaryRelationshipMappingAnnotation implementation ********** - - @Override - String getTargetEntityElementName() { - return JPA.MANY_TO_MANY__TARGET_ENTITY; - } - - @Override - String getFetchElementName() { - return JPA.MANY_TO_MANY__FETCH; - } - - @Override - String getCascadeElementName() { - return JPA.MANY_TO_MANY__CASCADE; - } - - - //**************** OwnableRelationshipMappingAnnotation implementation ************** - - // ***** mapped by - public String getMappedBy() { - return this.mappedBy; - } - - public void setMappedBy(String mappedBy) { - throw new UnsupportedOperationException(); - } - - private void setMappedBy_(String mappedBy) { - String old = this.mappedBy; - this.mappedBy = mappedBy; - this.firePropertyChanged(MAPPED_BY_PROPERTY, old, mappedBy); - } - - private String buildMappedBy() { - return (String) this.getJdtMemberValue(JPA.MANY_TO_MANY__MAPPED_BY); - } - - public TextRange getMappedByTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean mappedByTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryManyToOneAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryManyToOneAnnotation.java deleted file mode 100644 index 191b182208..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryManyToOneAnnotation.java +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.jpa2.resource.java.ManyToOne2_0Annotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.ManyToOne - */ -public final class BinaryManyToOneAnnotation - extends BinaryRelationshipMappingAnnotation - implements ManyToOne2_0Annotation -{ - private Boolean optional; - - - public BinaryManyToOneAnnotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.optional = this.buildOptional(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setOptional_(this.buildOptional()); - } - - - // ********** BinaryRelationshipMappingAnnotation implementation ********** - - @Override - String getTargetEntityElementName() { - return JPA.MANY_TO_ONE__TARGET_ENTITY; - } - - @Override - String getFetchElementName() { - return JPA.MANY_TO_ONE__FETCH; - } - - @Override - String getCascadeElementName() { - return JPA.MANY_TO_ONE__CASCADE; - } - - - // ********** ManyToOneMappingAnnotation implementation ********** - - // ***** optional - public Boolean getOptional() { - return this.optional; - } - - public void setOptional(Boolean optional) { - throw new UnsupportedOperationException(); - } - - private void setOptional_(Boolean optional) { - Boolean old = this.optional; - this.optional = optional; - this.firePropertyChanged(OPTIONAL_PROPERTY, old, optional); - } - - private Boolean buildOptional() { - return (Boolean) this.getJdtMemberValue(JPA.MANY_TO_ONE__OPTIONAL); - } - - public TextRange getOptionalTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryMapKeyAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryMapKeyAnnotation.java deleted file mode 100644 index 7699becdcf..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryMapKeyAnnotation.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.MapKeyAnnotation; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.MapKey - */ -public final class BinaryMapKeyAnnotation - extends BinaryAnnotation - implements MapKeyAnnotation -{ - private String name; - - - public BinaryMapKeyAnnotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.name = this.buildName(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setName_(this.buildName()); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - // ********** MapKeyAnnotation implementation ********** - - // ***** name - public String getName() { - return this.name; - } - - public void setName(String name) { - throw new UnsupportedOperationException(); - } - - private void setName_(String name) { - String old = this.name; - this.name = name; - this.firePropertyChanged(NAME_PROPERTY, old, name); - } - - private String buildName() { - return (String) this.getJdtMemberValue(JPA.MAP_KEY__NAME); - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean nameTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryMappedSuperclassAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryMappedSuperclassAnnotation.java deleted file mode 100644 index 419bfaaa06..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryMappedSuperclassAnnotation.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.resource.java.MappedSuperclassAnnotation; - -public final class BinaryMappedSuperclassAnnotation - extends BinaryAnnotation - implements MappedSuperclassAnnotation -{ - public BinaryMappedSuperclassAnnotation(JavaResourcePersistentType parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedColumnAnnotation.java deleted file mode 100644 index 2230a57bca..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedColumnAnnotation.java +++ /dev/null @@ -1,111 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NamedColumnAnnotation; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.Column - * javax.persistence.JoinColumn - * javax.persistence.DiscriminatorColumn - * javax.persistence.PrimaryKeyJoinColumn. - */ -public abstract class BinaryNamedColumnAnnotation - extends BinaryAnnotation - implements NamedColumnAnnotation -{ - private String name; - private String columnDefinition; - - - protected BinaryNamedColumnAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.name = this.buildName(); - this.columnDefinition = this.buildColumnDefinition(); - } - - @Override - public void update() { - super.update(); - this.setName_(this.buildName()); - this.setColumnDefinition_(this.buildColumnDefinition()); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - // ********** NamedColumn implementation ********** - - public boolean isSpecified() { - return true; - } - - // ***** name - public String getName() { - return this.name; - } - - public void setName(String name) { - throw new UnsupportedOperationException(); - } - - private void setName_(String name) { - String old = this.name; - this.name = name; - this.firePropertyChanged(NAME_PROPERTY, old, name); - } - - private String buildName() { - return (String) this.getJdtMemberValue(this.getNameElementName()); - } - - protected abstract String getNameElementName(); - - public TextRange getNameTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean nameTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** column definition - public String getColumnDefinition() { - return null; - } - - public void setColumnDefinition(String columnDefinition) { - throw new UnsupportedOperationException(); - } - - private void setColumnDefinition_(String columnDefinition) { - String old = this.columnDefinition; - this.columnDefinition = columnDefinition; - this.firePropertyChanged(COLUMN_DEFINITION_PROPERTY, old, columnDefinition); - } - - private String buildColumnDefinition() { - return (String) this.getJdtMemberValue(this.getColumnDefinitionElementName()); - } - - protected abstract String getColumnDefinitionElementName(); - - public TextRange getColumnDefinitionTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedNativeQueriesAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedNativeQueriesAnnotation.java deleted file mode 100644 index 8f8a12d239..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedNativeQueriesAnnotation.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.binary; - -import java.util.Vector; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NamedNativeQueriesAnnotation; -import org.eclipse.jpt.core.resource.java.NestableNamedNativeQueryAnnotation; -import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable; - -/** - * javax.persistence.NamedNativeQueries - */ -public final class BinaryNamedNativeQueriesAnnotation - extends BinaryContainerAnnotation<NestableNamedNativeQueryAnnotation> - implements NamedNativeQueriesAnnotation -{ - private final Vector<NestableNamedNativeQueryAnnotation> namedNativeQueries; - - - public BinaryNamedNativeQueriesAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.namedNativeQueries = this.buildNamedNativeQueries(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public Iterable<NestableNamedNativeQueryAnnotation> getNestedAnnotations() { - return new LiveCloneIterable<NestableNamedNativeQueryAnnotation>(this.namedNativeQueries); - } - - public int getNestedAnnotationsSize() { - return this.namedNativeQueries.size(); - } - - private Vector<NestableNamedNativeQueryAnnotation> buildNamedNativeQueries() { - Object[] jdtQueries = this.getJdtMemberValues(JPA.NAMED_NATIVE_QUERIES__VALUE); - Vector<NestableNamedNativeQueryAnnotation> result = new Vector<NestableNamedNativeQueryAnnotation>(jdtQueries.length); - for (Object jdtQuery : jdtQueries) { - result.add(new BinaryNamedNativeQueryAnnotation(this, (IAnnotation) jdtQuery)); - } - return result; - } - - @Override - public void update() { - super.update(); - this.updateNamedNativeQueries(); - } - - // TODO - private void updateNamedNativeQueries() { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedNativeQueryAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedNativeQueryAnnotation.java deleted file mode 100644 index 7b96cfc170..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedNativeQueryAnnotation.java +++ /dev/null @@ -1,119 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableNamedNativeQueryAnnotation; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.NamedNativeQuery - */ -public final class BinaryNamedNativeQueryAnnotation - extends BinaryBaseNamedQueryAnnotation - implements NestableNamedNativeQueryAnnotation -{ - private String resultClass; - private String resultSetMapping; - - - public BinaryNamedNativeQueryAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.resultClass = this.buildResultClass(); - this.resultSetMapping = this.buildResultSetMapping(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setResultClass_(this.buildResultClass()); - this.setResultSetMapping_(this.buildResultSetMapping()); - } - - - // ********** BinaryBaseNamedQueryAnnotation implementation ********** - - @Override - String getNameElementName() { - return JPA.NAMED_NATIVE_QUERY__NAME; - } - - @Override - String getQueryElementName() { - return JPA.NAMED_NATIVE_QUERY__QUERY; - } - - @Override - String getHintsElementName() { - return JPA.NAMED_NATIVE_QUERY__HINTS; - } - - - // ********** NamedNativeQueryAnnotation implementation ********** - - // ***** result class - public String getResultClass() { - return this.resultClass; - } - - public void setResultClass(String resultClass) { - throw new UnsupportedOperationException(); - } - - private void setResultClass_(String resultClass) { - String old = this.resultClass; - this.resultClass = resultClass; - this.firePropertyChanged(RESULT_CLASS_PROPERTY, old, resultClass); - } - - private String buildResultClass() { - return (String) this.getJdtMemberValue(JPA.NAMED_NATIVE_QUERY__RESULT_CLASS); - } - - public TextRange getResultClassTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** fully-qualified result class name - public String getFullyQualifiedResultClassName() { - return this.resultClass; - } - - // ***** result set mapping - public String getResultSetMapping() { - return this.resultSetMapping; - } - - public void setResultSetMapping(String resultSetMapping) { - throw new UnsupportedOperationException(); - } - - private void setResultSetMapping_(String resultSetMapping) { - String old = this.resultSetMapping; - this.resultSetMapping = resultSetMapping; - this.firePropertyChanged(RESULT_SET_MAPPING_PROPERTY, old, resultSetMapping); - } - - private String buildResultSetMapping() { - return (String) this.getJdtMemberValue(JPA.NAMED_NATIVE_QUERY__RESULT_CLASS); - } - - public TextRange getResultSetMappingTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedQueriesAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedQueriesAnnotation.java deleted file mode 100644 index d5fee459b8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedQueriesAnnotation.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.binary; - -import java.util.Vector; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NamedQueriesAnnotation; -import org.eclipse.jpt.core.resource.java.NamedQueryAnnotation; -import org.eclipse.jpt.core.resource.java.NestableNamedQueryAnnotation; -import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable; - -/** - * javax.persistence.NamedQueries - */ -public abstract class BinaryNamedQueriesAnnotation - extends BinaryContainerAnnotation<NestableNamedQueryAnnotation> - implements NamedQueriesAnnotation -{ - private final Vector<NestableNamedQueryAnnotation> namedQueries; - - - public BinaryNamedQueriesAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.namedQueries = this.buildNamedQueries(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public Iterable<NestableNamedQueryAnnotation> getNestedAnnotations() { - return new LiveCloneIterable<NestableNamedQueryAnnotation>(this.namedQueries); - } - - public int getNestedAnnotationsSize() { - return this.namedQueries.size(); - } - - private Vector<NestableNamedQueryAnnotation> buildNamedQueries() { - Object[] jdtQueries = this.getJdtMemberValues(JPA.NAMED_QUERIES__VALUE); - Vector<NestableNamedQueryAnnotation> result = new Vector<NestableNamedQueryAnnotation>(jdtQueries.length); - for (Object jdtQuery : jdtQueries) { - result.add(this.buildNamedQuery(jdtQuery)); - } - return result; - } - - protected abstract NamedQueryAnnotation buildNamedQuery(Object jdtQuery); - - @Override - public void update() { - super.update(); - this.updateNamedQueries(); - } - - // TODO - private void updateNamedQueries() { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedQueryAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedQueryAnnotation.java deleted file mode 100644 index 158384ddb8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedQueryAnnotation.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NamedQueryAnnotation; -import org.eclipse.jpt.core.resource.java.NestableNamedQueryAnnotation; - -/** - * javax.persistence.NamedQuery - */ -public abstract class BinaryNamedQueryAnnotation - extends BinaryBaseNamedQueryAnnotation - implements NestableNamedQueryAnnotation, NamedQueryAnnotation -{ - public BinaryNamedQueryAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - - // ********** BinaryBaseNamedQueryAnnotation implementation ********** - - @Override - String getNameElementName() { - return JPA.NAMED_QUERY__NAME; - } - - @Override - String getQueryElementName() { - return JPA.NAMED_QUERY__QUERY; - } - - @Override - String getHintsElementName() { - return JPA.NAMED_QUERY__HINTS; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNode.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNode.java deleted file mode 100644 index 8f01e8d048..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNode.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.binary; - -import org.eclipse.core.resources.IFile; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.AbstractJavaResourceNode; -import org.eclipse.jpt.core.resource.java.JavaResourceCompilationUnit; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * Binary convenience methods - */ -// TODO hopefully this class can go away with some sort of refactoring of the -// source and binary hierarchies... -public abstract class BinaryNode - extends AbstractJavaResourceNode -{ - - // ********** construction ********** - - protected BinaryNode(JavaResourceNode parent) { - super(parent); - } - - - // ********** JavaResourceNode implementation ********** - - @Override - public IFile getFile() { - return null; // only BinaryPackageFragmentRoot has a file... - } - - public void update() { - // nothing by default - } - - public JavaResourceCompilationUnit getJavaResourceCompilationUnit() { - throw new UnsupportedOperationException(); - } - - public TextRange getTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public void initialize(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public void synchronizeWith(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryOneToManyAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryOneToManyAnnotation.java deleted file mode 100644 index b0872a9081..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryOneToManyAnnotation.java +++ /dev/null @@ -1,121 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; -import org.eclipse.jpt.core.jpa2.resource.java.OneToMany2_0Annotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.OneToMany - */ -public final class BinaryOneToManyAnnotation - extends BinaryRelationshipMappingAnnotation - implements OneToMany2_0Annotation -{ - private String mappedBy; - - private Boolean orphanRemoval; //added in JPA 2.0 - - public BinaryOneToManyAnnotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.mappedBy = this.buildMappedBy(); - this.orphanRemoval = this.buildOrphanRemoval(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setMappedBy_(this.buildMappedBy()); - this.setOrphanRemoval_(this.buildOrphanRemoval()); - } - - - // ********** BinaryRelationshipMappingAnnotation implementation ********** - - @Override - String getTargetEntityElementName() { - return JPA.ONE_TO_MANY__TARGET_ENTITY; - } - - @Override - String getFetchElementName() { - return JPA.ONE_TO_MANY__FETCH; - } - - @Override - String getCascadeElementName() { - return JPA.ONE_TO_MANY__CASCADE; - } - - - //**************** OwnableRelationshipMappingAnnotation implementation ************** - - // ***** mapped by - public String getMappedBy() { - return this.mappedBy; - } - - public void setMappedBy(String mappedBy) { - throw new UnsupportedOperationException(); - } - - private void setMappedBy_(String mappedBy) { - String old = this.mappedBy; - this.mappedBy = mappedBy; - this.firePropertyChanged(MAPPED_BY_PROPERTY, old, mappedBy); - } - - private String buildMappedBy() { - return (String) this.getJdtMemberValue(JPA.ONE_TO_MANY__MAPPED_BY); - } - - public TextRange getMappedByTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean mappedByTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - - // ********** OneToMany2_0Annotation implementation ********** - - public Boolean getOrphanRemoval() { - return this.orphanRemoval; - } - - public void setOrphanRemoval(Boolean orphanRemoval) { - throw new UnsupportedOperationException(); - } - - public TextRange getOrphanRemovalTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - private Boolean buildOrphanRemoval() { - return (Boolean) this.getJdtMemberValue(JPA2_0.ONE_TO_MANY__ORPHAN_REMOVAL); - } - - private void setOrphanRemoval_(Boolean orphanRemoval) { - Boolean old = this.orphanRemoval; - this.orphanRemoval = orphanRemoval; - this.firePropertyChanged(ORPHAN_REMOVAL_PROPERTY, old, orphanRemoval); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryOneToOneAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryOneToOneAnnotation.java deleted file mode 100644 index 9a5be7bc82..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryOneToOneAnnotation.java +++ /dev/null @@ -1,148 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; -import org.eclipse.jpt.core.jpa2.resource.java.OneToOne2_0Annotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.OneToOne - */ -public class BinaryOneToOneAnnotation - extends BinaryRelationshipMappingAnnotation - implements OneToOne2_0Annotation -{ - private Boolean optional; - private String mappedBy; - private Boolean orphanRemoval; //added in JPA 2.0 - - public BinaryOneToOneAnnotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.optional = this.buildOptional(); - this.mappedBy = this.buildMappedBy(); - this.orphanRemoval = this.buildOrphanRemoval(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setOptional_(this.buildOptional()); - this.setMappedBy_(this.buildMappedBy()); - this.setOrphanRemoval_(this.buildOrphanRemoval()); - } - - - // ********** BinaryRelationshipMappingAnnotation implementation ********** - - @Override - String getTargetEntityElementName() { - return JPA.ONE_TO_ONE__TARGET_ENTITY; - } - - @Override - String getFetchElementName() { - return JPA.ONE_TO_ONE__FETCH; - } - - @Override - String getCascadeElementName() { - return JPA.ONE_TO_ONE__CASCADE; - } - - - //**************** OwnableRelationshipMappingAnnotation implementation ************** - - // ***** mapped by - public String getMappedBy() { - return this.mappedBy; - } - - public void setMappedBy(String mappedBy) { - throw new UnsupportedOperationException(); - } - - private void setMappedBy_(String mappedBy) { - String old = this.mappedBy; - this.mappedBy = mappedBy; - this.firePropertyChanged(MAPPED_BY_PROPERTY, old, mappedBy); - } - - private String buildMappedBy() { - return (String) this.getJdtMemberValue(JPA.ONE_TO_ONE__MAPPED_BY); - } - - public TextRange getMappedByTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean mappedByTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - - //**************** OneToOneAnnotation implementation ************** - - // ***** optional - public Boolean getOptional() { - return this.optional; - } - - public void setOptional(Boolean optional) { - throw new UnsupportedOperationException(); - } - - private void setOptional_(Boolean optional) { - Boolean old = this.optional; - this.optional = optional; - this.firePropertyChanged(OPTIONAL_PROPERTY, old, optional); - } - - private Boolean buildOptional() { - return (Boolean) this.getJdtMemberValue(JPA.ONE_TO_ONE__OPTIONAL); - } - - public TextRange getOptionalTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - - // ********** OneToOne2_0Annotation implementation ********** - - public Boolean getOrphanRemoval() { - return this.orphanRemoval; - } - - public void setOrphanRemoval(Boolean orphanRemoval) { - throw new UnsupportedOperationException(); - } - - public TextRange getOrphanRemovalTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - private Boolean buildOrphanRemoval() { - return (Boolean) this.getJdtMemberValue(JPA2_0.ONE_TO_ONE__ORPHAN_REMOVAL); - } - - private void setOrphanRemoval_(Boolean orphanRemoval) { - Boolean old = this.orphanRemoval; - this.orphanRemoval = orphanRemoval; - this.firePropertyChanged(ORPHAN_REMOVAL_PROPERTY, old, orphanRemoval); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryOrderByAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryOrderByAnnotation.java deleted file mode 100644 index e8f87d7a32..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryOrderByAnnotation.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.OrderByAnnotation; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.OrderBy - */ -public final class BinaryOrderByAnnotation - extends BinaryAnnotation - implements OrderByAnnotation -{ - private String value; - - - public BinaryOrderByAnnotation(JavaResourcePersistentAttribute parent, IAnnotation annotation) { - super(parent, annotation); - this.value = this.buildValue(); - } - - @Override - public void update() { - super.update(); - this.setValue_(this.buildValue()); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - - // ********** OrderByAnnotation implementation ********** - - // ***** value - public String getValue() { - return this.value; - } - - public void setValue(String value) { - throw new UnsupportedOperationException(); - } - - private void setValue_(String value) { - String old = this.value; - this.value = value; - this.firePropertyChanged(VALUE_PROPERTY, old, value); - } - - private String buildValue() { - return (String) this.getJdtMemberValue(JPA.ORDER_BY__VALUE); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryOverrideAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryOverrideAnnotation.java deleted file mode 100644 index 4e129f6372..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryOverrideAnnotation.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.OverrideAnnotation; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * Common behavior for - * javax.persistence.AttributeOverride - * javax.persistence.AssociationOverride - */ -public abstract class BinaryOverrideAnnotation - extends BinaryAnnotation - implements OverrideAnnotation -{ - private String name; - - - public BinaryOverrideAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.name = this.buildName(); - } - - @Override - public void update() { - super.update(); - this.setName_(this.buildName()); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - // ********** OverrideAnnotation implementation ********** - - // ***** name - public String getName() { - return this.name; - } - - public void setName(String name) { - throw new UnsupportedOperationException(); - } - - private void setName_(String name) { - String old = this.name; - this.name = name; - this.firePropertyChanged(OverrideAnnotation.NAME_PROPERTY, old, name); - } - - private String buildName() { - return (String) this.getJdtMemberValue(this.getNameElementName()); - } - - protected abstract String getNameElementName(); - - public TextRange getNameTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean nameTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPackageFragment.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPackageFragment.java deleted file mode 100644 index 734439b56d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPackageFragment.java +++ /dev/null @@ -1,125 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.ListIterator; -import java.util.Vector; -import org.eclipse.jdt.core.IClassFile; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.resource.java.JavaResourceClassFile; -import org.eclipse.jpt.core.resource.java.JavaResourcePackageFragment; -import org.eclipse.jpt.core.resource.java.JavaResourcePackageFragmentRoot; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; -import org.eclipse.jpt.utility.internal.iterators.TransformationIterator; - -/** - * binary package fragment - */ -final class BinaryPackageFragment - extends BinaryNode - implements JavaResourcePackageFragment -{ - /** JDT package fragment */ - private final IPackageFragment packageFragment; - - /** - * class files in the package fragment; - * we only hold class files/types that are actually annotated; - * if the unannotated types are needed (e.g. for orm.xml or an - * inheritance tree) they can be discovered on the classpath as needed - */ - private final Vector<JavaResourceClassFile> classFiles = new Vector<JavaResourceClassFile>(); - - - // ********** construction/initialization ********** - - BinaryPackageFragment(JavaResourcePackageFragmentRoot parent, IPackageFragment packageFragment) { - super(parent); - this.packageFragment = packageFragment; - this.classFiles.addAll(this.buildClassFiles()); - } - - private Collection<JavaResourceClassFile> buildClassFiles() { - IJavaElement[] children = this.getJDTChildren(); - ArrayList<JavaResourceClassFile> result = new ArrayList<JavaResourceClassFile>(children.length); - for (IJavaElement child : children) { - IClassFile jdtClassFile = (IClassFile) child; - IType jdtType = jdtClassFile.getType(); - if (BinaryPersistentType.typeIsPersistable(jdtType)) { - JavaResourceClassFile classFile = new BinaryClassFile(this, jdtClassFile, jdtType); - if (classFile.getPersistentType().isAnnotated()) { // we only hold annotated types - result.add(classFile); - } - } - } - return result; - } - - - // ********** JarResourceNode implementation ********** - - @Override - public void update() { - super.update(); - this.updateClassFiles(); - } - - // TODO - private void updateClassFiles() { - throw new UnsupportedOperationException(); - } - - - // ********** JavaResourcePackageFragment implementation ********** - - public ListIterator<JavaResourceClassFile> classFiles() { - return new CloneListIterator<JavaResourceClassFile>(this.classFiles); - } - - public int classFilesSize() { - return this.classFiles.size(); - } - - public Iterator<JavaResourcePersistentType> persistedTypes() { - return new TransformationIterator<JavaResourceClassFile, JavaResourcePersistentType>(this.classFiles()) { - @Override - protected JavaResourcePersistentType transform(JavaResourceClassFile classFile) { - return classFile.getPersistentType(); // we only hold annotated types - } - }; - } - - - // ********** misc ********** - - private IJavaElement[] getJDTChildren() { - try { - return this.packageFragment.getChildren(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return EMPTY_JAVA_ELEMENT_ARRAY; - } - } - protected static final IJavaElement[] EMPTY_JAVA_ELEMENT_ARRAY = new IJavaElement[0]; - - @Override - public void toString(StringBuilder sb) { - sb.append(this.packageFragment.getElementName()); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPackageFragmentRoot.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPackageFragmentRoot.java deleted file mode 100644 index 6dfcb01264..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPackageFragmentRoot.java +++ /dev/null @@ -1,117 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.Vector; - -import org.eclipse.core.resources.IFile; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jpt.core.JpaAnnotationProvider; -import org.eclipse.jpt.core.internal.utility.jdt.JDTTools; -import org.eclipse.jpt.core.resource.java.JavaResourcePackageFragment; -import org.eclipse.jpt.core.resource.java.JavaResourcePackageFragmentRoot; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.utility.internal.iterators.CloneIterator; -import org.eclipse.jpt.utility.internal.iterators.CompositeIterator; -import org.eclipse.jpt.utility.internal.iterators.TransformationIterator; - -/** - * binary package fragment root - */ -public final class BinaryPackageFragmentRoot - extends RootBinaryNode - implements JavaResourcePackageFragmentRoot -{ - /** JDT package fragment root */ - private final IPackageFragmentRoot packageFragmentRoot; - - /** package fragments in the JAR */ - private final Vector<JavaResourcePackageFragment> packageFragments = new Vector<JavaResourcePackageFragment>(); - - - // ********** construction/initialization ********** - - public BinaryPackageFragmentRoot(IPackageFragmentRoot packageFragmentRoot, JpaAnnotationProvider annotationProvider) { - super(null, annotationProvider); // the package fragment root is the root of its sub-tree - this.packageFragmentRoot = packageFragmentRoot; - this.packageFragments.addAll(this.buildPackageFragments()); - } - - private Collection<JavaResourcePackageFragment> buildPackageFragments() { - IJavaElement[] jdtChildren = this.getJDTChildren(); - ArrayList<JavaResourcePackageFragment> result = new ArrayList<JavaResourcePackageFragment>(jdtChildren.length); - for (IJavaElement child : jdtChildren) { - result.add(new BinaryPackageFragment(this, (IPackageFragment) child)); - } - return result; - } - - - // ********** overrides ********** - - @Override - public IFile getFile() { - return (IFile) this.packageFragmentRoot.getResource(); - } - - @Override - public void update() { - super.update(); - this.updatePackageFragments(); - } - - // TODO - private void updatePackageFragments() { - throw new UnsupportedOperationException(); - } - - - // ********** JavaResourceNode.Root implementation ********** - - /** - * NB: we hold only annotated types - */ - public Iterator<JavaResourcePersistentType> persistentTypes() { - return new CompositeIterator<JavaResourcePersistentType>(this.persistedTypeIterators()); - } - - private Iterator<Iterator<JavaResourcePersistentType>> persistedTypeIterators() { - return new TransformationIterator<JavaResourcePackageFragment, Iterator<JavaResourcePersistentType>>(this.packageFragments()) { - @Override - protected Iterator<JavaResourcePersistentType> transform(JavaResourcePackageFragment fragment) { - return fragment.persistedTypes(); - } - }; - } - - - // ********** JavaResourcePackageFragmentRoot implementation ********** - - public Iterator<JavaResourcePackageFragment> packageFragments() { - return new CloneIterator<JavaResourcePackageFragment>(this.packageFragments); - } - - public int packageFragmentsSize() { - return this.packageFragments.size(); - } - - - // ********** misc ********** - - private IJavaElement[] getJDTChildren() { - return JDTTools.getJDTChildren(this.packageFragmentRoot); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentAttribute.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentAttribute.java deleted file mode 100644 index 5d8de0a927..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentAttribute.java +++ /dev/null @@ -1,649 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.binary; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.IField; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IMethod; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.Signature; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.internal.utility.jdt.JPTTools; -import org.eclipse.jpt.core.jpa2.resource.java.Access2_0Annotation; -import org.eclipse.jpt.core.resource.java.AccessType; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.utility.MethodSignature; -import org.eclipse.jpt.utility.internal.ClassName; -import org.eclipse.jpt.utility.internal.NameTools; -import org.eclipse.jpt.utility.internal.iterators.CloneIterator; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * binary persistent attribute (field or property) - */ -final class BinaryPersistentAttribute - extends BinaryPersistentMember - implements JavaResourcePersistentAttribute -{ - private int modifiers; - - private String typeName; - - private boolean typeIsInterface; - - private boolean typeIsEnum; - - private final Vector<String> typeSuperclassNames = new Vector<String>(); - - private final Vector<String> typeInterfaceNames = new Vector<String>(); - - private final Vector<String> typeTypeArgumentNames = new Vector<String>(); - - - BinaryPersistentAttribute(JavaResourcePersistentType parent, IField field) { - this(parent, new FieldAdapter(field)); - } - - BinaryPersistentAttribute(JavaResourcePersistentType parent, IMethod method) { - this(parent, new MethodAdapter(method)); - } - - private BinaryPersistentAttribute(JavaResourcePersistentType parent, Adapter adapter) { - super(parent, adapter); - this.modifiers = this.buildModifiers(); - this.typeName = this.buildTypeName(); - - IType type = this.getType(); // shouldn't be an array... - this.typeIsInterface = this.buildTypeIsInterface(type); - this.typeIsEnum = this.buildTypeIsEnum(type); - this.typeSuperclassNames.addAll(this.buildTypeSuperclassNames(type)); - this.typeInterfaceNames.addAll(this.buildTypeInterfaceNames(type)); - - this.typeTypeArgumentNames.addAll(this.buildTypeTypeArgumentNames()); - } - - - // ******** overrides ******** - - @Override - public void update() { - super.update(); - this.setModifiers(this.buildModifiers()); - this.setTypeName(this.buildTypeName()); - - IType type = this.getType(); // shouldn't be an array... - this.setTypeIsInterface(this.buildTypeIsInterface(type)); - this.setTypeIsEnum(this.buildTypeIsEnum(type)); - this.setTypeSuperclassNames(this.buildTypeSuperclassNames(type)); - this.setTypeInterfaceNames(this.buildTypeInterfaceNames(type)); - - this.setTypeTypeArgumentNames(this.buildTypeTypeArgumentNames()); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.getName()); - } - - - // ********** BinaryPersistentMember implementation ********** - - private Adapter getAdapter() { - return (Adapter) this.adapter; - } - - @Override - Iterator<String> validAnnotationNames() { - return this.getAnnotationProvider().attributeAnnotationNames(); - } - - @Override - Annotation buildAnnotation(IAnnotation jdtAnnotation) { - return this.getAnnotationProvider().buildAttributeAnnotation(this, jdtAnnotation); - } - - Annotation buildNullAnnotation_(String annotationName) { - return this.getAnnotationProvider().buildNullAttributeAnnotation(this, annotationName); - } - - - // ********** JavaResourcePersistentAttribute implementation ********** - - public String getName() { - return this.getAdapter().getAttributeName(); - } - - @Override - public Annotation buildNullAnnotation(String annotationName) { - return (annotationName == null) ? null : this.buildNullAnnotation_(annotationName); - } - - public boolean isField() { - return this.getAdapter().isField(); - } - - public boolean isProperty() { - return ! this.isField(); - } - - public boolean isFor(MethodSignature methodSignature, int occurrence) { - throw new UnsupportedOperationException(); - } - - public AccessType getSpecifiedAccess() { - Access2_0Annotation accessAnnotation = (Access2_0Annotation) this.getAnnotation(Access2_0Annotation.ANNOTATION_NAME); - return accessAnnotation == null ? null : accessAnnotation.getValue(); - } - - public boolean typeIsSubTypeOf(String tn) { - return ((this.typeName != null) && this.typeName.equals(tn)) - || this.typeInterfaceNames.contains(tn) - || this.typeSuperclassNames.contains(tn); - } - - public boolean typeIsVariablePrimitive() { - return (this.typeName != null) && ClassName.isVariablePrimitive(this.typeName); - } - - // ***** modifiers - public int getModifiers() { - return this.modifiers; - } - - private void setModifiers(int modifiers) { - int old = this.modifiers; - this.modifiers = modifiers; - this.firePropertyChanged(MODIFIERS_PROPERTY, old, modifiers); - } - - /** - * zero seems like a reasonable default... - */ - private int buildModifiers() { - try { - return this.getMember().getFlags(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return 0; - } - } - - // ***** type name - public String getTypeName() { - return this.typeName; - } - - private void setTypeName(String typeName) { - String old = this.typeName; - this.typeName = typeName; - this.firePropertyChanged(TYPE_NAME_PROPERTY, old, typeName); - } - - /** - * JARs don't have array types; - * also, no generic type parameters - */ - private String buildTypeName() { - return convertTypeSignatureToTypeName(this.getTypeSignature()); - } - - // ***** type is interface - public boolean typeIsInterface() { - return this.typeIsInterface; - } - - private void setTypeIsInterface(boolean typeIsInterface) { - boolean old = this.typeIsInterface; - this.typeIsInterface = typeIsInterface; - this.firePropertyChanged(TYPE_IS_INTERFACE_PROPERTY, old, typeIsInterface); - } - - private boolean buildTypeIsInterface(IType type) { - try { - return (type != null) && type.isInterface(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return false; - } - } - - // ***** type is enum - public boolean typeIsEnum() { - return this.typeIsEnum; - } - - private void setTypeIsEnum(boolean typeIsEnum) { - boolean old = this.typeIsEnum; - this.typeIsEnum = typeIsEnum; - this.firePropertyChanged(TYPE_IS_ENUM_PROPERTY, old, typeIsEnum); - } - - private boolean buildTypeIsEnum(IType type) { - try { - return (type != null) && type.isEnum(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return false; - } - } - - // ***** type superclass hierarchy - public ListIterator<String> typeSuperclassNames() { - return new CloneListIterator<String>(this.typeSuperclassNames); - } - - public boolean typeSuperclassNamesContains(String superclassName) { - return this.typeSuperclassNames.contains(superclassName); - } - - private void setTypeSuperclassNames(List<String> typeSuperclassNames) { - this.synchronizeList(typeSuperclassNames, this.typeSuperclassNames, TYPE_SUPERCLASS_NAMES_LIST); - } - - private List<String> buildTypeSuperclassNames(IType type) { - if (type == null) { - return Collections.emptyList(); - } - - ArrayList<String> names = new ArrayList<String>(); - type = this.findSuperclass(type); - while (type != null) { - names.add(type.getFullyQualifiedName('.')); // no parameters are included here - type = this.findSuperclass(type); - } - return names; - } - - // ***** type interface hierarchy - public Iterator<String> typeInterfaceNames() { - return new CloneIterator<String>(this.typeInterfaceNames); - } - - public boolean typeInterfaceNamesContains(String interfaceName) { - return this.typeInterfaceNames.contains(interfaceName); - } - - private void setTypeInterfaceNames(Collection<String> typeInterfaceNames) { - this.synchronizeCollection(typeInterfaceNames, this.typeInterfaceNames, TYPE_INTERFACE_NAMES_COLLECTION); - } - - private Collection<String> buildTypeInterfaceNames(IType type) { - if (type == null) { - return Collections.emptySet(); - } - - HashSet<String> names = new HashSet<String>(); - while (type != null) { - this.addInterfaceNamesTo(type, names); - type = this.findSuperclass(type); - } - return names; - } - - private void addInterfaceNamesTo(IType type, HashSet<String> names) { - for (String interfaceSignature : this.getSuperInterfaceTypeSignatures(type)) { - String interfaceName = convertTypeSignatureToTypeName(interfaceSignature); - names.add(interfaceName); - IType interfaceType = this.findType(interfaceName); - if (interfaceType != null) { - this.addInterfaceNamesTo(interfaceType, names); // recurse - } - } - } - - // ***** type type argument names - public ListIterator<String> typeTypeArgumentNames() { - return new CloneListIterator<String>(this.typeTypeArgumentNames); - } - - public int typeTypeArgumentNamesSize() { - return this.typeTypeArgumentNames.size(); - } - - public String getTypeTypeArgumentName(int index) { - return this.typeTypeArgumentNames.get(index); - } - - private void setTypeTypeArgumentNames(List<String> typeTypeArgumentNames) { - this.synchronizeList(typeTypeArgumentNames, this.typeTypeArgumentNames, TYPE_TYPE_ARGUMENT_NAMES_LIST); - } - - /** - * these types can be arrays (e.g. "java.lang.String[]"); - * but they won't have any further nested generic type arguments - * (e.g. "java.util.Collection<java.lang.String>") - */ - private List<String> buildTypeTypeArgumentNames() { - String typeSignature = this.getTypeSignature(); - if (typeSignature == null) { - return Collections.emptyList(); - } - - String[] typeArgumentSignatures = Signature.getTypeArguments(typeSignature); - if (typeArgumentSignatures.length == 0) { - return Collections.emptyList(); - } - - ArrayList<String> names = new ArrayList<String>(typeArgumentSignatures.length); - for (String typeArgumentSignature : typeArgumentSignatures) { - names.add(convertTypeSignatureToTypeName(typeArgumentSignature)); - } - return names; - } - - - // ********** convenience methods ********** - - private String getTypeSignature() { - try { - return this.getAdapter().getTypeSignature(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return null; - } - } - - private IType findSuperclass(IType type) { - return this.findTypeBySignature(this.getSuperclassSignature(type)); - } - - private String getSuperclassSignature(IType type) { - try { - return type.getSuperclassTypeSignature(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return null; - } - } - - private String[] getSuperInterfaceTypeSignatures(IType type) { - try { - return type.getSuperInterfaceTypeSignatures(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return EMPTY_STRING_ARRAY; - } - } - private static final String[] EMPTY_STRING_ARRAY = new String[0]; - - private IType findTypeBySignature(String typeSignature) { - return (typeSignature == null) ? null : this.findType(convertTypeSignatureToTypeName_(typeSignature)); - } - - private IType getType() { - return (this.typeName == null) ? null : this.findType(this.typeName); - } - - private IType findType(String fullyQualifiedName) { - try { - return this.getJavaProject().findType(fullyQualifiedName); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return null; - } - } - - private IJavaProject getJavaProject() { - return this.getMember().getJavaProject(); - } - - - - // ********** adapters ********** - - /** - * Adapt an IField or IMethod. - */ - interface Adapter - extends BinaryPersistentMember.Adapter - { - /** - * Return the field or getter method's "attribute" name - * (e.g. field "foo" -> "foo"; method "getFoo" -> "foo"). - */ - String getAttributeName(); - - /** - * Return whether the attribute is a Java field (as opposed to a method). - */ - boolean isField(); - - /** - * Return the attribute's type signature. - */ - String getTypeSignature() throws JavaModelException; - } - - /** - * IField adapter - */ - static class FieldAdapter - implements Adapter - { - final IField field; - - FieldAdapter(IField field) { - super(); - this.field = field; - } - - public IField getElement() { - return this.field; - } - - public boolean isPersistable() { - return this.field.exists() && JPTTools.fieldIsPersistable(new JPTToolsAdapter()); - } - - public IAnnotation[] getAnnotations() throws JavaModelException { - return this.field.getAnnotations(); - } - - public String getAttributeName() { - return this.field.getElementName(); - } - - public boolean isField() { - return true; - } - - public String getTypeSignature() throws JavaModelException { - return this.field.getTypeSignature(); - } - - /** - * JPTTools needs an adapter so it can work with either an IField - * or an IVariableBinding etc. - */ - class JPTToolsAdapter implements JPTTools.FieldAdapter { - public int getModifiers() { - try { - return FieldAdapter.this.field.getFlags(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return 0; - } - } - - } - - } - - /** - * IMethod adapter - */ - static class MethodAdapter - implements Adapter - { - final IMethod method; - static final IMethod[] EMPTY_METHOD_ARRAY = new IMethod[0]; - - MethodAdapter(IMethod method) { - super(); - this.method = method; - } - - public IMethod getElement() { - return this.method; - } - - public boolean isPersistable() { - return JPTTools.methodIsPersistablePropertyGetter(new JPTToolsAdapter()); - } - - public IAnnotation[] getAnnotations() throws JavaModelException { - return this.method.getAnnotations(); - } - - public String getAttributeName() { - return NameTools.convertGetterMethodNameToPropertyName(this.method.getElementName()); - } - - public boolean isField() { - return false; - } - - public String getTypeSignature() throws JavaModelException { - return this.method.getReturnType(); - } - - /** - * JPTTools needs an adapter so it can work with either an IMethod - * or an IMethodBinding etc. - */ - abstract static class AbstractJPTToolsAdapter - implements JPTTools.SimpleMethodAdapter - { - AbstractJPTToolsAdapter() { - super(); - } - - abstract IMethod getMethod(); - - public int getModifiers() { - try { - return this.getMethod().getFlags(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return 0; - } - } - - public String getReturnTypeErasureName() { - return convertTypeSignatureToTypeName(this.getReturnTypeSignature()); - } - - private String getReturnTypeSignature() { - try { - return this.getMethod().getReturnType(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return null; - } - } - - public boolean isConstructor() { - try { - return this.getMethod().isConstructor(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return false; - } - } - - } - - static class SimpleJPTToolsAdapter - extends AbstractJPTToolsAdapter - { - private final IMethod method; - - SimpleJPTToolsAdapter(IMethod method) { - super(); - this.method = method; - } - - @Override - IMethod getMethod() { - return this.method; - } - - } - - class JPTToolsAdapter - extends AbstractJPTToolsAdapter - implements JPTTools.MethodAdapter - { - JPTToolsAdapter() { - super(); - } - - @Override - IMethod getMethod() { - return MethodAdapter.this.method; - } - - public String getName() { - return this.getMethod().getElementName(); - } - - public int getParametersLength() { - return this.getMethod().getParameterTypes().length; - } - - public JPTTools.SimpleMethodAdapter getSibling(String name) { - for (IMethod sibling : this.getSiblings()) { - if ((sibling.getParameterTypes().length == 0) - && sibling.getElementName().equals(name)) { - return new SimpleJPTToolsAdapter(sibling); - } - } - return null; - } - - public JPTTools.SimpleMethodAdapter getSibling(String name, String parameterTypeErasureName) { - for (IMethod sibling : this.getSiblings()) { - String[] parmTypes = sibling.getParameterTypes(); - if ((parmTypes.length == 1) - && sibling.getElementName().equals(name) - && convertTypeSignatureToTypeName(parmTypes[0]).equals(parameterTypeErasureName)) { - return new SimpleJPTToolsAdapter(sibling); - } - } - return null; - } - - private IMethod[] getSiblings() { - try { - return this.getMethod().getDeclaringType().getMethods(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return EMPTY_METHOD_ARRAY; - } - } - - } - - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentMember.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentMember.java deleted file mode 100644 index 9e5c6fce3b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentMember.java +++ /dev/null @@ -1,192 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.binary; - -import java.util.Iterator; -import org.eclipse.jdt.core.Flags; -import org.eclipse.jdt.core.IMember; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.Signature; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.utility.internal.iterators.FilteringIterator; - -/** - * binary persistent member - */ -abstract class BinaryPersistentMember - extends BinaryAnnotatedElement - implements JavaResourcePersistentMember -{ - - boolean persistable; - - private boolean final_; // 'final' is a reserved word - - - // ********** construction/initialization ********** - - public BinaryPersistentMember(JavaResourceNode parent, Adapter adapter) { - super(parent, adapter); - this.persistable = this.buildPersistable(); - this.final_ = this.buildFinal(); - } - - - private Adapter getAdapter() { - return (Adapter) this.adapter; - } - - // ********** updating ********** - - @Override - public void update() { - super.update(); - this.setPersistable(this.buildPersistable()); - this.setFinal(this.buildFinal()); - } - - - // ********** simple state ********** - - public boolean isPersistable() { - return this.persistable; - } - - private void setPersistable(boolean persistable) { - boolean old = this.persistable; - this.persistable = persistable; - this.firePropertyChanged(PERSISTABLE_PROPERTY, old, persistable); - } - - private boolean buildPersistable() { - return this.getAdapter().isPersistable(); - } - - // ***** final - public boolean isFinal() { - return this.final_; - } - - private void setFinal(boolean final_) { - boolean old = this.final_; - this.final_ = final_; - this.firePropertyChanged(FINAL_PROPERTY, old, final_); - } - - private boolean buildFinal() { - try { - return Flags.isFinal(this.getMember().getFlags()); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return false; - } - } - - - // ********** miscellaneous ********** - - IMember getMember() { - return (IMember) this.adapter.getElement(); - } - - /** - * convenience method - */ - <T extends JavaResourcePersistentMember> Iterator<T> persistableMembers(Iterator<T> members) { - return new FilteringIterator<T>(members) { - @Override - protected boolean accept(T m) { - return m.isPersistable(); - } - }; - } - - /** - * Strip off the type signature's parameters if present. - * Convert to a readable string. - */ - static String convertTypeSignatureToTypeName(String typeSignature) { - return (typeSignature == null) ? null : convertTypeSignatureToTypeName_(typeSignature); - } - - /** - * no null check - */ - static String convertTypeSignatureToTypeName_(String typeSignature) { - return Signature.toString(Signature.getTypeErasure(typeSignature)); - } - - - // ********** IMember adapter ********** - - interface Adapter extends BinaryAnnotatedElement.Adapter { - /** - * Return the adapter's JDT member (IType, IField, IMethod). - */ - IMember getElement(); - - /** - * Return whether the adapter's member is "persistable" - * (i.e. according to the JPA spec the member can be mapped) - */ - boolean isPersistable(); - } - - - // ********** unsupported JavaResourceAnnotatedElement implementation ********** - - @Override - public Annotation addAnnotation(String annotationName) { - throw new UnsupportedOperationException(); - } - - @Override - public NestableAnnotation addAnnotation(int index, String nestableAnnotationName, String containerAnnotationName) { - throw new UnsupportedOperationException(); - } - - @Override - public void moveAnnotation(int targetIndex, int sourceIndex, String containerAnnotationName) { - throw new UnsupportedOperationException(); - } - - @Override - public void removeAnnotation(String annotationName) { - throw new UnsupportedOperationException(); - } - - @Override - public void removeAnnotation(int index, String nestableAnnotationName, String containerAnnotationName) { - throw new UnsupportedOperationException(); - } - - public Annotation setPrimaryAnnotation(String primaryAnnotationName, Iterable<String> supportingAnnotationNames) { - throw new UnsupportedOperationException(); - } - - @Override - public TextRange getNameTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public void resolveTypes(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean isFor(String memberName, int occurrence) { - throw new UnsupportedOperationException(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentType.java deleted file mode 100644 index cc8ab60755..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentType.java +++ /dev/null @@ -1,714 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.binary; - -import java.util.Collection; -import java.util.Iterator; -import java.util.Vector; -import org.eclipse.jdt.core.Flags; -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.IField; -import org.eclipse.jdt.core.IMethod; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.internal.utility.jdt.JPTTools; -import org.eclipse.jpt.core.jpa2.resource.java.GeneratedAnnotation; -import org.eclipse.jpt.core.jpa2.resource.java.JavaResourcePersistentType2_0; -import org.eclipse.jpt.core.resource.java.AccessType; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.utility.MethodSignature; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.StringTools; -import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable; -import org.eclipse.jpt.utility.internal.iterators.CompositeIterator; -import org.eclipse.jpt.utility.internal.iterators.FilteringIterator; - -/** - * binary persistent type - */ -final class BinaryPersistentType - extends BinaryPersistentMember - implements JavaResourcePersistentType2_0 -{ - private String name; - - private String qualifiedName; - - private String packageName; - - private String superclassQualifiedName; - - private String declaringTypeName; - - private boolean abstract_; // 'abstract' is a reserved word - - private boolean static_; // 'static' is a reserved word - - private boolean memberType; - - private boolean hasPrivateNoArgConstructor; - - private boolean hasNoArgConstructor; - - private final Vector<JavaResourcePersistentAttribute> fields; - - private final Vector<JavaResourcePersistentAttribute> methods; - - private AccessType access; - - - // ********** construction/initialization ********** - - BinaryPersistentType(JavaResourceNode parent, IType type) { - super(parent, new TypeAdapter(type)); - this.name = this.buildName(); - this.qualifiedName = this.buildQualifiedName(); - this.packageName = this.buildPackageName(); - this.superclassQualifiedName = this.buildSuperclassQualifiedName(); - this.declaringTypeName = this.buildDeclaringTypeName(); - this.abstract_ = this.buildAbstract(); - this.static_ = this.buildStatic(); - this.memberType = this.buildMemberType(); - this.hasNoArgConstructor = this.buildHasNoArgConstructor(); - this.hasPrivateNoArgConstructor = this.buildHasPrivateNoArgConstructor(); - this.fields = this.buildFields(); - this.methods = this.buildMethods(); - // need to wait until everything is built to calculate 'access' - this.access = this.buildAccess(); - } - - - // ********** overrides ********** - - @Override - public void update() { - super.update(); - this.setName(this.buildName()); - this.setQualifiedName(this.buildQualifiedName()); - this.setPackageName(this.buildPackageName()); - this.setSuperclassQualifiedName(this.buildSuperclassQualifiedName()); - this.setDeclaringTypeName(this.buildDeclaringTypeName()); - this.setAbstract(this.buildAbstract()); - this.setStatic(this.buildStatic()); - this.setMemberType(this.buildMemberType()); - this.setHasNoArgConstructor(this.buildHasNoArgConstructor()); - this.setHasPrivateNoArgConstructor(this.buildHasPrivateNoArgConstructor()); - this.updateFields(); - this.updateMethods(); - // need to wait until everything is updated to calculate 'access' - this.setAccess(this.buildAccess()); - } - - // TODO - private void updateFields() { - throw new UnsupportedOperationException(); - } - - // TODO - private void updateMethods() { - throw new UnsupportedOperationException(); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - // ********** BinaryPersistentMember implementation ********** - - @Override - Annotation buildAnnotation(IAnnotation jdtAnnotation) { - return this.getAnnotationProvider().buildTypeAnnotation(this, jdtAnnotation); - } - - @Override - Annotation buildNullAnnotation(String annotationName) { - return this.getAnnotationProvider().buildNullTypeAnnotation(this, annotationName); - } - - @Override - Iterator<String> validAnnotationNames() { - return this.getAnnotationProvider().typeAnnotationNames(); - } - - - // ********** JavaResourcePersistentType implementation ********** - - // ***** name - public String getName() { - return this.name; - } - - private void setName(String name) { - String old = this.name; - this.name = name; - this.firePropertyChanged(NAME_PROPERTY, old, name); - } - - private String buildName() { - return this.getMember().getElementName(); - } - - // ***** qualified name - public String getQualifiedName() { - return this.qualifiedName; - } - - private void setQualifiedName(String qualifiedName) { - String old = this.qualifiedName; - this.qualifiedName = qualifiedName; - this.firePropertyChanged(QUALIFIED_NAME_PROPERTY, old, qualifiedName); - } - - private String buildQualifiedName() { - return this.getMember().getFullyQualifiedName('.'); // no parameters are included here - } - - // ***** package - public String getPackageName() { - return this.packageName; - } - - private void setPackageName(String packageName) { - String old = this.packageName; - this.packageName = packageName; - this.firePropertyChanged(PACKAGE_NAME_PROPERTY, old, packageName); - } - - private String buildPackageName() { - return this.getMember().getPackageFragment().getElementName(); - } - - public boolean isIn(IPackageFragment packageFragment) { - return StringTools.stringsAreEqual(packageFragment.getElementName(), this.packageName); - } - - // ***** superclass qualified name - public String getSuperclassQualifiedName() { - return this.superclassQualifiedName; - } - - private void setSuperclassQualifiedName(String superclassQualifiedName) { - String old = this.superclassQualifiedName; - this.superclassQualifiedName = superclassQualifiedName; - this.firePropertyChanged(SUPERCLASS_QUALIFIED_NAME_PROPERTY, old, superclassQualifiedName); - } - - private String buildSuperclassQualifiedName() { - return convertTypeSignatureToTypeName(this.getSuperclassTypeSignature()); - } - - private String getSuperclassTypeSignature() { - try { - return this.getMember().getSuperclassTypeSignature(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return null; - } - } - - // ***** declaring type name - public String getDeclaringTypeName() { - return this.declaringTypeName; - } - - private void setDeclaringTypeName(String declaringTypeName) { - String old = this.declaringTypeName; - this.declaringTypeName = declaringTypeName; - this.firePropertyChanged(DECLARING_TYPE_NAME_PROPERTY, old, declaringTypeName); - } - - private String buildDeclaringTypeName() { - IType declaringType = this.getMember().getDeclaringType(); - return (declaringType == null) ? null : declaringType.getFullyQualifiedName('.'); // no parameters are included here - } - - // ***** abstract - public boolean isAbstract() { - return this.abstract_; - } - - private void setAbstract(boolean abstract_) { - boolean old = this.abstract_; - this.abstract_ = abstract_; - this.firePropertyChanged(ABSTRACT_PROPERTY, old, abstract_); - } - - private boolean buildAbstract() { - try { - return Flags.isAbstract(this.getMember().getFlags()); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return false; - } - } - - // ***** static - public boolean isStatic() { - return this.static_; - } - - private void setStatic(boolean static_) { - boolean old = this.static_; - this.static_ = static_; - this.firePropertyChanged(STATIC_PROPERTY, old, static_); - } - - private boolean buildStatic() { - try { - return Flags.isStatic(this.getMember().getFlags()); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return false; - } - } - - // ***** member - public boolean isMemberType() { - return this.memberType; - } - - private void setMemberType(boolean memberType) { - boolean old = this.memberType; - this.memberType = memberType; - this.firePropertyChanged(MEMBER_TYPE_PROPERTY, old, memberType); - } - - private boolean buildMemberType() { - try { - return this.getMember().isMember(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return false; - } - } - - // ***** no-arg constructor - public boolean hasNoArgConstructor() { - return this.hasNoArgConstructor; - } - - private void setHasNoArgConstructor(boolean hasNoArgConstructor) { - boolean old = this.hasNoArgConstructor; - this.hasNoArgConstructor = hasNoArgConstructor; - this.firePropertyChanged(NO_ARG_CONSTRUCTOR_PROPERTY, old, hasNoArgConstructor); - } - - private boolean buildHasNoArgConstructor() { - return this.findNoArgConstructor() != null; - } - - private IMethod findNoArgConstructor() { - try { - for (IMethod method : this.getMember().getMethods()) { - if (method.isConstructor()) { - return method; - } - } - } - catch (JavaModelException ex) { - JptCorePlugin.log(ex); - } - return null; - } - - // ***** private no-arg constructor - public boolean hasPrivateNoArgConstructor() { - return this.hasPrivateNoArgConstructor; - } - - private void setHasPrivateNoArgConstructor(boolean hasPrivateNoArgConstructor) { - boolean old = this.hasPrivateNoArgConstructor; - this.hasPrivateNoArgConstructor = hasPrivateNoArgConstructor; - this.firePropertyChanged(PRIVATE_NO_ARG_CONSTRUCTOR_PROPERTY, old, hasPrivateNoArgConstructor); - } - - private boolean buildHasPrivateNoArgConstructor() { - IMethod method = this.findNoArgConstructor(); - try { - return method != null && Flags.isPrivate(method.getFlags()); - } - catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return false; - } - } - - // ***** access - public AccessType getAccess() { - return this.access; - } - - private void setAccess(AccessType access) { - AccessType old = this.access; - this.access = access; - this.firePropertyChanged(ACCESS_PROPERTY, old, access); - } - - private AccessType buildAccess() { - return JPTTools.buildAccess(this); - } - - public boolean isMapped() { - for (Annotation each : CollectionTools.iterable(annotations())) { - if (CollectionTools.contains( - getAnnotationProvider().typeMappingAnnotationNames(), - each.getAnnotationName())) { - return true; - } - } - return false; - } - - /** - * check only persistable attributes - */ - public boolean hasAnyAnnotatedAttributes() { - for (Iterator<JavaResourcePersistentAttribute> stream = this.persistableAttributes(); stream.hasNext(); ) { - if (stream.next().isAnnotated()) { - return true; - } - } - return false; - } - - @Override - public IType getMember() { - return (IType) super.getMember(); - } - - - // ********** fields ********** - - public Iterator<JavaResourcePersistentAttribute> fields() { - return this.getFields().iterator(); - } - - private Iterable<JavaResourcePersistentAttribute> getFields() { - return new LiveCloneIterable<JavaResourcePersistentAttribute>(this.fields); - } - - public Iterator<JavaResourcePersistentAttribute> persistableFields() { - return this.persistableMembers(this.fields()); - } - - public Iterator<JavaResourcePersistentAttribute> persistableFieldsWithSpecifiedFieldAccess() { - return new FilteringIterator<JavaResourcePersistentAttribute>(this.persistableFields()) { - @Override - protected boolean accept(JavaResourcePersistentAttribute resourceAttribute) { - return resourceAttribute.getSpecifiedAccess() == AccessType.FIELD; - } - }; - } - - private void addField(JavaResourcePersistentAttribute field) { - this.addItemToCollection(field, this.fields, FIELDS_COLLECTION); - } - - private JavaResourcePersistentAttribute getField(String fieldName, int occurrence) { - for (JavaResourcePersistentAttribute field : this.getFields()) { - if (field.isFor(fieldName, occurrence)) { - return field; - } - } - return null; - } - - private void removeFields(Collection<JavaResourcePersistentAttribute> remove) { - this.removeItemsFromCollection(remove, this.fields, FIELDS_COLLECTION); - } - - private Vector<JavaResourcePersistentAttribute> buildFields() { - IField[] jdtFields = this.getFields(this.getMember()); - Vector<JavaResourcePersistentAttribute> result = new Vector<JavaResourcePersistentAttribute>(jdtFields.length); - for (IField jdtField : jdtFields) { - result.add(this.buildField(jdtField)); - } - return result; - } - - private IField[] getFields(IType type) { - try { - return type.getFields(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return EMPTY_FIELD_ARRAY; - } - } - private static final IField[] EMPTY_FIELD_ARRAY = new IField[0]; - - private JavaResourcePersistentAttribute buildField(IField jdtField) { - return new BinaryPersistentAttribute(this, jdtField); - } - - - // ********** methods ********** - - public Iterator<JavaResourcePersistentAttribute> methods() { - return this.getMethods().iterator(); - } - - private Iterable<JavaResourcePersistentAttribute> getMethods() { - return new LiveCloneIterable<JavaResourcePersistentAttribute>(this.methods); - } - - public Iterator<JavaResourcePersistentAttribute> persistableProperties() { - return persistableMembers(this.methods()); - } - - public Iterator<JavaResourcePersistentAttribute> persistablePropertiesWithSpecifiedPropertyAccess() { - return new FilteringIterator<JavaResourcePersistentAttribute>(this.persistableProperties()) { - @Override - protected boolean accept(JavaResourcePersistentAttribute resourceAttribute) { - return resourceAttribute.getSpecifiedAccess() == AccessType.PROPERTY; - } - }; - } - - private JavaResourcePersistentAttribute getMethod(MethodSignature signature, int occurrence) { - for (JavaResourcePersistentAttribute method : this.getMethods()) { - if (method.isFor(signature, occurrence)) { - return method; - } - } - return null; - } - - private void addMethod(JavaResourcePersistentAttribute method) { - this.addItemToCollection(method, this.methods, METHODS_COLLECTION); - } - - private void removeMethods(Collection<JavaResourcePersistentAttribute> remove) { - this.removeItemsFromCollection(remove, this.methods, METHODS_COLLECTION); - } - - private Vector<JavaResourcePersistentAttribute> buildMethods() { - IMethod[] jdtMethods = this.getMethods(this.getMember()); - Vector<JavaResourcePersistentAttribute> result = new Vector<JavaResourcePersistentAttribute>(jdtMethods.length); - for (IMethod jdtMethod : jdtMethods) { - result.add(this.buildMethod(jdtMethod)); - } - return result; - } - - private IMethod[] getMethods(IType type) { - try { - return type.getMethods(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return EMPTY_METHOD_ARRAY; - } - } - private static final IMethod[] EMPTY_METHOD_ARRAY = new IMethod[0]; - - private JavaResourcePersistentAttribute buildMethod(IMethod jdtMethod) { - return new BinaryPersistentAttribute(this, jdtMethod); - } - - - // ********** attributes ********** - - @SuppressWarnings("unchecked") - public Iterator<JavaResourcePersistentAttribute> persistableAttributes() { - return new CompositeIterator<JavaResourcePersistentAttribute>( - this.persistableFields(), - this.persistableProperties() - ); - } - - public Iterator<JavaResourcePersistentAttribute> persistableAttributes(AccessType specifiedAccess) { - if (specifiedAccess == null) { - throw new IllegalArgumentException("specified access is null"); //$NON-NLS-1$ - } - return (specifiedAccess == AccessType.FIELD) ? - this.persistableAttributesForFieldAccessType() : - this.persistableAttributesForPropertyAccessType(); - } - - @SuppressWarnings("unchecked") - private Iterator<JavaResourcePersistentAttribute> persistableAttributesForFieldAccessType() { - return new CompositeIterator<JavaResourcePersistentAttribute>( - this.persistableFields(), - this.persistablePropertiesWithSpecifiedPropertyAccess() - ); - } - - @SuppressWarnings("unchecked") - private Iterator<JavaResourcePersistentAttribute> persistableAttributesForPropertyAccessType() { - return new CompositeIterator<JavaResourcePersistentAttribute>( - this.persistableProperties(), - this.persistableFieldsWithSpecifiedFieldAccess() - ); - } - - - // ********** IType adapter ********** - - static class TypeAdapter implements Adapter { - private final IType type; - - TypeAdapter(IType type) { - super(); - this.type = type; - } - - public IType getElement() { - return this.type; - } - - public boolean isPersistable() { - return true; // we only build a JAR type if it is "persistable" - } - - public IAnnotation[] getAnnotations() throws JavaModelException { - return this.type.getAnnotations(); - } - - } - - - // ********** "persistable" check ********** - - static boolean typeIsPersistable(IType type) { - return (type != null) - && type.exists() - && JPTTools.typeIsPersistable(new JPTToolsAdapter(type)); - } - - - // ********** JPT tools adapter ********** - - /** - * JPTTools needs an adapter so it can work with either an IType - * or an ITypeBinding etc. - */ - static class JPTToolsAdapter implements JPTTools.TypeAdapter { - private final IType type; - - protected JPTToolsAdapter(IType type) { - super(); - if (type == null) { - throw new NullPointerException(); - } - this.type = type; - } - - public int getModifiers() { - try { - return this.type.getFlags(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return 0; - } - } - - public boolean isAnnotation() { - try { - return this.type.isAnnotation(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return false; - } - } - - public boolean isAnonymous() { - try { - return this.type.isAnonymous(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return false; - } - } - - public boolean isArray() { - return false; // ??? - } - - public boolean isEnum() { - try { - return this.type.isEnum(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return false; - } - } - - public boolean isInterface() { - try { - return this.type.isInterface(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return false; - } - } - - public boolean isLocal() { - try { - return this.type.isLocal(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return false; - } - } - - public boolean isMember() { - try { - return this.type.isMember(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return false; - } - } - - public boolean isPrimitive() { - return false; // ??? - } - - } - - - // ********** unsupported JavaResourcePersistentType implementation ********** - - public Iterator<JavaResourcePersistentType> types() { - throw new UnsupportedOperationException(); - } - - public Iterator<JavaResourcePersistentType> allTypes() { - throw new UnsupportedOperationException(); - } - - public Iterator<JavaResourcePersistentType> persistableTypes() { - throw new UnsupportedOperationException(); - } - - public boolean isGeneratedMetamodelTopLevelType(IPackageFragmentRoot sourceFolder) { - throw new UnsupportedOperationException(); - } - - public boolean isGeneratedMetamodelTopLevelType() { - throw new UnsupportedOperationException(); - } - - public boolean isMetamodel() { - throw new UnsupportedOperationException(); - } - - public GeneratedAnnotation getGeneratedAnnotation() { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentTypeCache.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentTypeCache.java deleted file mode 100644 index bc1b8a1225..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentTypeCache.java +++ /dev/null @@ -1,149 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import java.util.Iterator; -import java.util.Vector; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.jdt.core.IType; -import org.eclipse.jpt.core.JpaAnnotationProvider; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentTypeCache; -import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable; -import org.eclipse.jpt.utility.internal.iterables.TransformationIterable; -import org.eclipse.jpt.utility.internal.StringTools; - -/** - * cache used to hold binary "external" Java resource persistent types - * (typically derived from JARs on the project's build path) - */ -public final class BinaryPersistentTypeCache - extends RootBinaryNode - implements JavaResourcePersistentTypeCache -{ - /** populated on-demand */ - private final Vector<Entry> entries = new Vector<Entry>(); - - - // ********** construction ********** - - public BinaryPersistentTypeCache(JpaAnnotationProvider annotationProvider) { - super(null, annotationProvider); - } - - - // ********** JavaResourceNode.Root implementation ********** - - public Iterator<JavaResourcePersistentType> persistentTypes() { - return this.getPersistentTypes().iterator(); - } - - private Iterable<JavaResourcePersistentType> getPersistentTypes() { - return new TransformationIterable<Entry, JavaResourcePersistentType>(this.getEntries()) { - @Override - protected JavaResourcePersistentType transform(Entry entry) { - return entry.persistentType; - } - }; - } - - private Iterable<Entry> getEntries() { - return new LiveCloneIterable<Entry>(this.entries); - } - - - // ********** JavaResourcePersistentTypeCache implementation ********** - - public int persistentTypesSize() { - return this.entries.size(); - } - - public JavaResourcePersistentType addPersistentType(IType jdtType) { - Entry entry = this.buildEntry(jdtType); - this.entries.add(entry); - this.fireItemAdded(PERSISTENT_TYPES_COLLECTION, entry.persistentType); - return entry.persistentType; - } - - private Entry buildEntry(IType jdtType) { - return new Entry(this.buildPersistentType(jdtType), jdtType.getResource()); - } - - private JavaResourcePersistentType buildPersistentType(IType jdtType) { - return new BinaryPersistentType(this, jdtType); - } - - public boolean removePersistentTypes(IFile jarFile) { - boolean modified = false; - for (Entry entry : this.getEntries()) { - IResource resource = entry.resource; - if ((resource != null) && resource.equals(jarFile)) { - this.removeEntry(entry); - modified = true; - } - } - return modified; - } - - private void removeEntry(Entry entry) { - this.entries.remove(entry); - this.fireItemRemoved(PERSISTENT_TYPES_COLLECTION, entry.persistentType); - } - - - // ********** overrides ********** - - /** - * Ignore changes to this collection. Adds can be ignored since they are triggered - * by requests that will, themselves, trigger updates (typically during the - * update of an object that calls a setter with the newly-created resource - * type). Deletes will be accompanied by manual updates. - */ - @Override - protected void aspectChanged(String aspectName) { - if ((aspectName != null) && ! aspectName.equals(PERSISTENT_TYPES_COLLECTION)) { - super.aspectChanged(aspectName); - } - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.entries); - } - - - // ********** cache entry ********** - - /** - * Associate a persistent type with its resource. - * This will be a JAR in the case of a type loaded from a JAR that is in - * the Eclipse workspace. The resource will be null for a type loaded - * from a JAR or class directory outside of the workspace. - */ - static class Entry { - final JavaResourcePersistentType persistentType; - final IResource resource; - - Entry(JavaResourcePersistentType persistentType, IResource resource) { - super(); - this.persistentType = persistentType; - this.resource = resource; - } - - @Override - public String toString() { - return StringTools.buildToStringFor(this, this.persistentType); - } - - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPrimaryKeyJoinColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPrimaryKeyJoinColumnAnnotation.java deleted file mode 100644 index e4c9a1c5ab..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPrimaryKeyJoinColumnAnnotation.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestablePrimaryKeyJoinColumnAnnotation; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.PrimaryKeyJoinColumn - */ -public final class BinaryPrimaryKeyJoinColumnAnnotation - extends BinaryNamedColumnAnnotation - implements NestablePrimaryKeyJoinColumnAnnotation -{ - private String referencedColumnName; - - - public BinaryPrimaryKeyJoinColumnAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.referencedColumnName = this.buildReferencedColumnName(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setReferencedColumnName_(this.buildReferencedColumnName()); - } - - - // ********** BinaryNamedColumnAnnotation implementation ********** - - @Override - protected String getNameElementName() { - return JPA.PRIMARY_KEY_JOIN_COLUMN__NAME; - } - - @Override - protected String getColumnDefinitionElementName() { - return JPA.PRIMARY_KEY_JOIN_COLUMN__COLUMN_DEFINITION; - } - - - // ********** PrimaryKeyJoinColumnAnnotation implementation ********** - - // ***** referenced column name - public String getReferencedColumnName() { - return this.referencedColumnName; - } - - public void setReferencedColumnName(String referencedColumnName) { - throw new UnsupportedOperationException(); - } - - private void setReferencedColumnName_(String referencedColumnName) { - String old = this.referencedColumnName; - this.referencedColumnName = referencedColumnName; - this.firePropertyChanged(REFERENCED_COLUMN_NAME_PROPERTY, old, referencedColumnName); - } - - private String buildReferencedColumnName() { - return (String) this.getJdtMemberValue(JPA.PRIMARY_KEY_JOIN_COLUMN__REFERENCED_COLUMN_NAME); - } - - public TextRange getReferencedColumnNameTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean referencedColumnNameTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPrimaryKeyJoinColumnsAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPrimaryKeyJoinColumnsAnnotation.java deleted file mode 100644 index 53fb9f0d46..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPrimaryKeyJoinColumnsAnnotation.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.binary; - -import java.util.Vector; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestablePrimaryKeyJoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.PrimaryKeyJoinColumnsAnnotation; -import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable; - -/** - * javax.persistence.PrimaryKeyJoinColumns - */ -public final class BinaryPrimaryKeyJoinColumnsAnnotation - extends BinaryContainerAnnotation<NestablePrimaryKeyJoinColumnAnnotation> - implements PrimaryKeyJoinColumnsAnnotation -{ - private final Vector<NestablePrimaryKeyJoinColumnAnnotation> pkJoinColumns; - - - public BinaryPrimaryKeyJoinColumnsAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.pkJoinColumns = this.buildPkJoinColumns(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public Iterable<NestablePrimaryKeyJoinColumnAnnotation> getNestedAnnotations() { - return new LiveCloneIterable<NestablePrimaryKeyJoinColumnAnnotation>(this.pkJoinColumns); - } - - public int getNestedAnnotationsSize() { - return this.pkJoinColumns.size(); - } - - private Vector<NestablePrimaryKeyJoinColumnAnnotation> buildPkJoinColumns() { - Object[] jdtJoinColumns = this.getJdtMemberValues(JPA.PRIMARY_KEY_JOIN_COLUMNS__VALUE); - Vector<NestablePrimaryKeyJoinColumnAnnotation> result = new Vector<NestablePrimaryKeyJoinColumnAnnotation>(jdtJoinColumns.length); - for (Object jdtJoinColumn : jdtJoinColumns) { - result.add(new BinaryPrimaryKeyJoinColumnAnnotation(this, (IAnnotation) jdtJoinColumn)); - } - return result; - } - - @Override - public void update() { - super.update(); - this.updatePkJoinColumns(); - } - - // TODO - private void updatePkJoinColumns() { - throw new UnsupportedOperationException(); - } - -} - diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryQueryHintAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryQueryHintAnnotation.java deleted file mode 100644 index c3f76581e6..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryQueryHintAnnotation.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.QueryHintAnnotation; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.QueryHint - */ -class BinaryQueryHintAnnotation - extends BinaryAnnotation - implements QueryHintAnnotation -{ - private String name; - private String value; - - - BinaryQueryHintAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.name = this.buildName(); - this.value = this.buildValue(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setName_(this.buildName()); - this.setValue_(this.buildValue()); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - // ********** QueryHintAnnotation implementation ********** - - // ***** name - public String getName() { - return this.name; - } - - public void setName(String name) { - throw new UnsupportedOperationException(); - } - - private void setName_(String name) { - String old = this.name; - this.name = name; - this.firePropertyChanged(NAME_PROPERTY, old, name); - } - - private String buildName() { - return (String) this.getJdtMemberValue(JPA.QUERY_HINT__NAME); - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** value - public String getValue() { - return this.value; - } - - public void setValue(String value) { - throw new UnsupportedOperationException(); - } - - private void setValue_(String value) { - String old = this.value; - this.value = value; - this.firePropertyChanged(VALUE_PROPERTY, old, value); - } - - private String buildValue() { - return (String) this.getJdtMemberValue(JPA.QUERY_HINT__VALUE); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryRelationshipMappingAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryRelationshipMappingAnnotation.java deleted file mode 100644 index 6da0b80236..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryRelationshipMappingAnnotation.java +++ /dev/null @@ -1,233 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.jpa2.resource.java.RelationshipMapping2_0Annotation; -import org.eclipse.jpt.core.resource.java.CascadeType; -import org.eclipse.jpt.core.resource.java.FetchType; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.utility.internal.ArrayTools; - -/** - * javax.persistence.ManyToMany - * javax.persistence.ManyToOne - * javax.persistence.OneToMany - * javax.persistence.OneToOne - */ -abstract class BinaryRelationshipMappingAnnotation - extends BinaryAnnotation - implements RelationshipMapping2_0Annotation -{ - String targetEntity; - FetchType fetch; - boolean cascadeAll; - boolean cascadeMerge; - boolean cascadePersist; - boolean cascadeRefresh; - boolean cascadeRemove; - boolean cascadeDetach; //added in JPA 2.0 - - - BinaryRelationshipMappingAnnotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.targetEntity = this.buildTargetEntity(); - this.fetch = this.buildFetch(); - this.initializeCascadeTypes(this.buildCascadeTypes()); - } - - protected void initializeCascadeTypes(CascadeType[] cascadeTypes) { - this.cascadeAll = ArrayTools.contains(cascadeTypes, CascadeType.ALL); - this.cascadeMerge = ArrayTools.contains(cascadeTypes, CascadeType.MERGE); - this.cascadePersist = ArrayTools.contains(cascadeTypes, CascadeType.PERSIST); - this.cascadeRefresh = ArrayTools.contains(cascadeTypes, CascadeType.REFRESH); - this.cascadeRemove = ArrayTools.contains(cascadeTypes, CascadeType.REMOVE); - this.cascadeDetach = ArrayTools.contains(cascadeTypes, CascadeType.DETACH); - } - - @Override - public void update() { - super.update(); - this.setTargetEntity_(this.buildTargetEntity()); - this.setFetch_(this.buildFetch()); - this.updateCascadeTypes(this.buildCascadeTypes()); - } - - protected void updateCascadeTypes(CascadeType[] cascadeTypes) { - this.setCascadeAll_(ArrayTools.contains(cascadeTypes, CascadeType.ALL)); - this.setCascadeMerge_(ArrayTools.contains(cascadeTypes, CascadeType.MERGE)); - this.setCascadePersist_(ArrayTools.contains(cascadeTypes, CascadeType.PERSIST)); - this.setCascadeRefresh_(ArrayTools.contains(cascadeTypes, CascadeType.REFRESH)); - this.setCascadeRemove_(ArrayTools.contains(cascadeTypes, CascadeType.REMOVE)); - this.setCascadeDetach_(ArrayTools.contains(cascadeTypes, CascadeType.DETACH)); - } - - // ********** RelationshipMappingAnnotation implementation ********** - - // ***** target entity - public String getTargetEntity() { - return this.targetEntity; - } - - public void setTargetEntity(String targetEntity) { - throw new UnsupportedOperationException(); - } - - private void setTargetEntity_(String targetEntity) { - String old = this.targetEntity; - this.targetEntity = targetEntity; - this.firePropertyChanged(TARGET_ENTITY_PROPERTY, old, targetEntity); - this.firePropertyChanged(FULLY_QUALIFIED_TARGET_ENTITY_CLASS_NAME_PROPERTY, old, targetEntity); - } - - private String buildTargetEntity() { - return (String) this.getJdtMemberValue(this.getTargetEntityElementName()); - } - - abstract String getTargetEntityElementName(); - - public TextRange getTargetEntityTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** fully-qualified target entity class name - public String getFullyQualifiedTargetEntityClassName() { - return this.targetEntity; - } - - // ***** fetch - public FetchType getFetch() { - return this.fetch; - } - - public void setFetch(FetchType fetch) { - throw new UnsupportedOperationException(); - } - - private void setFetch_(FetchType fetch) { - FetchType old = this.fetch; - this.fetch = fetch; - this.firePropertyChanged(FETCH_PROPERTY, old, fetch); - } - - private FetchType buildFetch() { - return FetchType.fromJavaAnnotationValue(this.getJdtMemberValue(this.getFetchElementName())); - } - - abstract String getFetchElementName(); - - public TextRange getFetchTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** cascade - private CascadeType[] buildCascadeTypes() { - return CascadeType.fromJavaAnnotationValues(this.getJdtMemberValues(this.getCascadeElementName())); - } - - abstract String getCascadeElementName(); - - public TextRange getCascadeTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** cascade all - public boolean isCascadeAll() { - return this.cascadeAll; - } - - public void setCascadeAll(boolean cascadeAll) { - throw new UnsupportedOperationException(); - } - - private void setCascadeAll_(boolean cascadeAll) { - boolean old = this.cascadeAll; - this.cascadeAll = cascadeAll; - this.firePropertyChanged(CASCADE_ALL_PROPERTY, old, cascadeAll); - } - - // ***** cascade merge - public boolean isCascadeMerge() { - return this.cascadeMerge; - } - - public void setCascadeMerge(boolean cascadeMerge) { - throw new UnsupportedOperationException(); - } - - private void setCascadeMerge_(boolean cascadeMerge) { - boolean old = this.cascadeMerge; - this.cascadeMerge = cascadeMerge; - this.firePropertyChanged(CASCADE_MERGE_PROPERTY, old, cascadeMerge); - } - - // ***** cascade persist - public boolean isCascadePersist() { - return this.cascadePersist; - } - - public void setCascadePersist(boolean cascadePersist) { - throw new UnsupportedOperationException(); - } - - private void setCascadePersist_(boolean cascadePersist) { - boolean old = this.cascadePersist; - this.cascadePersist = cascadePersist; - this.firePropertyChanged(CASCADE_PERSIST_PROPERTY, old, cascadePersist); - } - - // ***** cascade refresh - public boolean isCascadeRefresh() { - return this.cascadeRefresh; - } - - public void setCascadeRefresh(boolean cascadeRefresh) { - throw new UnsupportedOperationException(); - } - - private void setCascadeRefresh_(boolean cascadeRefresh) { - boolean old = this.cascadeRefresh; - this.cascadeRefresh = cascadeRefresh; - this.firePropertyChanged(CASCADE_REFRESH_PROPERTY, old, cascadeRefresh); - } - - // ***** cascade remove - public boolean isCascadeRemove() { - return this.cascadeRemove; - } - - public void setCascadeRemove(boolean cascadeRemove) { - throw new UnsupportedOperationException(); - } - - private void setCascadeRemove_(boolean cascadeRemove) { - boolean old = this.cascadeRemove; - this.cascadeRemove = cascadeRemove; - this.firePropertyChanged(CASCADE_REMOVE_PROPERTY, old, cascadeRemove); - } - - // ***** cascade detach - JPA 2.0 - public boolean isCascadeDetach() { - return this.cascadeDetach; - } - - public void setCascadeDetach(boolean cascadeDetach) { - throw new UnsupportedOperationException(); - } - - private void setCascadeDetach_(boolean cascadeDetach) { - boolean old = this.cascadeDetach; - this.cascadeDetach = cascadeDetach; - this.firePropertyChanged(CASCADE_DETACH_PROPERTY, old, cascadeDetach); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinarySecondaryTableAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinarySecondaryTableAnnotation.java deleted file mode 100644 index 7e018e6cb9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinarySecondaryTableAnnotation.java +++ /dev/null @@ -1,115 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableSecondaryTableAnnotation; -import org.eclipse.jpt.core.resource.java.PrimaryKeyJoinColumnAnnotation; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.SecondaryTable - */ -public final class BinarySecondaryTableAnnotation - extends BinaryBaseTableAnnotation - implements NestableSecondaryTableAnnotation -{ - private final Vector<PrimaryKeyJoinColumnAnnotation> pkJoinColumns; - - public BinarySecondaryTableAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.pkJoinColumns = this.buildPkJoinColumns(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.updatePkJoinColumns(); - } - - - // ********** BinaryBaseTableAnnotation implementation ********** - - @Override - protected String getNameElementName() { - return JPA.SECONDARY_TABLE__NAME; - } - - @Override - protected String getSchemaElementName() { - return JPA.SECONDARY_TABLE__SCHEMA; - } - - @Override - protected String getCatalogElementName() { - return JPA.SECONDARY_TABLE__CATALOG; - } - - @Override - protected String getUniqueConstraintElementName() { - return JPA.SECONDARY_TABLE__UNIQUE_CONSTRAINTS; - } - - - // ************* SecondaryTableAnnotation implementation ******************* - - // ***** pk join columns - public ListIterator<PrimaryKeyJoinColumnAnnotation> pkJoinColumns() { - return new CloneListIterator<PrimaryKeyJoinColumnAnnotation>(this.pkJoinColumns); - } - - public int pkJoinColumnsSize() { - return this.pkJoinColumns.size(); - } - - public PrimaryKeyJoinColumnAnnotation pkJoinColumnAt(int index) { - return this.pkJoinColumns.get(index); - } - - public int indexOfPkJoinColumn(PrimaryKeyJoinColumnAnnotation pkJoinColumn) { - return this.pkJoinColumns.indexOf(pkJoinColumn); - } - - public PrimaryKeyJoinColumnAnnotation addPkJoinColumn(int index) { - throw new UnsupportedOperationException(); - } - - public void movePkJoinColumn(int targetIndex, int sourceIndex) { - throw new UnsupportedOperationException(); - } - - public void removePkJoinColumn(int index) { - throw new UnsupportedOperationException(); - } - - private Vector<PrimaryKeyJoinColumnAnnotation> buildPkJoinColumns() { - Object[] jdtJoinColumns = this.getJdtMemberValues(JPA.SECONDARY_TABLE__PK_JOIN_COLUMNS); - Vector<PrimaryKeyJoinColumnAnnotation> result = new Vector<PrimaryKeyJoinColumnAnnotation>(jdtJoinColumns.length); - for (Object jdtJoinColumn : jdtJoinColumns) { - result.add(new BinaryPrimaryKeyJoinColumnAnnotation(this, (IAnnotation) jdtJoinColumn)); - } - return result; - } - - // TODO - private void updatePkJoinColumns() { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinarySecondaryTablesAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinarySecondaryTablesAnnotation.java deleted file mode 100644 index 5dbc1fd97f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinarySecondaryTablesAnnotation.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.binary; - -import java.util.Vector; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.resource.java.NestableSecondaryTableAnnotation; -import org.eclipse.jpt.core.resource.java.SecondaryTablesAnnotation; -import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable; - -/** - * javax.persistence.SecondaryTables - */ -public final class BinarySecondaryTablesAnnotation - extends BinaryContainerAnnotation<NestableSecondaryTableAnnotation> - implements SecondaryTablesAnnotation -{ - private final Vector<NestableSecondaryTableAnnotation> secondaryTables; - - - public BinarySecondaryTablesAnnotation(JavaResourcePersistentType parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.secondaryTables = this.buildSecondaryTables(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public Iterable<NestableSecondaryTableAnnotation> getNestedAnnotations() { - return new LiveCloneIterable<NestableSecondaryTableAnnotation>(this.secondaryTables); - } - - public int getNestedAnnotationsSize() { - return this.secondaryTables.size(); - } - - private Vector<NestableSecondaryTableAnnotation> buildSecondaryTables() { - Object[] jdtSecondaryTables = this.getJdtMemberValues(JPA.SECONDARY_TABLES__VALUE); - Vector<NestableSecondaryTableAnnotation> result = new Vector<NestableSecondaryTableAnnotation>(jdtSecondaryTables.length); - for (Object jdtSecondaryTable : jdtSecondaryTables) { - result.add(new BinarySecondaryTableAnnotation(this, (IAnnotation) jdtSecondaryTable)); - } - return result; - } - - @Override - public void update() { - super.update(); - this.updateSecondaryTables(); - } - - // TODO - private void updateSecondaryTables() { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinarySequenceGeneratorAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinarySequenceGeneratorAnnotation.java deleted file mode 100644 index cfe2c821ba..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinarySequenceGeneratorAnnotation.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.SequenceGeneratorAnnotation; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.SequenceGenerator - */ -public abstract class BinarySequenceGeneratorAnnotation - extends BinaryGeneratorAnnotation - implements SequenceGeneratorAnnotation -{ - private String sequenceName; - - - protected BinarySequenceGeneratorAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.sequenceName = this.buildSequenceName(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setSequenceName_(this.buildSequenceName()); - } - - - // ********** BinaryGeneratorAnnotation implementation ********** - - @Override - String getNameElementName() { - return JPA.SEQUENCE_GENERATOR__NAME; - } - - @Override - String getInitialValueElementName() { - return JPA.SEQUENCE_GENERATOR__INITIAL_VALUE; - } - - @Override - String getAllocationSizeElementName() { - return JPA.SEQUENCE_GENERATOR__ALLOCATION_SIZE; - } - - - // ********** SequenceGeneratorAnnotation implementation ********** - - // ***** sequence name - public String getSequenceName() { - return this.sequenceName; - } - - public void setSequenceName(String sequenceName) { - throw new UnsupportedOperationException(); - } - - private void setSequenceName_(String sequenceName) { - String old = this.sequenceName; - this.sequenceName = sequenceName; - this.firePropertyChanged(SEQUENCE_NAME_PROPERTY, old, sequenceName); - } - - private String buildSequenceName() { - return (String) this.getJdtMemberValue(JPA.SEQUENCE_GENERATOR__SEQUENCE_NAME); - } - - public TextRange getSequenceNameTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean sequenceNameTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryTableAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryTableAnnotation.java deleted file mode 100644 index e7bcdc7306..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryTableAnnotation.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.resource.java.TableAnnotation; - -/** - * javax.persistence.Table - */ -public final class BinaryTableAnnotation - extends BinaryBaseTableAnnotation - implements TableAnnotation -{ - public BinaryTableAnnotation(JavaResourcePersistentType parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - - // ********** BinaryBaseTableAnnotation implementation ********** - - @Override - protected String getNameElementName() { - return JPA.TABLE__NAME; - } - - @Override - protected String getSchemaElementName() { - return JPA.TABLE__SCHEMA; - } - - @Override - protected String getCatalogElementName() { - return JPA.TABLE__CATALOG; - } - - @Override - protected String getUniqueConstraintElementName() { - return JPA.TABLE__UNIQUE_CONSTRAINTS; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryTableGeneratorAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryTableGeneratorAnnotation.java deleted file mode 100644 index 0ecdebbb42..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryTableGeneratorAnnotation.java +++ /dev/null @@ -1,293 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.TableGeneratorAnnotation; -import org.eclipse.jpt.core.resource.java.UniqueConstraintAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.TableGenerator - */ -public final class BinaryTableGeneratorAnnotation - extends BinaryGeneratorAnnotation - implements TableGeneratorAnnotation -{ - private String table; - private String schema; - private String catalog; - private String pkColumnName; - private String valueColumnName; - private String pkColumnValue; - private final Vector<UniqueConstraintAnnotation> uniqueConstraints; - - - public BinaryTableGeneratorAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.table = this.buildTable(); - this.schema = this.buildSchema(); - this.catalog = this.buildCatalog(); - this.pkColumnName = this.buildPkColumnName(); - this.valueColumnName = this.buildValueColumnName(); - this.pkColumnValue = this.buildPkColumnValue(); - this.uniqueConstraints = this.buildUniqueConstraints(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setTable_(this.buildTable()); - this.setSchema_(this.buildSchema()); - this.setCatalog_(this.buildCatalog()); - this.setPkColumnName_(this.buildPkColumnName()); - this.setValueColumnName_(this.buildValueColumnName()); - this.setPkColumnValue_(this.buildPkColumnValue()); - this.updateUniqueConstraints(); - } - - - // ********** AbstractGeneratorAnnotation implementation ********** - - @Override - String getNameElementName() { - return JPA.TABLE_GENERATOR__NAME; - } - - @Override - String getInitialValueElementName() { - return JPA.TABLE_GENERATOR__INITIAL_VALUE; - } - - @Override - String getAllocationSizeElementName() { - return JPA.TABLE_GENERATOR__ALLOCATION_SIZE; - } - - - // ********** TableGeneratorAnnotation implementation ********** - - // ***** table - public String getTable() { - return this.table; - } - - public void setTable(String table) { - throw new UnsupportedOperationException(); - } - - private void setTable_(String table) { - String old = this.table; - this.table = table; - this.firePropertyChanged(TABLE_PROPERTY, old, table); - } - - private String buildTable() { - return (String) this.getJdtMemberValue(JPA.TABLE_GENERATOR__TABLE); - } - - public TextRange getTableTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean tableTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** schema - public String getSchema() { - return this.schema; - } - - public void setSchema(String schema) { - throw new UnsupportedOperationException(); - } - - private void setSchema_(String schema) { - String old = this.schema; - this.schema = schema; - this.firePropertyChanged(SCHEMA_PROPERTY, old, schema); - } - - private String buildSchema() { - return (String) this.getJdtMemberValue(JPA.TABLE_GENERATOR__SCHEMA); - } - - public TextRange getSchemaTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean schemaTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** catalog - public String getCatalog() { - return this.catalog; - } - - public void setCatalog(String catalog) { - throw new UnsupportedOperationException(); - } - - private void setCatalog_(String catalog) { - String old = this.catalog; - this.catalog = catalog; - this.firePropertyChanged(CATALOG_PROPERTY, old, catalog); - } - - private String buildCatalog() { - return (String) this.getJdtMemberValue(JPA.TABLE_GENERATOR__CATALOG); - } - - public TextRange getCatalogTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean catalogTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** pk column name - public String getPkColumnName() { - return this.pkColumnName; - } - - public void setPkColumnName(String pkColumnName) { - throw new UnsupportedOperationException(); - } - - private void setPkColumnName_(String pkColumnName) { - String old = this.pkColumnName; - this.pkColumnName = pkColumnName; - this.firePropertyChanged(PK_COLUMN_NAME_PROPERTY, old, pkColumnName); - } - - private String buildPkColumnName() { - return (String) this.getJdtMemberValue(JPA.TABLE_GENERATOR__PK_COLUMN_NAME); - } - - public TextRange getPkColumnNameTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean pkColumnNameTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** value column name - public String getValueColumnName() { - return this.valueColumnName; - } - - public void setValueColumnName(String valueColumnName) { - throw new UnsupportedOperationException(); - } - - private void setValueColumnName_(String valueColumnName) { - String old = this.valueColumnName; - this.valueColumnName = valueColumnName; - this.firePropertyChanged(VALUE_COLUMN_NAME_PROPERTY, old, valueColumnName); - } - - private String buildValueColumnName() { - return (String) this.getJdtMemberValue(JPA.TABLE_GENERATOR__VALUE_COLUMN_NAME); - } - - public TextRange getValueColumnNameTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean valueColumnNameTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** pk column value - public String getPkColumnValue() { - return this.pkColumnValue; - } - - public void setPkColumnValue(String pkColumnValue) { - throw new UnsupportedOperationException(); - } - - private void setPkColumnValue_(String pkColumnValue) { - String old = this.pkColumnValue; - this.pkColumnValue = pkColumnValue; - this.firePropertyChanged(PK_COLUMN_VALUE_PROPERTY, old, pkColumnValue); - } - - private String buildPkColumnValue() { - return (String) this.getJdtMemberValue(JPA.TABLE_GENERATOR__PK_COLUMN_VALUE); - } - - public TextRange getPkColumnValueTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean pkColumnValueTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** unique constraints - public ListIterator<UniqueConstraintAnnotation> uniqueConstraints() { - return new CloneListIterator<UniqueConstraintAnnotation>(this.uniqueConstraints); - } - - public int uniqueConstraintsSize() { - return this.uniqueConstraints.size(); - } - - public UniqueConstraintAnnotation uniqueConstraintAt(int index) { - return this.uniqueConstraints.get(index); - } - - public int indexOfUniqueConstraint(UniqueConstraintAnnotation uniqueConstraint) { - return this.uniqueConstraints.indexOf(uniqueConstraint); - } - - public UniqueConstraintAnnotation addUniqueConstraint(int index) { - throw new UnsupportedOperationException(); - } - - public void moveUniqueConstraint(int targetIndex, int sourceIndex) { - throw new UnsupportedOperationException(); - } - - public void removeUniqueConstraint(int index) { - throw new UnsupportedOperationException(); - } - - private Vector<UniqueConstraintAnnotation> buildUniqueConstraints() { - Object[] jdtUniqueConstraints = this.getJdtMemberValues(JPA.TABLE_GENERATOR__UNIQUE_CONSTRAINTS); - Vector<UniqueConstraintAnnotation> result = new Vector<UniqueConstraintAnnotation>(jdtUniqueConstraints.length); - for (Object jdtUniqueConstraint : jdtUniqueConstraints) { - result.add(new BinaryUniqueConstraintAnnotation(this, (IAnnotation) jdtUniqueConstraint)); - } - return result; - } - - // TODO - private void updateUniqueConstraints() { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryTemporalAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryTemporalAnnotation.java deleted file mode 100644 index b4e6fd81ee..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryTemporalAnnotation.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.TemporalAnnotation; - -/** - * javax.persistence.Temporal - */ -public final class BinaryTemporalAnnotation - extends BinaryBaseTemporalAnnotation - implements TemporalAnnotation -{ - - public BinaryTemporalAnnotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - protected String getValueElementName() { - return JPA.TEMPORAL__VALUE; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryTransientAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryTransientAnnotation.java deleted file mode 100644 index 92e643fd4b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryTransientAnnotation.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.TransientAnnotation; - -/** - * javax.persistence.Transient - */ -public final class BinaryTransientAnnotation - extends BinaryAnnotation - implements TransientAnnotation -{ - - public BinaryTransientAnnotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryUniqueConstraintAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryUniqueConstraintAnnotation.java deleted file mode 100644 index 2d8af3aec7..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryUniqueConstraintAnnotation.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.UniqueConstraintAnnotation; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.UniqueConstraint - */ -final class BinaryUniqueConstraintAnnotation - extends BinaryAnnotation - implements UniqueConstraintAnnotation -{ - private final Vector<String> columnNames; - - - BinaryUniqueConstraintAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.columnNames = this.buildColumnNames(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.updateColumnNames(); - } - - // TODO - private void updateColumnNames() { - throw new UnsupportedOperationException(); - } - - - // ********** UniqueConstraintAnnotation implementation ********** - - // ***** column names - public ListIterator<String> columnNames() { - return new CloneListIterator<String>(this.columnNames); - } - - public int columnNamesSize() { - return this.columnNames.size(); - } - - private Vector<String> buildColumnNames() { - Object[] jdtColumnNames = this.getJdtMemberValues(JPA.UNIQUE_CONSTRAINT__COLUMN_NAMES); - Vector<String> result = new Vector<String>(jdtColumnNames.length); - for (Object jdtColumnName : jdtColumnNames) { - result.add((String) jdtColumnName); - } - return result; - } - - public void addColumnName(String columnName) { - throw new UnsupportedOperationException(); - } - - public void addColumnName(int index, String columnName) { - throw new UnsupportedOperationException(); - } - - public void moveColumnName(int targetIndex, int sourceIndex) { - throw new UnsupportedOperationException(); - } - - public boolean columnNamesTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public void removeColumnName(String columnName) { - throw new UnsupportedOperationException(); - } - - public void removeColumnName(int index) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryVersionAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryVersionAnnotation.java deleted file mode 100644 index 37f3256a19..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryVersionAnnotation.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * 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.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.VersionAnnotation; - -/** - * javax.persistence.Version - */ -public final class BinaryVersionAnnotation - extends BinaryAnnotation - implements VersionAnnotation -{ - - public BinaryVersionAnnotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/RootBinaryNode.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/RootBinaryNode.java deleted file mode 100644 index 1a8152c288..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/RootBinaryNode.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.binary; - -import org.eclipse.jpt.core.JpaAnnotationProvider; -import org.eclipse.jpt.core.JpaResourceModelListener; -import org.eclipse.jpt.core.JpaResourceType; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.utility.internal.ListenerList; - -/** - * JAR and external types - */ -abstract class RootBinaryNode - extends BinaryNode - implements JavaResourceNode.Root -{ - /** pluggable annotation provider */ - private final JpaAnnotationProvider annotationProvider; - - /** listeners notified whenever the resource model changes */ - private final ListenerList<JpaResourceModelListener> resourceModelListenerList = new ListenerList<JpaResourceModelListener>(JpaResourceModelListener.class); - - - // ********** construction ********** - - RootBinaryNode(JavaResourceNode parent, JpaAnnotationProvider annotationProvider) { - super(parent); - this.annotationProvider = annotationProvider; - } - - - // ********** overrides ********** - - @Override - protected boolean requiresParent() { - return false; - } - - @Override - public Root getRoot() { - return this; - } - - @Override - public JpaAnnotationProvider getAnnotationProvider() { - return this.annotationProvider; - } - - - // ********** JavaResourceNode.Root implementation ********** - - public void resourceModelChanged() { - for (JpaResourceModelListener listener : this.resourceModelListenerList.getListeners()) { - listener.resourceModelChanged(this); - } - } - - - // ********** JpaResourceModel implementation ********** - - public JpaResourceType getResourceType() { - return JptCorePlugin.JAR_RESOURCE_TYPE; - } - - public void addResourceModelListener(JpaResourceModelListener listener) { - this.resourceModelListenerList.add(listener); - } - - public void removeResourceModelListener(JpaResourceModelListener listener) { - this.resourceModelListenerList.remove(listener); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/AnnotationContainerTools.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/AnnotationContainerTools.java deleted file mode 100644 index 1b2a0e867e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/AnnotationContainerTools.java +++ /dev/null @@ -1,272 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.jdt.core.dom.ASTNode; -import org.eclipse.jdt.core.dom.Annotation; -import org.eclipse.jdt.core.dom.ArrayInitializer; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jdt.core.dom.Expression; -import org.eclipse.jdt.core.dom.ITypeBinding; -import org.eclipse.jdt.core.dom.MemberValuePair; -import org.eclipse.jdt.core.dom.NormalAnnotation; -import org.eclipse.jdt.core.dom.SingleMemberAnnotation; -import org.eclipse.jpt.core.resource.java.AnnotationContainer; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.utility.internal.CollectionTools; - -/** - * Utility methods for manipulating annotation containers. - */ -public final class AnnotationContainerTools { - - /** - * Add a nested annotation to the specified annotation container - * at the specified index. - * This method modifies both the resource model annotation container and the - * AST; with <em>no</em> change notification. - */ - public static <T extends NestableAnnotation> NestableAnnotation addNestedAnnotation(int index, AnnotationContainer<T> annotationContainer) { - // add a new annotation to the end of the list... - int sourceIndex = annotationContainer.getNestedAnnotationsSize(); - T nestedAnnotation = annotationContainer.addNestedAnnotation(); - nestedAnnotation.newAnnotation(); - // ...then move it to the specified index - moveNestedAnnotation(index, sourceIndex, annotationContainer); - return nestedAnnotation; - } - - /** - * Move the nested annotation at the specified source index in the - * specified annotation container to the specified target index. - * This method modifies both the resource model annotation container and the - * AST; with <em>no</em> change notification. - */ - public static <T extends NestableAnnotation> void moveNestedAnnotation(int targetIndex, int sourceIndex, AnnotationContainer<T> annotationContainer) { - if (targetIndex != sourceIndex) { - moveNestedAnnotation_(targetIndex, sourceIndex, annotationContainer); - } - } - - private static <T extends NestableAnnotation> void moveNestedAnnotation_(int targetIndex, int sourceIndex, AnnotationContainer<T> annotationContainer) { - NestableAnnotation nestedAnnotation = annotationContainer.moveNestedAnnotation(targetIndex, sourceIndex); - syncAstAnnotationsAfterMove(targetIndex, sourceIndex, annotationContainer, nestedAnnotation); - } - - /** - * An annotation was moved within the specified annotation container from - * the specified source index to the specified target index. - * Synchronize the AST annotations with the resource model annotation container, - * starting with the lower index to prevent overlap. - */ - private static <T extends NestableAnnotation> void syncAstAnnotationsAfterMove(int targetIndex, int sourceIndex, AnnotationContainer<T> annotationContainer, NestableAnnotation nestedAnnotation) { - // move the Java annotation to the end of the list... - nestedAnnotation.moveAnnotation(annotationContainer.getNestedAnnotationsSize()); - // ...then shift the other AST annotations over one slot... - List<T> nestableAnnotations = CollectionTools.list(annotationContainer.getNestedAnnotations()); - if (sourceIndex < targetIndex) { - for (int i = sourceIndex; i < targetIndex; i++) { - nestableAnnotations.get(i).moveAnnotation(i); - } - } else { - for (int i = sourceIndex; i > targetIndex; i-- ) { - nestableAnnotations.get(i).moveAnnotation(i); - } - } - // ...then move the AST annotation to the now empty slot at the target index - nestedAnnotation.moveAnnotation(targetIndex); - } - - /** - * Remove the nested annotation at the specified index in the - * specified annotation container. - * This method modifies both the resource model annotation container and the - * AST; with <em>no</em> change notification. - */ - public static <T extends NestableAnnotation> void removeNestedAnnotation(int index, AnnotationContainer<T> annotationContainer) { - T nestedAnnotation = annotationContainer.removeNestedAnnotation(index); - nestedAnnotation.removeAnnotation(); - syncAstAnnotationsAfterRemove(index, annotationContainer); - } - - /** - * An annotation was removed from the specified annotation container at the - * specified index. - * Synchronize the AST annotations with the resource model annotation container, - * starting at the specified index to prevent overlap. - */ - private static <T extends NestableAnnotation> void syncAstAnnotationsAfterRemove(int index, AnnotationContainer<T> annotationContainer) { - List<T> nestableAnnotations = CollectionTools.list(annotationContainer.getNestedAnnotations()); - for (int i = index; i < nestableAnnotations.size(); i++) { - // the indices are the same because the model annotations are - // already in the proper locations - it's the AST annotations that - // need to be moved to the matching location - nestableAnnotations.get(i).moveAnnotation(i); - } - } - - /** - * Initialize the specified resource model annotation container to be in - * sync with the specified AST. No change notification will occur. - */ - public static <T extends NestableAnnotation> void initialize(AnnotationContainer<T> annotationContainer, CompilationUnit astRoot) { - // ignore the nested AST annotations themselves - // (maybe someday we can use them during initialization...) - int size = getNestedAstAnnotations(astRoot, annotationContainer).size(); - for (int i = 0; i < size; i++) { - T nestedAnnotation = annotationContainer.addNestedAnnotation(); - nestedAnnotation.initialize(astRoot); - } - } - - /** - * Return a list of the nested AST annotations. - */ - private static <T extends NestableAnnotation> ArrayList<Annotation> getNestedAstAnnotations(CompilationUnit astRoot, AnnotationContainer<T> annotationContainer) { - ArrayList<Annotation> result = new ArrayList<Annotation>(); - Annotation astContainerAnnotation = annotationContainer.getAstAnnotation(astRoot); - if (astContainerAnnotation == null || astContainerAnnotation.isMarkerAnnotation()) { - // no nested annotations - } - else if (astContainerAnnotation.isSingleMemberAnnotation()) { - if (annotationContainer.getElementName().equals("value")) { //$NON-NLS-1$ - Expression ex = ((SingleMemberAnnotation) astContainerAnnotation).getValue(); - addAstAnnotationsTo(ex, annotationContainer.getNestedAnnotationName(), result); - } else { - // no nested annotations - } - } - else if (astContainerAnnotation.isNormalAnnotation()) { - MemberValuePair pair = getMemberValuePair((NormalAnnotation) astContainerAnnotation, annotationContainer.getElementName()); - if (pair == null) { - // no nested annotations - } else { - addAstAnnotationsTo(pair.getValue(), annotationContainer.getNestedAnnotationName(), result); - } - } - return result; - } - - /** - * Add whatever annotations are represented by the specified expression to - * the specified list. Do not add null to the list for any non-annotation expression. - */ - private static void addAstAnnotationsTo(Expression expression, String annotationName, ArrayList<Annotation> astAnnotations) { - if (expression == null) { - //do not add null to the list, not sure how we would get here... - } - else if (expression.getNodeType() == ASTNode.ARRAY_INITIALIZER) { - addAstAnnotationsTo((ArrayInitializer) expression, annotationName, astAnnotations); - } - else { - Annotation astAnnotation = getAstAnnotation_(expression, annotationName); - if (astAnnotation != null) { - astAnnotations.add(astAnnotation); - } - } - } - - private static void addAstAnnotationsTo(ArrayInitializer arrayInitializer, String annotationName, ArrayList<Annotation> astAnnotations) { - @SuppressWarnings("unchecked") - List<Expression> expressions = arrayInitializer.expressions(); - for (Expression expression : expressions) { - Annotation astAnnotation = getAstAnnotation(expression, annotationName); - if (astAnnotation != null) { - astAnnotations.add(astAnnotation); - } - } - } - - /** - * If the specified expression is an annotation with the specified name, return it; - * otherwise return null. - */ - private static Annotation getAstAnnotation(Expression expression, String annotationName) { - // not sure how the expression could be null... - return (expression == null) ? null : getAstAnnotation_(expression, annotationName); - } - - /** - * pre-condition: expression is not null - */ - private static Annotation getAstAnnotation_(Expression expression, String annotationName) { - switch (expression.getNodeType()) { - case ASTNode.NORMAL_ANNOTATION: - case ASTNode.SINGLE_MEMBER_ANNOTATION: - case ASTNode.MARKER_ANNOTATION: - Annotation astAnnotation = (Annotation) expression; - if (getQualifiedName(astAnnotation).equals(annotationName)) { - return astAnnotation; - } - return null; - default: - return null; - } - } - - private static String getQualifiedName(Annotation astAnnotation) { - ITypeBinding typeBinding = astAnnotation.resolveTypeBinding(); - if (typeBinding != null) { - String resolvedName = typeBinding.getQualifiedName(); - if (resolvedName != null) { - return resolvedName; - } - } - return astAnnotation.getTypeName().getFullyQualifiedName(); - } - - private static MemberValuePair getMemberValuePair(NormalAnnotation annotation, String elementName) { - @SuppressWarnings("unchecked") - List<MemberValuePair> pairs = annotation.values(); - for (MemberValuePair pair : pairs) { - if (pair.getName().getFullyQualifiedName().equals(elementName)) { - return pair; - } - } - return null; - } - - /** - * Synchronize the resource model annotations in the specified annotation - * container with those in the specified AST. Trigger the appropriate change - * notification. - */ - public static <T extends NestableAnnotation> void synchronize(AnnotationContainer<T> annotationContainer, CompilationUnit astRoot) { - ArrayList<Annotation> astAnnotations = getNestedAstAnnotations(astRoot, annotationContainer); - Iterator<Annotation> astAnnotationStream = astAnnotations.iterator(); - - for (T nestedAnnotation : annotationContainer.getNestedAnnotations()) { - if (astAnnotationStream.hasNext()) { - // matching AST annotation is present - synchronize the nested annotation - astAnnotationStream.next(); // maybe someday we can pass this to the update - nestedAnnotation.synchronizeWith(astRoot); - } else { - // no more AST annotations - remove the remaining nested annotations and exit - annotationContainer.syncRemoveNestedAnnotations(astAnnotations.size()); - return; - } - } - - // add nested annotations for any remaining AST annotations - while (astAnnotationStream.hasNext()) { - annotationContainer.syncAddNestedAnnotation(astAnnotationStream.next()); - } - } - - private AnnotationContainerTools() { - super(); - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAnnotatedElement.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAnnotatedElement.java deleted file mode 100644 index 21f7269431..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAnnotatedElement.java +++ /dev/null @@ -1,441 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 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.source; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; -import java.util.Vector; - -import org.eclipse.jdt.core.dom.ASTNode; -import org.eclipse.jdt.core.dom.ASTVisitor; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jdt.core.dom.MarkerAnnotation; -import org.eclipse.jdt.core.dom.NormalAnnotation; -import org.eclipse.jdt.core.dom.SingleMemberAnnotation; -import org.eclipse.jpt.core.internal.utility.jdt.ASTNodeTextRange; -import org.eclipse.jpt.core.internal.utility.jdt.ASTTools; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.ContainerAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable; -import org.eclipse.jpt.utility.internal.iterators.EmptyIterator; -import org.eclipse.jpt.utility.internal.iterators.SingleElementIterator; - -/** - * Java source annotated element (annotations) - */ -abstract class SourceAnnotatedElement<A extends AnnotatedElement> - extends SourceNode - implements JavaResourceAnnotatedElement -{ - final A annotatedElement; - - /** - * annotations; no duplicates (java compiler has an error for duplicates) - */ - final Vector<Annotation> annotations = new Vector<Annotation>(); - - - // ********** construction/initialization ********** - - SourceAnnotatedElement(JavaResourceNode parent, A annotatedElement) { - super(parent); - this.annotatedElement = annotatedElement; - } - - public void initialize(CompilationUnit astRoot) { - this.annotatedElement.getBodyDeclaration(astRoot).accept(this.buildInitialAnnotationVisitor(astRoot)); - } - - private ASTVisitor buildInitialAnnotationVisitor(CompilationUnit astRoot) { - return new InitialAnnotationVisitor(astRoot, this.annotatedElement.getBodyDeclaration(astRoot)); - } - - /** - * called from {@link InitialAnnotationVisitor} - */ - /* private */ void addInitialAnnotation(org.eclipse.jdt.core.dom.Annotation node, CompilationUnit astRoot) { - String jdtAnnotationName = ASTTools.resolveAnnotation(node); - if (jdtAnnotationName != null) { - this.addInitialAnnotation(jdtAnnotationName, astRoot); - } - } - - /** - * pre-condition: jdtAnnotationName is not null - */ - void addInitialAnnotation(String jdtAnnotationName, CompilationUnit astRoot) { - if (this.annotationIsValid(jdtAnnotationName)) { - if (this.selectAnnotationNamed(this.annotations, jdtAnnotationName) == null) { // ignore duplicates - Annotation annotation = this.buildAnnotation(jdtAnnotationName); - annotation.initialize(astRoot); - this.annotations.add(annotation); - } - } - } - - public void synchronizeWith(CompilationUnit astRoot) { - this.syncAnnotations(astRoot); - } - - - // ********** annotations ********** - - public Iterator<Annotation> annotations() { - return this.getAnnotations().iterator(); - } - - Iterable<Annotation> getAnnotations() { - return new LiveCloneIterable<Annotation>(this.annotations); - } - - public int annotationsSize() { - return this.annotations.size(); - } - - public Annotation getAnnotation(String annotationName) { - return this.selectAnnotationNamed(this.getAnnotations(), annotationName); - } - - public Annotation getNonNullAnnotation(String annotationName) { - Annotation annotation = this.getAnnotation(annotationName); - return (annotation != null) ? annotation : this.buildNullAnnotation(annotationName); - } - - public Iterator<NestableAnnotation> annotations(String nestableAnnotationName, String containerAnnotationName) { - ContainerAnnotation<NestableAnnotation> containerAnnotation = this.getContainerAnnotation(containerAnnotationName); - if (containerAnnotation != null) { - return containerAnnotation.getNestedAnnotations().iterator(); - } - NestableAnnotation nestableAnnotation = this.getNestableAnnotation(nestableAnnotationName); - if (nestableAnnotation != null) { - return new SingleElementIterator<NestableAnnotation>(nestableAnnotation); - } - return EmptyIterator.instance(); - } - - // minimize scope of suppressed warnings - @SuppressWarnings("unchecked") - private ContainerAnnotation<NestableAnnotation> getContainerAnnotation(String annotationName) { - return (ContainerAnnotation<NestableAnnotation>) this.getAnnotation(annotationName); - } - - private NestableAnnotation getNestableAnnotation(String annotationName) { - return (NestableAnnotation) this.getAnnotation(annotationName); - } - - public Annotation addAnnotation(String annotationName) { - Annotation annotation = this.buildAnnotation(annotationName); - this.annotations.add(annotation); - annotation.newAnnotation(); - return annotation; - } - - /** - * 1. check for a container annotation; - * if it is present, add a nested annotation to it - * 2. check for a stand-alone nested annotation; - * if it is missing, add a stand-alone nested annotation - * 3. if there is an existing stand-alone nested annotation, - * add a container annotation and move the stand-alone nested annotation to it - * and add a new nested annotation to it also - */ - public NestableAnnotation addAnnotation(int index, String nestableAnnotationName, String containerAnnotationName) { - ContainerAnnotation<NestableAnnotation> containerAnnotation = this.getContainerAnnotation(containerAnnotationName); - if (containerAnnotation != null) { - // ignore any stand-alone nestable annotations and just add to the container annotation - return AnnotationContainerTools.addNestedAnnotation(index, containerAnnotation); - } - NestableAnnotation standAloneAnnotation = this.getNestableAnnotation(nestableAnnotationName); - if (standAloneAnnotation == null) { - // add a stand-alone nestable annotation since neither the nestable nor the container exist - return (NestableAnnotation) this.addAnnotation(nestableAnnotationName); - } - // move the stand-alone nestable annotation to a container and add another nestable - return this.addSecondNestedAnnotation(index, containerAnnotationName, standAloneAnnotation); - } - - /** - * "move" the existing nestable annotation to a new container annotation and - * add a new nestable annotation at the specified index (which should be 0 or 1) - */ - private NestableAnnotation addSecondNestedAnnotation(int index, String containerAnnotationName, NestableAnnotation standAloneAnnotation) { - ContainerAnnotation<NestableAnnotation> containerAnnotation = this.buildContainerAnnotation(containerAnnotationName); - this.annotations.add(containerAnnotation); - containerAnnotation.newAnnotation(); - - NestableAnnotation nestedAnnotation0 = containerAnnotation.addNestedAnnotation(); - nestedAnnotation0.newAnnotation(); - NestableAnnotation nestedAnnotation1 = containerAnnotation.addNestedAnnotation(); - nestedAnnotation1.newAnnotation(); - this.removeAnnotation(standAloneAnnotation); - - if (index == 0) { - // adding new annotation at 0, so stand-alone is "copied" to slot 1 - nestedAnnotation1.initializeFrom(standAloneAnnotation); - } else { - // adding new annotation at 1, so stand-alone is "copied" to slot 0 - nestedAnnotation0.initializeFrom(standAloneAnnotation); - } - - return (index == 0) ? nestedAnnotation0 : nestedAnnotation1; - } - - public void moveAnnotation(int targetIndex, int sourceIndex, String containerAnnotationName) { - this.moveAnnotation(targetIndex, sourceIndex, this.getContainerAnnotation(containerAnnotationName)); - } - - private void moveAnnotation(int targetIndex, int sourceIndex, ContainerAnnotation<NestableAnnotation> containerAnnotation) { - AnnotationContainerTools.moveNestedAnnotation(targetIndex, sourceIndex, containerAnnotation); - } - - public void removeAnnotation(String annotationName) { - Annotation annotation = this.getAnnotation(annotationName); - if (annotation != null) { - this.removeAnnotation(annotation); - } - } - - private void removeAnnotation(Annotation annotation) { - this.annotations.remove(annotation); - annotation.removeAnnotation(); - } - - public void removeAnnotation(int index, String nestableAnnotationName, String containerAnnotationName) { - ContainerAnnotation<NestableAnnotation> containerAnnotation = this.getContainerAnnotation(containerAnnotationName); - if (containerAnnotation == null) { // assume the index is 0 - this.removeAnnotation(this.getAnnotation(nestableAnnotationName)); - } else { - this.removeAnnotation(index, containerAnnotation); - } - } - - /** - * after we remove the nested annotation, check to see whether we need to - * either remove the container (if it is empty) or convert the last nested - * annotation to a stand-alone annotation - */ - private void removeAnnotation(int index, ContainerAnnotation<NestableAnnotation> containerAnnotation) { - AnnotationContainerTools.removeNestedAnnotation(index, containerAnnotation); - switch (containerAnnotation.getNestedAnnotationsSize()) { - case 0: - this.removeAnnotation(containerAnnotation); - break; - case 1: - this.convertLastNestedAnnotation(containerAnnotation); - break; - default: - break; - } - } - - /** - * convert the last nested annotation in the container to a stand-alone - * annotation - */ - private void convertLastNestedAnnotation(ContainerAnnotation<NestableAnnotation> containerAnnotation) { - NestableAnnotation lastNestedAnnotation = containerAnnotation.getNestedAnnotations().iterator().next(); - this.annotations.remove(containerAnnotation); - containerAnnotation.removeAnnotation(); - - NestableAnnotation standAloneAnnotation = this.buildNestableAnnotation(lastNestedAnnotation.getAnnotationName()); - this.annotations.add(standAloneAnnotation); - standAloneAnnotation.newAnnotation(); - standAloneAnnotation.initializeFrom(lastNestedAnnotation); - } - - private boolean annotationIsValid(String annotationName) { - return CollectionTools.contains(this.validAnnotationNames(), annotationName); - } - - abstract Iterator<String> validAnnotationNames(); - - abstract Annotation buildAnnotation(String annotationName); - - abstract Annotation buildNullAnnotation(String annotationName); - - // minimize scope of suppressed warnings - @SuppressWarnings("unchecked") - private ContainerAnnotation<NestableAnnotation> buildContainerAnnotation(String annotationName) { - return (ContainerAnnotation<NestableAnnotation>) this.buildAnnotation(annotationName); - } - - private NestableAnnotation buildNestableAnnotation(String annotationName) { - return (NestableAnnotation) this.buildAnnotation(annotationName); - } - - private void syncAnnotations(CompilationUnit astRoot) { - HashSet<Annotation> annotationsToRemove = new HashSet<Annotation>(this.annotations); - - this.annotatedElement.getBodyDeclaration(astRoot).accept(this.buildSynchronizeAnnotationVisitor(astRoot, annotationsToRemove)); - - for (Annotation annotation : annotationsToRemove) { - this.removeItemFromCollection(annotation, this.annotations, ANNOTATIONS_COLLECTION); - } - } - - private ASTVisitor buildSynchronizeAnnotationVisitor(CompilationUnit astRoot, Set<Annotation> annotationsToRemove) { - return new SynchronizeAnnotationVisitor(astRoot, this.annotatedElement.getBodyDeclaration(astRoot), annotationsToRemove); - } - - /** - * called from {@link SynchronizeAnnotationVisitor} - */ - /* private */ void addOrSyncAnnotation(org.eclipse.jdt.core.dom.Annotation node, CompilationUnit astRoot, Set<Annotation> annotationsToRemove) { - String jdtAnnotationName = ASTTools.resolveAnnotation(node); - if (jdtAnnotationName != null) { - this.addOrSyncAnnotation(jdtAnnotationName, astRoot, annotationsToRemove); - } - } - - /** - * pre-condition: jdtAnnotationName is not null - */ - void addOrSyncAnnotation(String jdtAnnotationName, CompilationUnit astRoot, Set<Annotation> annotationsToRemove) { - if (this.annotationIsValid(jdtAnnotationName)) { - this.addOrSyncAnnotation_(jdtAnnotationName, astRoot, annotationsToRemove); - } - } - - /** - * pre-condition: jdtAnnotationName is valid - */ - private void addOrSyncAnnotation_(String jdtAnnotationName, CompilationUnit astRoot, Set<Annotation> annotationsToRemove) { - Annotation annotation = this.selectAnnotationNamed(annotationsToRemove, jdtAnnotationName); - if (annotation != null) { - annotation.synchronizeWith(astRoot); - annotationsToRemove.remove(annotation); - } else { - annotation = this.buildAnnotation(jdtAnnotationName); - annotation.initialize(astRoot); - this.addItemToCollection(annotation, this.annotations, ANNOTATIONS_COLLECTION); - } - } - - - // ********** miscellaneous ********** - - public boolean isAnnotated() { - return ! this.annotations.isEmpty(); - } - - public TextRange getTextRange(CompilationUnit astRoot) { - return this.fullTextRange(astRoot); - } - - private TextRange fullTextRange(CompilationUnit astRoot) { - return this.buildTextRange(this.annotatedElement.getBodyDeclaration(astRoot)); - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - return this.annotatedElement.getNameTextRange(astRoot); - } - - private Annotation selectAnnotationNamed(Iterable<Annotation> list, String annotationName) { - for (Annotation annotation : list) { - if (annotation.getAnnotationName().equals(annotationName)) { - return annotation; - } - } - return null; - } - - private TextRange buildTextRange(ASTNode astNode) { - return (astNode == null) ? null : new ASTNodeTextRange(astNode); - } - - - // ********** AST visitors ********** - - /** - * annotation visitor - */ - protected static abstract class AnnotationVisitor - extends ASTVisitor - { - protected final CompilationUnit astRoot; - protected final ASTNode node; - - - protected AnnotationVisitor(CompilationUnit astRoot, ASTNode node) { - super(); - this.astRoot = astRoot; - this.node = node; - } - - @Override - public boolean visit(SingleMemberAnnotation node) { - return this.visit_(node); - } - - @Override - public boolean visit(NormalAnnotation node) { - return this.visit_(node); - } - - @Override - public boolean visit(MarkerAnnotation node) { - return this.visit_(node); - } - - protected boolean visit_(org.eclipse.jdt.core.dom.Annotation node) { - // ignore annotations for child members, only this member - if (node.getParent() == this.node) { - this.visitChildAnnotation(node); - } - return false; - } - - protected abstract void visitChildAnnotation(org.eclipse.jdt.core.dom.Annotation node); - } - - - /** - * initial annotation visitor - */ - protected class InitialAnnotationVisitor - extends AnnotationVisitor - { - protected InitialAnnotationVisitor(CompilationUnit astRoot, ASTNode node) { - super(astRoot, node); - } - - @Override - protected void visitChildAnnotation(org.eclipse.jdt.core.dom.Annotation node) { - SourceAnnotatedElement.this.addInitialAnnotation(node, this.astRoot); - } - } - - - /** - * synchronize annotation visitor - */ - protected class SynchronizeAnnotationVisitor - extends AnnotationVisitor - { - protected final Set<Annotation> annotationsToRemove; - - protected SynchronizeAnnotationVisitor(CompilationUnit astRoot, ASTNode node, Set<Annotation> annotationsToRemove) { - super(astRoot, node); - this.annotationsToRemove = annotationsToRemove; - } - - @Override - protected void visitChildAnnotation(org.eclipse.jdt.core.dom.Annotation node) { - SourceAnnotatedElement.this.addOrSyncAnnotation(node, this.astRoot, this.annotationsToRemove); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAnnotation.java deleted file mode 100644 index 6a95185d73..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAnnotation.java +++ /dev/null @@ -1,146 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import org.eclipse.jdt.core.dom.ASTNode; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jdt.core.dom.Expression; -import org.eclipse.jpt.core.internal.utility.jdt.ASTNodeTextRange; -import org.eclipse.jpt.core.internal.utility.jdt.ElementAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; - -/** - * some common state and behavior for Java source annotations; - * and lots of convenience methods - */ -public abstract class SourceAnnotation<A extends AnnotatedElement> - extends SourceNode - implements Annotation -{ - protected final A annotatedElement; - - protected final DeclarationAnnotationAdapter daa; - - protected final AnnotationAdapter annotationAdapter; - - - /** - * constructor for straight member annotation - */ - protected SourceAnnotation(JavaResourceNode parent, A annotatedElement, DeclarationAnnotationAdapter daa) { - this(parent, annotatedElement, daa, new ElementAnnotationAdapter(annotatedElement, daa)); - } - - /** - * constructor for nested annotation (typically) - */ - protected SourceAnnotation(JavaResourceNode parent, A annotatedElement, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { - super(parent); - this.annotatedElement = annotatedElement; - this.daa = daa; - this.annotationAdapter = annotationAdapter; - } - - - // ********** JavaResourceNode implementation ********** - - public TextRange getTextRange(CompilationUnit astRoot) { - return this.getAnnotationTextRange(astRoot); - } - - - // ********** Annotation implementation ********** - - public org.eclipse.jdt.core.dom.Annotation getAstAnnotation(CompilationUnit astRoot) { - return this.annotationAdapter.getAnnotation(astRoot); - } - - public void newAnnotation() { - this.annotationAdapter.newMarkerAnnotation(); - } - - public void removeAnnotation() { - this.annotationAdapter.removeAnnotation(); - } - - - // ********** convenience methods ********** - - /** - * Return the text range corresponding to the annotation. - * If the annotation is missing, return null. - */ - protected TextRange getAnnotationTextRange(CompilationUnit astRoot) { - return this.getTextRange(this.getAstAnnotation(astRoot)); - } - - /** - * Convenience method. - * Return the text range corresponding to the specified element. - * If the specified element is missing, return the annotation's text range instead. - */ - protected TextRange getElementTextRange(DeclarationAnnotationElementAdapter<?> elementAdapter, CompilationUnit astRoot) { - return this.getElementTextRange(this.getAnnotationElementTextRange(elementAdapter, astRoot), astRoot); - } - - /** - * Convenience method. If the specified element text range is null - * return the member's text range instead. - */ - protected TextRange getElementTextRange(TextRange elementTextRange, CompilationUnit astRoot) { - return (elementTextRange != null) ? elementTextRange : this.getAnnotationTextRange(astRoot); - } - - /** - * Convenience method. Return whether the specified position exists and - * touches the specified element. - */ - protected boolean elementTouches(DeclarationAnnotationElementAdapter<?> elementAdapter, int pos, CompilationUnit astRoot) { - return this.textRangeTouches(this.getAnnotationElementTextRange(elementAdapter, astRoot), pos); - } - - /** - * Convenience method. Return whether the specified text range is not - * null (meaning the corresponding AST node exists) and the specified position touches it. - */ - protected boolean textRangeTouches(TextRange textRange, int pos) { - return (textRange != null) && textRange.touches(pos); - } - - /** - * Return the text range corresponding to the specified element. - * If the element is missing, return null. - */ - protected TextRange getAnnotationElementTextRange(DeclarationAnnotationElementAdapter<?> adapter, CompilationUnit astRoot) { - return this.getTextRange(this.getAnnotationElementExpression(adapter, astRoot)); - } - - /** - * Return the specified AST DOM element. - */ - protected Expression getAnnotationElementExpression(DeclarationAnnotationElementAdapter<?> adapter, CompilationUnit astRoot) { - return adapter.getExpression(this.annotatedElement.getModifiedDeclaration(astRoot)); - } - - /** - * Return the text range corresponding to the specified AST node. - * If the AST node is null, return null. - */ - protected TextRange getTextRange(ASTNode astNode) { - return (astNode == null) ? null : new ASTNodeTextRange(astNode); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAssociationOverrideAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAssociationOverrideAnnotation.java deleted file mode 100644 index 4034302844..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAssociationOverrideAnnotation.java +++ /dev/null @@ -1,218 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.dom.Annotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.AnnotationContainer; -import org.eclipse.jpt.core.resource.java.AssociationOverrideAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.resource.java.NestableAssociationOverrideAnnotation; -import org.eclipse.jpt.core.resource.java.NestableJoinColumnAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.StringTools; -import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.AssociationOverride - */ -public abstract class SourceAssociationOverrideAnnotation - extends SourceOverrideAnnotation - implements NestableAssociationOverrideAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final Vector<NestableJoinColumnAnnotation> joinColumns = new Vector<NestableJoinColumnAnnotation>(); - private final JoinColumnsAnnotationContainer joinColumnsContainer = new JoinColumnsAnnotationContainer(); - - - // ********** construction/initialization ********** - - protected SourceAssociationOverrideAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { - super(parent, member, daa, annotationAdapter); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - AnnotationContainerTools.initialize(this.joinColumnsContainer, astRoot); - } - - @Override - public void synchronizeWith(CompilationUnit astRoot) { - super.synchronizeWith(astRoot); - AnnotationContainerTools.synchronize(this.joinColumnsContainer, astRoot); - } - - - // ********** SourceOverrideAnnotation implementation ********** - - @Override - protected String getNameElementName() { - return JPA.ASSOCIATION_OVERRIDE__NAME; - } - - - // ********** AssociationOverrideAnnotation implementation ********** - - // ***** join columns - public ListIterator<JoinColumnAnnotation> joinColumns() { - return new CloneListIterator<JoinColumnAnnotation>(this.joinColumns); - } - - Iterable<NestableJoinColumnAnnotation> getNestableJoinColumns() { - return new LiveCloneIterable<NestableJoinColumnAnnotation>(this.joinColumns); - } - - public int joinColumnsSize() { - return this.joinColumns.size(); - } - - public NestableJoinColumnAnnotation joinColumnAt(int index) { - return this.joinColumns.get(index); - } - - public int indexOfJoinColumn(JoinColumnAnnotation joinColumn) { - return this.joinColumns.indexOf(joinColumn); - } - - public NestableJoinColumnAnnotation addJoinColumn(int index) { - return (NestableJoinColumnAnnotation) AnnotationContainerTools.addNestedAnnotation(index, this.joinColumnsContainer); - } - - NestableJoinColumnAnnotation addJoinColumn_() { - return this.addJoinColumn_(this.joinColumns.size()); - } - - private NestableJoinColumnAnnotation addJoinColumn_(int index) { - NestableJoinColumnAnnotation joinColumn = this.buildJoinColumn(index); - this.joinColumns.add(joinColumn); - return joinColumn; - } - - void syncAddJoinColumn(Annotation astAnnotation) { - int index = this.joinColumns.size(); - NestableJoinColumnAnnotation joinColumn = this.addJoinColumn_(index); - joinColumn.initialize((CompilationUnit) astAnnotation.getRoot()); - this.fireItemAdded(JOIN_COLUMNS_LIST, index, joinColumn); - } - - private NestableJoinColumnAnnotation buildJoinColumn(int index) { - return SourceJoinColumnAnnotation.createAssociationOverrideJoinColumn(this.daa, this, this.annotatedElement, index); - } - - void joinColumnAdded(int index, NestableJoinColumnAnnotation joinColumn) { - this.fireItemAdded(JOIN_COLUMNS_LIST, index, joinColumn); - } - - public void moveJoinColumn(int targetIndex, int sourceIndex) { - AnnotationContainerTools.moveNestedAnnotation(targetIndex, sourceIndex, this.joinColumnsContainer); - } - - NestableJoinColumnAnnotation moveJoinColumn_(int targetIndex, int sourceIndex) { - return CollectionTools.move(this.joinColumns, targetIndex, sourceIndex).get(targetIndex); - } - - public void removeJoinColumn(int index) { - AnnotationContainerTools.removeNestedAnnotation(index, this.joinColumnsContainer); - } - - NestableJoinColumnAnnotation removeJoinColumn_(int index) { - return this.joinColumns.remove(index); - } - - void syncRemoveJoinColumns(int index) { - this.removeItemsFromList(index, this.joinColumns, JOIN_COLUMNS_LIST); - } - - - // ********** NestableAnnotation implementation ********** - - @Override - public void initializeFrom(NestableAnnotation oldAnnotation) { - super.initializeFrom(oldAnnotation); - AssociationOverrideAnnotation oldOverride = (AssociationOverrideAnnotation) oldAnnotation; - for (JoinColumnAnnotation oldJoinColumn : CollectionTools.iterable(oldOverride.joinColumns())) { - NestableJoinColumnAnnotation newJoinColumn = this.addJoinColumn(oldOverride.indexOfJoinColumn(oldJoinColumn)); - newJoinColumn.initializeFrom((NestableAnnotation) oldJoinColumn); - } - } - - // ********** join column container ********** - - /** - * adapt the AnnotationContainer interface to the override's join columns - */ - class JoinColumnsAnnotationContainer - implements AnnotationContainer<NestableJoinColumnAnnotation> - { - public org.eclipse.jdt.core.dom.Annotation getAstAnnotation(CompilationUnit astRoot) { - return SourceAssociationOverrideAnnotation.this.getAstAnnotation(astRoot); - } - - public String getElementName() { - return JPA.ASSOCIATION_OVERRIDE__JOIN_COLUMNS; - } - - public String getNestedAnnotationName() { - return JoinColumnAnnotation.ANNOTATION_NAME; - } - - public Iterable<NestableJoinColumnAnnotation> getNestedAnnotations() { - return SourceAssociationOverrideAnnotation.this.getNestableJoinColumns(); - } - - public int getNestedAnnotationsSize() { - return SourceAssociationOverrideAnnotation.this.joinColumnsSize(); - } - - public NestableJoinColumnAnnotation addNestedAnnotation() { - return SourceAssociationOverrideAnnotation.this.addJoinColumn_(); - } - - public void syncAddNestedAnnotation(Annotation astAnnotation) { - SourceAssociationOverrideAnnotation.this.syncAddJoinColumn(astAnnotation); - } - - public NestableJoinColumnAnnotation moveNestedAnnotation(int targetIndex, int sourceIndex) { - return SourceAssociationOverrideAnnotation.this.moveJoinColumn_(targetIndex, sourceIndex); - } - - public NestableJoinColumnAnnotation removeNestedAnnotation(int index) { - return SourceAssociationOverrideAnnotation.this.removeJoinColumn_(index); - } - - public void syncRemoveNestedAnnotations(int index) { - SourceAssociationOverrideAnnotation.this.syncRemoveJoinColumns(index); - } - - @Override - public String toString() { - return StringTools.buildToStringFor(this); - } - - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAssociationOverridesAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAssociationOverridesAnnotation.java deleted file mode 100644 index bb5930a7fd..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAssociationOverridesAnnotation.java +++ /dev/null @@ -1,110 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import java.util.Vector; - -import org.eclipse.jdt.core.dom.Annotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.AssociationOverrideAnnotation; -import org.eclipse.jpt.core.resource.java.AssociationOverridesAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableAssociationOverrideAnnotation; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable; - -/** - * javax.persistence.AssociationOverrides - */ -public abstract class SourceAssociationOverridesAnnotation - extends SourceAnnotation<Member> - implements AssociationOverridesAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final Vector<NestableAssociationOverrideAnnotation> associationOverrides = new Vector<NestableAssociationOverrideAnnotation>(); - - - protected SourceAssociationOverridesAnnotation(JavaResourceNode parent, Member member) { - super(parent, member, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - AnnotationContainerTools.initialize(this, astRoot); - } - - public void synchronizeWith(CompilationUnit astRoot) { - AnnotationContainerTools.synchronize(this, astRoot); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.associationOverrides); - } - - - // ********** AnnotationContainer implementation ********** - - public String getElementName() { - return JPA.ASSOCIATION_OVERRIDES__VALUE; - } - - public String getNestedAnnotationName() { - return AssociationOverrideAnnotation.ANNOTATION_NAME; - } - - public Iterable<NestableAssociationOverrideAnnotation> getNestedAnnotations() { - return new LiveCloneIterable<NestableAssociationOverrideAnnotation>(this.associationOverrides); - } - - public int getNestedAnnotationsSize() { - return this.associationOverrides.size(); - } - - public NestableAssociationOverrideAnnotation addNestedAnnotation() { - return this.addNestedAnnotation(this.associationOverrides.size()); - } - - private NestableAssociationOverrideAnnotation addNestedAnnotation(int index) { - NestableAssociationOverrideAnnotation associationOverride = this.buildAssociationOverride(index); - this.associationOverrides.add(associationOverride); - return associationOverride; - } - - protected abstract NestableAssociationOverrideAnnotation buildAssociationOverride(int index); - - public void syncAddNestedAnnotation(Annotation astAnnotation) { - int index = this.associationOverrides.size(); - NestableAssociationOverrideAnnotation associationOverride = this.addNestedAnnotation(index); - associationOverride.initialize((CompilationUnit) astAnnotation.getRoot()); - this.fireItemAdded(ASSOCIATION_OVERRIDES_LIST, index, associationOverride); - } - - public NestableAssociationOverrideAnnotation moveNestedAnnotation(int targetIndex, int sourceIndex) { - return CollectionTools.move(this.associationOverrides, targetIndex, sourceIndex).get(targetIndex); - } - - public NestableAssociationOverrideAnnotation removeNestedAnnotation(int index) { - return this.associationOverrides.remove(index); - } - - public void syncRemoveNestedAnnotations(int index) { - this.removeItemsFromList(index, this.associationOverrides, ASSOCIATION_OVERRIDES_LIST); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAttributeOverrideAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAttributeOverrideAnnotation.java deleted file mode 100644 index 80f9aade75..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAttributeOverrideAnnotation.java +++ /dev/null @@ -1,158 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.NullAttributeOverrideColumnAnnotation; -import org.eclipse.jpt.core.internal.utility.jdt.ElementAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ElementIndexedAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.AttributeOverrideAnnotation; -import org.eclipse.jpt.core.resource.java.ColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.resource.java.NestableAttributeOverrideAnnotation; -import org.eclipse.jpt.core.resource.java.NestableColumnAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.AttributeOverride - */ -public final class SourceAttributeOverrideAnnotation - extends SourceOverrideAnnotation - implements NestableAttributeOverrideAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final ElementAnnotationAdapter columnAdapter; - private NestableColumnAnnotation column; - - - // ********** construction/initialization ********** - - public SourceAttributeOverrideAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { - super(parent, member, daa, annotationAdapter); - this.columnAdapter = new ElementAnnotationAdapter(this.annotatedElement, SourceColumnAnnotation.buildAttributeOverrideAnnotationAdapter(this.daa)); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - if (this.columnAdapter.getAnnotation(astRoot) != null) { - this.column = SourceColumnAnnotation.createAttributeOverrideColumn(this, this.annotatedElement, this.daa); - this.column.initialize(astRoot); - } - } - - @Override - public void synchronizeWith(CompilationUnit astRoot) { - super.synchronizeWith(astRoot); - this.syncColumn(astRoot); - } - - - // ********** SourceOverrideAnnotation implementation ********** - - @Override - protected String getNameElementName() { - return JPA.ATTRIBUTE_OVERRIDE__NAME; - } - - - //************ AttributeOverride implementation **************** - - // ***** column - public ColumnAnnotation getColumn() { - return this.column; - } - - public ColumnAnnotation getNonNullColumn() { - return (this.column != null) ? this.column : new NullAttributeOverrideColumnAnnotation(this); - } - - public NestableColumnAnnotation addColumn() { - if (this.column != null) { - throw new IllegalStateException("'column' element already exists: " + this.column); //$NON-NLS-1$ - } - this.column = SourceColumnAnnotation.createAttributeOverrideColumn(this, this.annotatedElement, this.daa); - this.column.newAnnotation(); - return this.column; - } - - public void removeColumn() { - if (this.column == null) { - throw new IllegalStateException("'column' element does not exist"); //$NON-NLS-1$ - } - this.column.removeAnnotation(); - this.column = null; - } - - private void syncColumn(CompilationUnit astRoot) { - if (this.columnAdapter.getAnnotation(astRoot) == null) { - this.syncColumn_(null); - } else { - if (this.column == null) { - NestableColumnAnnotation col = SourceColumnAnnotation.createAttributeOverrideColumn(this, this.annotatedElement, this.daa); - col.initialize(astRoot); - this.syncColumn_(col); - } else { - this.column.synchronizeWith(astRoot); - } - } - } - - private void syncColumn_(NestableColumnAnnotation astColumn) { - ColumnAnnotation old = this.column; - this.column = astColumn; - this.firePropertyChanged(COLUMN_PROPERTY, old, astColumn); - } - - - // ********** NestableAnnotation implementation ********** - - @Override - public void initializeFrom(NestableAnnotation oldAnnotation) { - super.initializeFrom(oldAnnotation); - AttributeOverrideAnnotation oldOverride = (AttributeOverrideAnnotation) oldAnnotation; - ColumnAnnotation oldColumn = oldOverride.getColumn(); - if (oldColumn != null) { - NestableColumnAnnotation newColumn = this.addColumn(); - newColumn.initializeFrom((NestableAnnotation) oldColumn); - } - } - - - // ********** static methods ********** - - public static SourceAttributeOverrideAnnotation buildAttributeOverride(JavaResourceNode parent, Member member) { - return new SourceAttributeOverrideAnnotation(parent, member, DECLARATION_ANNOTATION_ADAPTER, new ElementAnnotationAdapter(member, DECLARATION_ANNOTATION_ADAPTER)); - } - - static SourceAttributeOverrideAnnotation buildNestedAttributeOverride(JavaResourceNode parent, Member member, int index, DeclarationAnnotationAdapter attributeOverridesAdapter) { - IndexedDeclarationAnnotationAdapter idaa = buildNestedDeclarationAnnotationAdapter(index, attributeOverridesAdapter); - IndexedAnnotationAdapter annotationAdapter = new ElementIndexedAnnotationAdapter(member, idaa); - return new SourceAttributeOverrideAnnotation(parent, member, idaa, annotationAdapter); - } - - private static IndexedDeclarationAnnotationAdapter buildNestedDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter attributeOverridesAdapter) { - return new NestedIndexedDeclarationAnnotationAdapter(attributeOverridesAdapter, index, JPA.ATTRIBUTE_OVERRIDE); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAttributeOverridesAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAttributeOverridesAnnotation.java deleted file mode 100644 index b0e1f4d74f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAttributeOverridesAnnotation.java +++ /dev/null @@ -1,112 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import java.util.Vector; - -import org.eclipse.jdt.core.dom.Annotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.AttributeOverrideAnnotation; -import org.eclipse.jpt.core.resource.java.AttributeOverridesAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableAttributeOverrideAnnotation; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable; - -/** - * javax.persistence.AttributeOverrides - */ -public final class SourceAttributeOverridesAnnotation - extends SourceAnnotation<Member> - implements AttributeOverridesAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final Vector<NestableAttributeOverrideAnnotation> attributesOverrides = new Vector<NestableAttributeOverrideAnnotation>(); - - - public SourceAttributeOverridesAnnotation(JavaResourceNode parent, Member member) { - super(parent, member, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - AnnotationContainerTools.initialize(this, astRoot); - } - - public void synchronizeWith(CompilationUnit astRoot) { - AnnotationContainerTools.synchronize(this, astRoot); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.attributesOverrides); - } - - - // ********** AnnotationContainer implementation ********** - - public String getElementName() { - return JPA.ATTRIBUTE_OVERRIDES__VALUE; - } - - public String getNestedAnnotationName() { - return AttributeOverrideAnnotation.ANNOTATION_NAME; - } - - public Iterable<NestableAttributeOverrideAnnotation> getNestedAnnotations() { - return new LiveCloneIterable<NestableAttributeOverrideAnnotation>(this.attributesOverrides); - } - - public int getNestedAnnotationsSize() { - return this.attributesOverrides.size(); - } - - public NestableAttributeOverrideAnnotation addNestedAnnotation() { - return this.addNestedAnnotation(this.attributesOverrides.size()); - } - - private NestableAttributeOverrideAnnotation addNestedAnnotation(int index) { - NestableAttributeOverrideAnnotation attributeOverride = this.buildAttributeOverride(index); - this.attributesOverrides.add(attributeOverride); - return attributeOverride; - } - - public void syncAddNestedAnnotation(Annotation astAnnotation) { - int index = this.attributesOverrides.size(); - NestableAttributeOverrideAnnotation attributeOverride = this.addNestedAnnotation(index); - attributeOverride.initialize((CompilationUnit) astAnnotation.getRoot()); - this.fireItemAdded(ATTRIBUTE_OVERRIDES_LIST, index, attributeOverride); - } - - private NestableAttributeOverrideAnnotation buildAttributeOverride(int index) { - return SourceAttributeOverrideAnnotation.buildNestedAttributeOverride(this, this.annotatedElement, index, this.daa); - } - - public NestableAttributeOverrideAnnotation moveNestedAnnotation(int targetIndex, int sourceIndex) { - return CollectionTools.move(this.attributesOverrides, targetIndex, sourceIndex).get(targetIndex); - } - - public NestableAttributeOverrideAnnotation removeNestedAnnotation(int index) { - return this.attributesOverrides.remove(index); - } - - public void syncRemoveNestedAnnotations(int index) { - this.removeItemsFromList(index, this.attributesOverrides, ATTRIBUTE_OVERRIDES_LIST); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseColumnAnnotation.java deleted file mode 100644 index 2ce59879c6..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseColumnAnnotation.java +++ /dev/null @@ -1,252 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.ElementAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.BaseColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.Column - * javax.persistence.JoinColumn - */ -public abstract class SourceBaseColumnAnnotation - extends SourceNamedColumnAnnotation - implements BaseColumnAnnotation -{ - protected final DeclarationAnnotationElementAdapter<String> tableDeclarationAdapter; - protected final AnnotationElementAdapter<String> tableAdapter; - protected String table; - - protected final DeclarationAnnotationElementAdapter<Boolean> uniqueDeclarationAdapter; - protected final AnnotationElementAdapter<Boolean> uniqueAdapter; - protected Boolean unique; - - protected final DeclarationAnnotationElementAdapter<Boolean> nullableDeclarationAdapter; - protected final AnnotationElementAdapter<Boolean> nullableAdapter; - protected Boolean nullable; - - protected final DeclarationAnnotationElementAdapter<Boolean> insertableDeclarationAdapter; - protected final AnnotationElementAdapter<Boolean> insertableAdapter; - protected Boolean insertable; - - protected final DeclarationAnnotationElementAdapter<Boolean> updatableDeclarationAdapter; - protected final AnnotationElementAdapter<Boolean> updatableAdapter; - protected Boolean updatable; - - - protected SourceBaseColumnAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa) { - this(parent, member, daa, new ElementAnnotationAdapter(member, daa)); - } - - protected SourceBaseColumnAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { - super(parent, member, daa, annotationAdapter); - this.tableDeclarationAdapter = this.buildStringElementAdapter(this.getTableElementName()); - this.tableAdapter = this.buildShortCircuitElementAdapter(this.tableDeclarationAdapter); - this.uniqueDeclarationAdapter = this.buildBooleanElementAdapter(this.getUniqueElementName()); - this.uniqueAdapter = this.buildShortCircuitBooleanElementAdapter(this.uniqueDeclarationAdapter); - this.nullableDeclarationAdapter = this.buildBooleanElementAdapter(this.getNullableElementName()); - this.nullableAdapter = this.buildShortCircuitBooleanElementAdapter(this.nullableDeclarationAdapter); - this.insertableDeclarationAdapter = this.buildBooleanElementAdapter(this.getInsertableElementName()); - this.insertableAdapter = this.buildShortCircuitBooleanElementAdapter(this.insertableDeclarationAdapter); - this.updatableDeclarationAdapter = this.buildBooleanElementAdapter(this.getUpdatableElementName()); - this.updatableAdapter = this.buildShortCircuitBooleanElementAdapter(this.updatableDeclarationAdapter); - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.table = this.buildTable(astRoot); - this.unique = this.buildUnique(astRoot); - this.nullable = this.buildNullable(astRoot); - this.insertable = this.buildInsertable(astRoot); - this.updatable = this.buildUpdatable(astRoot); - } - - @Override - public void synchronizeWith(CompilationUnit astRoot) { - super.synchronizeWith(astRoot); - this.syncTable(this.buildTable(astRoot)); - this.syncUnique(this.buildUnique(astRoot)); - this.syncNullable(this.buildNullable(astRoot)); - this.syncInsertable(this.buildInsertable(astRoot)); - this.syncUpdatable(this.buildUpdatable(astRoot)); - } - - - //************* BaseColumnAnnotation implementation ************* - - // ***** table - public String getTable() { - return this.table; - } - - public void setTable(String table) { - if (this.attributeValueHasChanged(this.table, table)) { - this.table = table; - this.tableAdapter.setValue(table); - } - } - - private void syncTable(String astTable) { - String old = this.table; - this.table = astTable; - this.firePropertyChanged(TABLE_PROPERTY, old, astTable); - } - - private String buildTable(CompilationUnit astRoot) { - return this.tableAdapter.getValue(astRoot); - } - - public TextRange getTableTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.tableDeclarationAdapter, astRoot); - } - - public boolean tableTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(this.tableDeclarationAdapter, pos, astRoot); - } - - protected abstract String getTableElementName(); - - // ***** unique - public Boolean getUnique() { - return this.unique; - } - - public void setUnique(Boolean unique) { - if (this.attributeValueHasChanged(this.unique, unique)) { - this.unique = unique; - this.uniqueAdapter.setValue(unique); - } - } - - private void syncUnique(Boolean astUnique) { - Boolean old = this.unique; - this.unique = astUnique; - this.firePropertyChanged(UNIQUE_PROPERTY, old, astUnique); - } - - private Boolean buildUnique(CompilationUnit astRoot) { - return this.uniqueAdapter.getValue(astRoot); - } - - public TextRange getUniqueTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.uniqueDeclarationAdapter, astRoot); - } - - protected abstract String getUniqueElementName(); - - // ***** nullable - public Boolean getNullable() { - return this.nullable; - } - - public void setNullable(Boolean nullable) { - if (this.attributeValueHasChanged(this.nullable, nullable)) { - this.nullable = nullable; - this.nullableAdapter.setValue(nullable); - } - } - - private void syncNullable(Boolean astNullable) { - Boolean old = this.nullable; - this.nullable = astNullable; - this.firePropertyChanged(NULLABLE_PROPERTY, old, astNullable); - } - - private Boolean buildNullable(CompilationUnit astRoot) { - return this.nullableAdapter.getValue(astRoot); - } - - public TextRange getNullableTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.nullableDeclarationAdapter, astRoot); - } - - protected abstract String getNullableElementName(); - - // ***** insertable - public Boolean getInsertable() { - return this.insertable; - } - - public void setInsertable(Boolean insertable) { - if (this.attributeValueHasChanged(this.insertable, insertable)) { - this.insertable = insertable; - this.insertableAdapter.setValue(insertable); - } - } - - private void syncInsertable(Boolean astInsertable) { - Boolean old = this.insertable; - this.insertable = astInsertable; - this.firePropertyChanged(INSERTABLE_PROPERTY, old, astInsertable); - } - - private Boolean buildInsertable(CompilationUnit astRoot) { - return this.insertableAdapter.getValue(astRoot); - } - - public TextRange getInsertableTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.insertableDeclarationAdapter, astRoot); - } - - protected abstract String getInsertableElementName(); - - // ***** updatable - public Boolean getUpdatable() { - return this.updatable; - } - - public void setUpdatable(Boolean updatable) { - if (this.attributeValueHasChanged(this.updatable, updatable)) { - this.updatable = updatable; - this.updatableAdapter.setValue(updatable); - } - } - - private void syncUpdatable(Boolean astUpdatable) { - Boolean old = this.updatable; - this.updatable = astUpdatable; - this.firePropertyChanged(UPDATABLE_PROPERTY, old, astUpdatable); - } - - private Boolean buildUpdatable(CompilationUnit astRoot) { - return this.updatableAdapter.getValue(astRoot); - } - - public TextRange getUpdatableTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.updatableDeclarationAdapter, astRoot); - } - - protected abstract String getUpdatableElementName(); - - - //************* NestableAnnotation implementation ************* - - @Override - public void initializeFrom(NestableAnnotation oldAnnotation) { - super.initializeFrom(oldAnnotation); - BaseColumnAnnotation oldColumn = (BaseColumnAnnotation) oldAnnotation; - this.setTable(oldColumn.getTable()); - this.setUnique(oldColumn.getUnique()); - this.setNullable(oldColumn.getNullable()); - this.setInsertable(oldColumn.getInsertable()); - this.setUpdatable(oldColumn.getUpdatable()); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseEnumeratedAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseEnumeratedAnnotation.java deleted file mode 100644 index 5d877ff49e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseEnumeratedAnnotation.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.AnnotatedElementAnnotationElementAdapter; -import org.eclipse.jpt.core.resource.java.EnumType; -import org.eclipse.jpt.core.resource.java.EnumeratedAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; - -/** - * javax.persistence.Enumerated - * javax.persistence.MapKeyEnumerated - */ -public abstract class SourceBaseEnumeratedAnnotation - extends SourceAnnotation<Attribute> - implements EnumeratedAnnotation -{ - private final DeclarationAnnotationElementAdapter<String> valueDeclarationAdapter; - private final AnnotationElementAdapter<String> valueAdapter; - private EnumType value; - - - protected SourceBaseEnumeratedAnnotation(JavaResourceNode parent, Attribute attribute, DeclarationAnnotationAdapter daa) { - super(parent, attribute, daa); - this.valueDeclarationAdapter = new EnumDeclarationAnnotationElementAdapter(daa, getValueElementName(), false); - this.valueAdapter = new AnnotatedElementAnnotationElementAdapter<String>(attribute, this.valueDeclarationAdapter); - } - - public void initialize(CompilationUnit astRoot) { - this.value = this.buildValue(astRoot); - } - - public void synchronizeWith(CompilationUnit astRoot) { - this.syncValue(this.buildValue(astRoot)); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.value); - } - - - // ********** EnumeratedAnnotation implementation ********** - - // ***** value - public EnumType getValue() { - return this.value; - } - - public void setValue(EnumType value) { - if (this.attributeValueHasChanged(this.value, value)) { - this.value = value; - this.valueAdapter.setValue(EnumType.toJavaAnnotationValue(value)); - } - } - - private void syncValue(EnumType astValue) { - EnumType old = this.value; - this.value = astValue; - this.firePropertyChanged(VALUE_PROPERTY, old, astValue); - } - - private EnumType buildValue(CompilationUnit astRoot) { - return EnumType.fromJavaAnnotationValue(this.valueAdapter.getValue(astRoot)); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.valueDeclarationAdapter, astRoot); - } - - protected abstract String getValueElementName(); - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseJoinColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseJoinColumnAnnotation.java deleted file mode 100644 index 86a70da607..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseJoinColumnAnnotation.java +++ /dev/null @@ -1,118 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.ElementAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ElementIndexedAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.BaseJoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.JoinColumn - * javax.persistence.MapKeyJoinColumn - */ -public abstract class SourceBaseJoinColumnAnnotation - extends SourceBaseColumnAnnotation - implements BaseJoinColumnAnnotation -{ - private final DeclarationAnnotationElementAdapter<String> referencedColumnNameDeclarationAdapter; - private final AnnotationElementAdapter<String> referencedColumnNameAdapter; - private String referencedColumnName; - - - protected SourceBaseJoinColumnAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { - super(parent, member, daa, annotationAdapter); - this.referencedColumnNameDeclarationAdapter = this.buildStringElementAdapter(this.getReferencedColumnNameElementName()); - this.referencedColumnNameAdapter = this.buildShortCircuitElementAdapter(this.referencedColumnNameDeclarationAdapter); - } - - protected SourceBaseJoinColumnAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa) { - this(parent, member, daa, new ElementAnnotationAdapter(member, daa)); - } - - protected SourceBaseJoinColumnAnnotation(JavaResourceNode parent, Member member, IndexedDeclarationAnnotationAdapter idaa) { - this(parent, member, idaa, new ElementIndexedAnnotationAdapter(member, idaa)); - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.referencedColumnName = this.buildReferencedColumnName(astRoot); - } - - @Override - public void synchronizeWith(CompilationUnit astRoot) { - super.synchronizeWith(astRoot); - this.syncReferencedColumnName(this.buildReferencedColumnName(astRoot)); - } - - protected abstract String getReferencedColumnNameElementName(); - - - //************ BaseJoinColumnAnnotation implementation *************** - - // referenced column name - public String getReferencedColumnName() { - return this.referencedColumnName; - } - - public void setReferencedColumnName(String referencedColumnName) { - if (this.attributeValueHasChanged(this.referencedColumnName, referencedColumnName)) { - this.referencedColumnName = referencedColumnName; - this.referencedColumnNameAdapter.setValue(referencedColumnName); - } - } - - private void syncReferencedColumnName(String astReferencedColumnName) { - String old = this.referencedColumnName; - this.referencedColumnName = astReferencedColumnName; - this.firePropertyChanged(REFERENCED_COLUMN_NAME_PROPERTY, old, astReferencedColumnName); - } - - private String buildReferencedColumnName(CompilationUnit astRoot) { - return this.referencedColumnNameAdapter.getValue(astRoot); - } - - public TextRange getReferencedColumnNameTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.referencedColumnNameDeclarationAdapter, astRoot); - } - - public boolean referencedColumnNameTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(this.referencedColumnNameDeclarationAdapter, pos, astRoot); - } - - - // ********** NestableAnnotation implementation ********** - - @Override - public void initializeFrom(NestableAnnotation oldAnnotation) { - super.initializeFrom(oldAnnotation); - BaseJoinColumnAnnotation oldJoinColumn = (BaseJoinColumnAnnotation) oldAnnotation; - this.setReferencedColumnName(oldJoinColumn.getReferencedColumnName()); - } - - public void moveAnnotation(int newIndex) { - this.getIndexedAnnotationAdapter().moveAnnotation(newIndex); - } - - protected IndexedAnnotationAdapter getIndexedAnnotationAdapter() { - return (IndexedAnnotationAdapter) this.annotationAdapter; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseNamedQueryAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseNamedQueryAnnotation.java deleted file mode 100644 index 2327e06502..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseNamedQueryAnnotation.java +++ /dev/null @@ -1,311 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.dom.Annotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.AnnotatedElementAnnotationElementAdapter; -import org.eclipse.jpt.core.resource.java.AnnotationContainer; -import org.eclipse.jpt.core.resource.java.BaseNamedQueryAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.resource.java.NestableQueryHintAnnotation; -import org.eclipse.jpt.core.resource.java.QueryHintAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Type; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.StringTools; -import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.NamedQuery - * javax.persistence.NamedNativeQuery - */ -abstract class SourceBaseNamedQueryAnnotation - extends SourceAnnotation<Type> - implements BaseNamedQueryAnnotation -{ - final DeclarationAnnotationElementAdapter<String> nameDeclarationAdapter; - final AnnotationElementAdapter<String> nameAdapter; - String name; - - final DeclarationAnnotationElementAdapter<String> queryDeclarationAdapter; - final AnnotationElementAdapter<String> queryAdapter; - String query; - - final Vector<NestableQueryHintAnnotation> hints = new Vector<NestableQueryHintAnnotation>(); - final HintsAnnotationContainer hintsContainer = new HintsAnnotationContainer(); - - - SourceBaseNamedQueryAnnotation(JavaResourceNode parent, Type type,DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { - super(parent, type, daa, annotationAdapter); - this.nameDeclarationAdapter = this.buildNameAdapter(daa); - this.queryDeclarationAdapter = this.buildQueryAdapter(daa); - this.nameAdapter = this.buildAdapter(this.nameDeclarationAdapter); - this.queryAdapter = this.buildAdapter(this.queryDeclarationAdapter); - } - - public void initialize(CompilationUnit astRoot) { - this.name = this.buildName(astRoot); - this.query = this.buildQuery(astRoot); - AnnotationContainerTools.initialize(this.hintsContainer, astRoot); - } - - public void synchronizeWith(CompilationUnit astRoot) { - this.syncName(this.buildName(astRoot)); - this.syncQuery(this.buildQuery(astRoot)); - AnnotationContainerTools.synchronize(this.hintsContainer, astRoot); - } - - /** - * convenience method - */ - protected AnnotationElementAdapter<String> buildAdapter(DeclarationAnnotationElementAdapter<String> daea) { - return new AnnotatedElementAnnotationElementAdapter<String>(this.annotatedElement, daea); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - // ********** BaseNamedQueryAnnotation implementation ********** - - // ***** name - public String getName() { - return this.name; - } - - public void setName(String name) { - if (this.attributeValueHasChanged(this.name, name)) { - this.name = name; - this.nameAdapter.setValue(name); - } - } - - private void syncName(String astName) { - String old = this.name; - this.name = astName; - this.firePropertyChanged(NAME_PROPERTY, old, astName); - } - - private String buildName(CompilationUnit astRoot) { - return this.nameAdapter.getValue(astRoot); - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.nameDeclarationAdapter, astRoot); - } - - private DeclarationAnnotationElementAdapter<String> buildNameAdapter(DeclarationAnnotationAdapter daAdapter) { - return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter, this.getNameElementName()); - } - - abstract String getNameElementName(); - - // ***** query - public String getQuery() { - return this.query; - } - - public void setQuery(String query) { - if (this.attributeValueHasChanged(this.query, query)) { - this.query = query; - this.queryAdapter.setValue(query); - } - } - - private void syncQuery(String annotationQuery) { - String old = this.query; - this.query = annotationQuery; - this.firePropertyChanged(QUERY_PROPERTY, old, annotationQuery); - } - - private String buildQuery(CompilationUnit astRoot) { - return this.queryAdapter.getValue(astRoot); - } - - public TextRange getQueryTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.queryDeclarationAdapter, astRoot); - } - - private DeclarationAnnotationElementAdapter<String> buildQueryAdapter(DeclarationAnnotationAdapter daAdapter) { - return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter, this.getQueryElementName()); - } - - abstract String getQueryElementName(); - - // ***** hints - public ListIterator<QueryHintAnnotation> hints() { - return new CloneListIterator<QueryHintAnnotation>(this.hints); - } - - Iterable<NestableQueryHintAnnotation> getNestableHints() { - return new LiveCloneIterable<NestableQueryHintAnnotation>(this.hints); - } - - public int hintsSize() { - return this.hints.size(); - } - - public NestableQueryHintAnnotation hintAt(int index) { - return this.hints.get(index); - } - - public int indexOfHint(QueryHintAnnotation hint) { - return this.hints.indexOf(hint); - } - - public NestableQueryHintAnnotation addHint(int index) { - return (NestableQueryHintAnnotation) AnnotationContainerTools.addNestedAnnotation(index, this.hintsContainer); - } - - NestableQueryHintAnnotation addHint_() { - return this.addHint_(this.hints.size()); - } - - private NestableQueryHintAnnotation addHint_(int index) { - NestableQueryHintAnnotation hint = this.buildHint(index); - this.hints.add(hint); - return hint; - } - - void syncAddHint(Annotation astAnnotation) { - int index = this.hints.size(); - NestableQueryHintAnnotation hint = this.addHint_(index); - hint.initialize((CompilationUnit) astAnnotation.getRoot()); - this.fireItemAdded(HINTS_LIST, index, hint); - } - - abstract NestableQueryHintAnnotation buildHint(int index); - - void hintAdded(int index, NestableQueryHintAnnotation hint) { - this.fireItemAdded(HINTS_LIST, index, hint); - } - - public void moveHint(int targetIndex, int sourceIndex) { - AnnotationContainerTools.moveNestedAnnotation(targetIndex, sourceIndex, this.hintsContainer); - } - - NestableQueryHintAnnotation moveHint_(int targetIndex, int sourceIndex) { - return CollectionTools.move(this.hints, targetIndex, sourceIndex).get(targetIndex); - } - - public void removeHint(int index) { - AnnotationContainerTools.removeNestedAnnotation(index, this.hintsContainer); - } - - NestableQueryHintAnnotation removeHint_(int index) { - return this.hints.remove(index); - } - - void syncRemoveHints(int index) { - this.removeItemsFromList(index, this.hints, HINTS_LIST); - } - - abstract String getHintsElementName(); - - - // ********** NestableAnnotation implementation ********** - - /** - * convenience implementation of method from NestableAnnotation interface - * for subclasses - */ - public void initializeFrom(NestableAnnotation oldAnnotation) { - BaseNamedQueryAnnotation oldQuery = (BaseNamedQueryAnnotation) oldAnnotation; - this.setName(oldQuery.getName()); - this.setQuery(oldQuery.getQuery()); - for (QueryHintAnnotation oldHint : CollectionTools.iterable(oldQuery.hints())) { - NestableQueryHintAnnotation newHint = this.addHint(oldQuery.indexOfHint(oldHint)); - newHint.initializeFrom((NestableQueryHintAnnotation) oldHint); - } - } - - /** - * convenience implementation of method from NestableAnnotation interface - * for subclasses - */ - public void moveAnnotation(int newIndex) { - this.getIndexedAnnotationAdapter().moveAnnotation(newIndex); - } - - private IndexedAnnotationAdapter getIndexedAnnotationAdapter() { - return (IndexedAnnotationAdapter) this.annotationAdapter; - } - - - // ********** hint container ********** - - /** - * adapt the AnnotationContainer interface to the override's join columns - */ - class HintsAnnotationContainer - implements AnnotationContainer<NestableQueryHintAnnotation> - { - public Annotation getAstAnnotation(CompilationUnit astRoot) { - return SourceBaseNamedQueryAnnotation.this.getAstAnnotation(astRoot); - } - - public String getElementName() { - return SourceBaseNamedQueryAnnotation.this.getHintsElementName(); - } - - public String getNestedAnnotationName() { - return QueryHintAnnotation.ANNOTATION_NAME; - } - - public Iterable<NestableQueryHintAnnotation> getNestedAnnotations() { - return SourceBaseNamedQueryAnnotation.this.getNestableHints(); - } - - public int getNestedAnnotationsSize() { - return SourceBaseNamedQueryAnnotation.this.hintsSize(); - } - - public NestableQueryHintAnnotation addNestedAnnotation() { - return SourceBaseNamedQueryAnnotation.this.addHint_(); - } - - public void syncAddNestedAnnotation(Annotation astAnnotation) { - SourceBaseNamedQueryAnnotation.this.syncAddHint(astAnnotation); - } - - public NestableQueryHintAnnotation moveNestedAnnotation(int targetIndex, int sourceIndex) { - return SourceBaseNamedQueryAnnotation.this.moveHint_(targetIndex, sourceIndex); - } - - public NestableQueryHintAnnotation removeNestedAnnotation(int index) { - return SourceBaseNamedQueryAnnotation.this.removeHint_(index); - } - - public void syncRemoveNestedAnnotations(int index) { - SourceBaseNamedQueryAnnotation.this.syncRemoveHints(index); - } - - @Override - public String toString() { - return StringTools.buildToStringFor(this); - } - - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseTableAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseTableAnnotation.java deleted file mode 100644 index 2416e19c97..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseTableAnnotation.java +++ /dev/null @@ -1,362 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.dom.Annotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.ElementAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.AnnotatedElementAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.AnnotationContainer; -import org.eclipse.jpt.core.resource.java.BaseTableAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.resource.java.NestableUniqueConstraintAnnotation; -import org.eclipse.jpt.core.resource.java.UniqueConstraintAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.StringTools; -import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.Table - * javax.persistence.JoinTable - * javax.persistence.SecondaryTable - * javax.persistence.CollectionTable - */ -public abstract class SourceBaseTableAnnotation - extends SourceAnnotation<Member> - implements BaseTableAnnotation -{ - final DeclarationAnnotationElementAdapter<String> nameDeclarationAdapter; - final AnnotationElementAdapter<String> nameAdapter; - String name; - - final DeclarationAnnotationElementAdapter<String> schemaDeclarationAdapter; - final AnnotationElementAdapter<String> schemaAdapter; - String schema; - - final DeclarationAnnotationElementAdapter<String> catalogDeclarationAdapter; - final AnnotationElementAdapter<String> catalogAdapter; - String catalog; - - final Vector<NestableUniqueConstraintAnnotation> uniqueConstraints = new Vector<NestableUniqueConstraintAnnotation>(); - final UniqueConstraintsAnnotationContainer uniqueConstraintsContainer = new UniqueConstraintsAnnotationContainer(); - - - protected SourceBaseTableAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa) { - this(parent, member, daa, new ElementAnnotationAdapter(member, daa)); - } - - protected SourceBaseTableAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { - super(parent, member, daa, annotationAdapter); - this.nameDeclarationAdapter = this.getNameAdapter(daa); - this.schemaDeclarationAdapter = this.getSchemaAdapter(daa); - this.catalogDeclarationAdapter = this.getCatalogAdapter(daa); - this.nameAdapter = this.buildAnnotationElementAdapter(this.nameDeclarationAdapter); - this.schemaAdapter = this.buildAnnotationElementAdapter(this.schemaDeclarationAdapter); - this.catalogAdapter = this.buildAnnotationElementAdapter(this.catalogDeclarationAdapter); - } - - private AnnotationElementAdapter<String> buildAnnotationElementAdapter(DeclarationAnnotationElementAdapter<String> daea) { - return new AnnotatedElementAnnotationElementAdapter<String>(this.annotatedElement, daea); - } - - public void initialize(CompilationUnit astRoot) { - this.name = this.buildName(astRoot); - this.schema = this.buildSchema(astRoot); - this.catalog = this.buildCatalog(astRoot); - AnnotationContainerTools.initialize(this.uniqueConstraintsContainer, astRoot); - } - - public void synchronizeWith(CompilationUnit astRoot) { - this.syncName(this.buildName(astRoot)); - this.syncSchema(this.buildSchema(astRoot)); - this.syncCatalog(this.buildCatalog(astRoot)); - AnnotationContainerTools.synchronize(this.uniqueConstraintsContainer, astRoot); - } - - /** - * Return the uniqueConstraints element name - */ - protected abstract String getUniqueConstraintsElementName(); - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - // ********** BaseTableAnnotation implementation ********** - - public boolean isSpecified() { - return true; - } - - // ***** name - public String getName() { - return this.name; - } - - public void setName(String name) { - if (this.attributeValueHasChanged(this.name, name)) { - this.name = name; - this.nameAdapter.setValue(name); - } - } - - private void syncName(String astName) { - String old = this.name; - this.name = astName; - this.firePropertyChanged(NAME_PROPERTY, old, astName); - } - - private String buildName(CompilationUnit astRoot) { - return this.nameAdapter.getValue(astRoot); - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.nameDeclarationAdapter, astRoot); - } - - public boolean nameTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(this.nameDeclarationAdapter, pos, astRoot); - } - - /** - * Build and return a declaration element adapter for the table's 'name' element - */ - protected abstract DeclarationAnnotationElementAdapter<String> getNameAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter); - - // ***** schema - public String getSchema() { - return this.schema; - } - - public void setSchema(String schema) { - if (this.attributeValueHasChanged(this.schema, schema)) { - this.schema = schema; - this.schemaAdapter.setValue(schema); - } - } - - private void syncSchema(String astSchema) { - String old = this.schema; - this.schema = astSchema; - this.firePropertyChanged(SCHEMA_PROPERTY, old, astSchema); - } - - private String buildSchema(CompilationUnit astRoot) { - return this.schemaAdapter.getValue(astRoot); - } - - public TextRange getSchemaTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.schemaDeclarationAdapter, astRoot); - } - - public boolean schemaTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(this.schemaDeclarationAdapter, pos, astRoot); - } - - /** - * Build and return a declaration element adapter for the table's 'schema' element - */ - protected abstract DeclarationAnnotationElementAdapter<String> getSchemaAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter); - - // ***** catalog - public String getCatalog() { - return this.catalog; - } - - public void setCatalog(String catalog) { - if (this.attributeValueHasChanged(this.catalog, catalog)) { - this.catalog = catalog; - this.catalogAdapter.setValue(catalog); - } - } - - private void syncCatalog(String astCatalog) { - String old = this.catalog; - this.catalog = astCatalog; - this.firePropertyChanged(CATALOG_PROPERTY, old, astCatalog); - } - - private String buildCatalog(CompilationUnit astRoot) { - return this.catalogAdapter.getValue(astRoot); - } - - public TextRange getCatalogTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.catalogDeclarationAdapter, astRoot); - } - - public boolean catalogTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(this.catalogDeclarationAdapter, pos, astRoot); - } - - /** - * Build and return a declaration element adapter for the table's 'catalog' element - */ - protected abstract DeclarationAnnotationElementAdapter<String> getCatalogAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter); - - // ***** unique constraints - public ListIterator<UniqueConstraintAnnotation> uniqueConstraints() { - return new CloneListIterator<UniqueConstraintAnnotation>(this.uniqueConstraints); - } - - Iterable<NestableUniqueConstraintAnnotation> getNestableUniqueConstraints() { - return new LiveCloneIterable<NestableUniqueConstraintAnnotation>(this.uniqueConstraints); - } - - public int uniqueConstraintsSize() { - return this.uniqueConstraints.size(); - } - - public NestableUniqueConstraintAnnotation uniqueConstraintAt(int index) { - return this.uniqueConstraints.get(index); - } - - public int indexOfUniqueConstraint(UniqueConstraintAnnotation uniqueConstraint) { - return this.uniqueConstraints.indexOf(uniqueConstraint); - } - - public NestableUniqueConstraintAnnotation addUniqueConstraint(int index) { - return (NestableUniqueConstraintAnnotation) AnnotationContainerTools.addNestedAnnotation(index, this.uniqueConstraintsContainer); - } - - NestableUniqueConstraintAnnotation addUniqueConstraint_() { - return this.addUniqueConstraint_(this.uniqueConstraints.size()); - } - - private NestableUniqueConstraintAnnotation addUniqueConstraint_(int index) { - NestableUniqueConstraintAnnotation uniqueConstraint = this.buildUniqueConstraint(index); - this.uniqueConstraints.add(uniqueConstraint); - return uniqueConstraint; - } - - void syncAddUniqueConstraint(Annotation astAnnotation) { - int index = this.uniqueConstraints.size(); - NestableUniqueConstraintAnnotation uniqueConstraint = this.addUniqueConstraint_(index); - uniqueConstraint.initialize((CompilationUnit) astAnnotation.getRoot()); - this.fireItemAdded(UNIQUE_CONSTRAINTS_LIST, index, uniqueConstraint); - } - - NestableUniqueConstraintAnnotation buildUniqueConstraint(int index) { - return new SourceUniqueConstraintAnnotation(this, this.annotatedElement, buildUniqueConstraintAnnotationAdapter(index)); - } - - IndexedDeclarationAnnotationAdapter buildUniqueConstraintAnnotationAdapter(int index) { - return new NestedIndexedDeclarationAnnotationAdapter(this.daa, getUniqueConstraintsElementName(), index, JPA.UNIQUE_CONSTRAINT); - } - - void uniqueConstraintAdded(int index, NestableUniqueConstraintAnnotation constraint) { - this.fireItemAdded(UNIQUE_CONSTRAINTS_LIST, index, constraint); - } - - public void moveUniqueConstraint(int targetIndex, int sourceIndex) { - AnnotationContainerTools.moveNestedAnnotation(targetIndex, sourceIndex, this.uniqueConstraintsContainer); - } - - NestableUniqueConstraintAnnotation moveUniqueConstraint_(int targetIndex, int sourceIndex) { - return CollectionTools.move(this.uniqueConstraints, targetIndex, sourceIndex).get(targetIndex); - } - - public void removeUniqueConstraint(int index) { - AnnotationContainerTools.removeNestedAnnotation(index, this.uniqueConstraintsContainer); - } - - NestableUniqueConstraintAnnotation removeUniqueConstraint_(int index) { - return this.uniqueConstraints.remove(index); - } - - void syncRemoveUniqueConstraints(int index) { - this.removeItemsFromList(index, this.uniqueConstraints, UNIQUE_CONSTRAINTS_LIST); - } - - - // ********** NestableAnnotation implementation ********** - - protected void initializeFrom(NestableAnnotation oldAnnotation) { - BaseTableAnnotation oldTable = (BaseTableAnnotation) oldAnnotation; - this.setName(oldTable.getName()); - this.setSchema(oldTable.getSchema()); - this.setCatalog(oldTable.getCatalog()); - for (UniqueConstraintAnnotation oldUniqueConstraint : CollectionTools.iterable(oldTable.uniqueConstraints())) { - NestableUniqueConstraintAnnotation newUniqueConstraint = this.addUniqueConstraint(oldTable.indexOfUniqueConstraint(oldUniqueConstraint)); - newUniqueConstraint.initializeFrom((NestableAnnotation) oldUniqueConstraint); - } - } - - // ********** unique constraint container ********** - - /** - * adapt the AnnotationContainer interface to the table's unique constraints - */ - class UniqueConstraintsAnnotationContainer - implements AnnotationContainer<NestableUniqueConstraintAnnotation> - { - public Annotation getAstAnnotation(CompilationUnit astRoot) { - return SourceBaseTableAnnotation.this.getAstAnnotation(astRoot); - } - - public String getElementName() { - return SourceBaseTableAnnotation.this.getUniqueConstraintsElementName(); - } - - public String getNestedAnnotationName() { - return UniqueConstraintAnnotation.ANNOTATION_NAME; - } - - public Iterable<NestableUniqueConstraintAnnotation> getNestedAnnotations() { - return SourceBaseTableAnnotation.this.getNestableUniqueConstraints(); - } - - public int getNestedAnnotationsSize() { - return SourceBaseTableAnnotation.this.uniqueConstraintsSize(); - } - - public NestableUniqueConstraintAnnotation addNestedAnnotation() { - return SourceBaseTableAnnotation.this.addUniqueConstraint_(); - } - - public void syncAddNestedAnnotation(Annotation astAnnotation) { - SourceBaseTableAnnotation.this.syncAddUniqueConstraint(astAnnotation); - } - - public NestableUniqueConstraintAnnotation moveNestedAnnotation(int targetIndex, int sourceIndex) { - return SourceBaseTableAnnotation.this.moveUniqueConstraint_(targetIndex, sourceIndex); - } - - public NestableUniqueConstraintAnnotation removeNestedAnnotation(int index) { - return SourceBaseTableAnnotation.this.removeUniqueConstraint_(index); - } - - public void syncRemoveNestedAnnotations(int index) { - SourceBaseTableAnnotation.this.syncRemoveUniqueConstraints(index); - } - - @Override - public String toString() { - return StringTools.buildToStringFor(this); - } - - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseTemporalAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseTemporalAnnotation.java deleted file mode 100644 index 2995571ae0..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseTemporalAnnotation.java +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.AnnotatedElementAnnotationElementAdapter; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.TemporalAnnotation; -import org.eclipse.jpt.core.resource.java.TemporalType; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; - -/** - * Abstract implementation for JPA annotations - * javax.persistence.Temporal - * javax.persistence.MapKeyTemporal - */ -public abstract class SourceBaseTemporalAnnotation - extends SourceAnnotation<Attribute> - implements TemporalAnnotation -{ - protected final DeclarationAnnotationElementAdapter<String> valueDeclarationAdapter; - private final AnnotationElementAdapter<String> valueAdapter; - private TemporalType value; - - - protected SourceBaseTemporalAnnotation(JavaResourceNode parent, Attribute attribute, DeclarationAnnotationAdapter daa) { - super(parent, attribute, daa); - this.valueDeclarationAdapter = new EnumDeclarationAnnotationElementAdapter(daa, getValueElementName()); - this.valueAdapter = new AnnotatedElementAnnotationElementAdapter<String>(attribute, this.valueDeclarationAdapter); - } - - public void initialize(CompilationUnit astRoot) { - this.value = this.buildValue(astRoot); - } - - public void synchronizeWith(CompilationUnit astRoot) { - this.syncValue(this.buildValue(astRoot)); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.value); - } - - - // ********** TemporalAnnotation implementation ********** - - // ***** value - public TemporalType getValue() { - return this.value; - } - - public void setValue(TemporalType value) { - if (this.attributeValueHasChanged(this.value, value)) { - this.value = value; - this.valueAdapter.setValue(TemporalType.toJavaAnnotationValue(value)); - } - } - - private void syncValue(TemporalType astValue) { - TemporalType old = this.value; - this.value = astValue; - this.firePropertyChanged(VALUE_PROPERTY, old, astValue); - } - - private TemporalType buildValue(CompilationUnit astRoot) { - return TemporalType.fromJavaAnnotationValue(this.valueAdapter.getValue(astRoot)); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.valueDeclarationAdapter, astRoot); - } - - protected abstract String getValueElementName(); - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBasicAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBasicAnnotation.java deleted file mode 100644 index f2bf083063..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBasicAnnotation.java +++ /dev/null @@ -1,137 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.BooleanExpressionConverter; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.AnnotatedElementAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.BasicAnnotation; -import org.eclipse.jpt.core.resource.java.FetchType; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; - -/** - * javax.persistence.Basic - */ -public final class SourceBasicAnnotation - extends SourceAnnotation<Attribute> - implements BasicAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter<Boolean> OPTIONAL_ADAPTER = buildOptionalAdapter(); - private final AnnotationElementAdapter<Boolean> optionalAdapter; - private Boolean optional; - - private static final DeclarationAnnotationElementAdapter<String> FETCH_ADAPTER = buildFetchAdapter(); - private final AnnotationElementAdapter<String> fetchAdapter; - private FetchType fetch; - - - public SourceBasicAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.optionalAdapter = new AnnotatedElementAnnotationElementAdapter<Boolean>(attribute, OPTIONAL_ADAPTER); - this.fetchAdapter = new AnnotatedElementAnnotationElementAdapter<String>(attribute, FETCH_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - this.optional = this.buildOptional(astRoot); - this.fetch = this.buildFetch(astRoot); - } - - public void synchronizeWith(CompilationUnit astRoot) { - this.syncOptional(this.buildOptional(astRoot)); - this.syncFetch(this.buildFetch(astRoot)); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.fetch); - } - - - //*************** Basic implementation **************** - - // ***** optional - public Boolean getOptional() { - return this.optional; - } - - public void setOptional(Boolean optional) { - if (this.attributeValueHasChanged(this.optional, optional)) { - this.optional = optional; - this.optionalAdapter.setValue(optional); - } - } - - private void syncOptional(Boolean astOptional) { - Boolean old = this.optional; - this.optional = astOptional; - this.firePropertyChanged(OPTIONAL_PROPERTY, old, astOptional); - } - - private Boolean buildOptional(CompilationUnit astRoot) { - return this.optionalAdapter.getValue(astRoot); - } - - public TextRange getOptionalTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(OPTIONAL_ADAPTER, astRoot); - } - - // ***** fetch - public FetchType getFetch() { - return this.fetch; - } - - public void setFetch(FetchType fetch) { - if (this.attributeValueHasChanged(this.fetch, fetch)) { - this.fetch = fetch; - this.fetchAdapter.setValue(FetchType.toJavaAnnotationValue(fetch)); - } - } - - private void syncFetch(FetchType astFetch) { - FetchType old = this.fetch; - this.fetch = astFetch; - this.firePropertyChanged(FETCH_PROPERTY, old, astFetch); - } - - private FetchType buildFetch(CompilationUnit astRoot) { - return FetchType.fromJavaAnnotationValue(this.fetchAdapter.getValue(astRoot)); - } - - public TextRange getFetchTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(FETCH_ADAPTER, astRoot); - } - - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter<Boolean> buildOptionalAdapter() { - return new ConversionDeclarationAnnotationElementAdapter<Boolean>(DECLARATION_ANNOTATION_ADAPTER, JPA.BASIC__OPTIONAL, false, BooleanExpressionConverter.instance()); - } - - private static DeclarationAnnotationElementAdapter<String> buildFetchAdapter() { - return new EnumDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.BASIC__FETCH, false); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceColumnAnnotation.java deleted file mode 100644 index 1d2f2864a4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceColumnAnnotation.java +++ /dev/null @@ -1,129 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.source; - -import org.eclipse.jpt.core.internal.utility.jdt.NestedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.ColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.resource.java.NestableColumnAnnotation; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.Column - */ -public final class SourceColumnAnnotation - extends SourceCompleteColumnAnnotation - implements NestableColumnAnnotation -{ - // this adapter is only used by a Column annotation associated with a mapping annotation (e.g. Basic) - public static final DeclarationAnnotationAdapter MAPPING_DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - - public SourceColumnAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa) { - super(parent, member, daa); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - // ********** SourceNamedColumnAnnotation implementation ********** - - @Override - protected String getNameElementName() { - return JPA.COLUMN__NAME; - } - - @Override - protected String getColumnDefinitionElementName() { - return JPA.COLUMN__COLUMN_DEFINITION; - } - - - // ********** SourceBaseColumnAnnotation implementation ********** - - @Override - protected String getTableElementName() { - return JPA.COLUMN__TABLE; - } - - @Override - protected String getUniqueElementName() { - return JPA.COLUMN__UNIQUE; - } - - @Override - protected String getNullableElementName() { - return JPA.COLUMN__NULLABLE; - } - - @Override - protected String getInsertableElementName() { - return JPA.COLUMN__INSERTABLE; - } - - @Override - protected String getUpdatableElementName() { - return JPA.COLUMN__UPDATABLE; - } - - // ********** SourceCompleteColumnAnnotation implementation ********** - - @Override - protected String getLengthElementName() { - return JPA.COLUMN__LENGTH; - } - - @Override - protected String getPrecisionElementName() { - return JPA.COLUMN__PRECISION; - } - - @Override - protected String getScaleElementName() { - return JPA.COLUMN__SCALE; - } - - // ********** NestableAnnotation implementation ********** - - @Override - public void initializeFrom(NestableAnnotation oldAnnotation) { - super.initializeFrom(oldAnnotation); - ColumnAnnotation oldColumn = (ColumnAnnotation) oldAnnotation; - this.setLength(oldColumn.getLength()); - this.setPrecision(oldColumn.getPrecision()); - this.setScale(oldColumn.getScale()); - } - - public void moveAnnotation(int newIndex) { - // the only place where a column annotation is nested is in an - // attribute override; and that only nests a single column, not an array - // of columns; so #moveAnnotation(int) is never called - // TODO maybe NestableAnnotation should be split up; - // moving this method to something like IndexableAnnotation - throw new UnsupportedOperationException(); - } - - - // ********** static methods ********** - - static NestableColumnAnnotation createAttributeOverrideColumn(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter attributeOverrideAnnotationAdapter) { - return new SourceColumnAnnotation(parent, member, buildAttributeOverrideAnnotationAdapter(attributeOverrideAnnotationAdapter)); - } - - static DeclarationAnnotationAdapter buildAttributeOverrideAnnotationAdapter(DeclarationAnnotationAdapter attributeOverrideAnnotationAdapter) { - return new NestedDeclarationAnnotationAdapter(attributeOverrideAnnotationAdapter, JPA.ATTRIBUTE_OVERRIDE__COLUMN, JPA.COLUMN); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceCompilationUnit.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceCompilationUnit.java deleted file mode 100644 index cfe7a4c1e7..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceCompilationUnit.java +++ /dev/null @@ -1,176 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import org.eclipse.core.resources.IFile; -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.JpaAnnotationProvider; -import org.eclipse.jpt.core.JpaResourceModelListener; -import org.eclipse.jpt.core.internal.utility.jdt.ASTTools; -import org.eclipse.jpt.core.resource.java.JavaResourceCompilationUnit; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationEditFormatter; -import org.eclipse.jpt.utility.CommandExecutor; -import org.eclipse.jpt.utility.internal.ListenerList; - -/** - * Java compilation unit (source file) - */ -public abstract class SourceCompilationUnit - extends SourceNode - implements JavaResourceCompilationUnit -{ - /** JDT compilation unit */ - final ICompilationUnit compilationUnit; - - /** pluggable annotation provider */ - private final JpaAnnotationProvider annotationProvider; - - /** improved annotation formatting */ - private final AnnotationEditFormatter annotationEditFormatter; - - /** pluggable executor that allows the document to be modified on another thread */ - private final CommandExecutor modifySharedDocumentCommandExecutor; - - /** listeners notified whenever the resource model changes */ - private final ListenerList<JpaResourceModelListener> resourceModelListenerList; - - - // ********** construction ********** - - protected SourceCompilationUnit( - ICompilationUnit compilationUnit, - JpaAnnotationProvider annotationProvider, - AnnotationEditFormatter annotationEditFormatter, - CommandExecutor modifySharedDocumentCommandExecutor) { - super(null); // the JPA compilation unit is the root of its sub-tree - this.compilationUnit = compilationUnit; - this.annotationProvider = annotationProvider; - this.annotationEditFormatter = annotationEditFormatter; - this.modifySharedDocumentCommandExecutor = modifySharedDocumentCommandExecutor; - this.resourceModelListenerList = new ListenerList<JpaResourceModelListener>(JpaResourceModelListener.class); - } - - public void initialize(CompilationUnit astRoot) { - // never called? - } - - void openCompilationUnit() { - try { - this.compilationUnit.open(null); - } catch (JavaModelException ex) { - // do nothing - we just won't have a primary type in this case - } - } - - void closeCompilationUnit() { - try { - this.compilationUnit.close(); - } catch (JavaModelException ex) { - // hmmm - } - } - - - // ********** AbstractJavaResourceNode overrides ********** - - @Override - protected boolean requiresParent() { - return false; - } - - @Override - public JavaResourceCompilationUnit getRoot() { - return this; - } - - @Override - public IFile getFile() { - return (IFile) this.compilationUnit.getResource(); - } - - @Override - public JpaAnnotationProvider getAnnotationProvider() { - return this.annotationProvider; - } - - - // ********** JavaResourceNode implementation ********** - - public TextRange getTextRange(CompilationUnit astRoot) { - return null; - } - - - // ********** JavaResourceNode.Root implementation ********** - - public void resourceModelChanged() { - for (JpaResourceModelListener listener : this.resourceModelListenerList.getListeners()) { - listener.resourceModelChanged(this); - } - } - - - // ********** JavaResourceCompilationUnit implementation ********** - - public ICompilationUnit getCompilationUnit() { - return this.compilationUnit; - } - - public CommandExecutor getModifySharedDocumentCommandExecutor() { - return this.modifySharedDocumentCommandExecutor; - } - - public AnnotationEditFormatter getAnnotationEditFormatter() { - return this.annotationEditFormatter; - } - - public CompilationUnit buildASTRoot() { - return ASTTools.buildASTRoot(this.compilationUnit); - } - - - // ********** JpaResourceModel implementation ********** - - public void addResourceModelListener(JpaResourceModelListener listener) { - this.resourceModelListenerList.add(listener); - } - - public void removeResourceModelListener(JpaResourceModelListener listener) { - this.resourceModelListenerList.remove(listener); - } - - - // ********** Java changes ********** - - public void synchronizeWithJavaSource() { - this.synchronizeWith(this.buildASTRoot()); - } - - - // ********** internal ********** - - String getCompilationUnitName() { - return this.removeJavaExtension(this.compilationUnit.getElementName()); - } - - private String removeJavaExtension(String fileName) { - int index = fileName.lastIndexOf(".java"); //$NON-NLS-1$ - return (index == -1) ? fileName : fileName.substring(0, index); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.getCompilationUnitName()); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceCompleteColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceCompleteColumnAnnotation.java deleted file mode 100644 index 766c351580..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceCompleteColumnAnnotation.java +++ /dev/null @@ -1,155 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.ColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * Abstract implementation of ColumnAnnotation to be used for JPA annotations: - * javax.persistence.Column - * javax.persistence.MapKeyColumn - */ -public abstract class SourceCompleteColumnAnnotation - extends SourceBaseColumnAnnotation - implements ColumnAnnotation -{ - protected final DeclarationAnnotationElementAdapter<Integer> lengthDeclarationAdapter; - protected final AnnotationElementAdapter<Integer> lengthAdapter; - protected Integer length; - - protected final DeclarationAnnotationElementAdapter<Integer> precisionDeclarationAdapter; - protected final AnnotationElementAdapter<Integer> precisionAdapter; - protected Integer precision; - - protected final DeclarationAnnotationElementAdapter<Integer> scaleDeclarationAdapter; - protected final AnnotationElementAdapter<Integer> scaleAdapter; - protected Integer scale; - - - protected SourceCompleteColumnAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa) { - super(parent, member, daa); - this.lengthDeclarationAdapter = this.buildIntegerElementAdapter(this.getLengthElementName()); - this.lengthAdapter = this.buildShortCircuitIntegerElementAdapter(this.lengthDeclarationAdapter); - this.precisionDeclarationAdapter = this.buildIntegerElementAdapter(this.getPrecisionElementName()); - this.precisionAdapter = this.buildShortCircuitIntegerElementAdapter(this.precisionDeclarationAdapter); - this.scaleDeclarationAdapter = this.buildIntegerElementAdapter(this.getScaleElementName()); - this.scaleAdapter = this.buildShortCircuitIntegerElementAdapter(this.scaleDeclarationAdapter); - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.length = this.buildLength(astRoot); - this.precision = this.buildPrecision(astRoot); - this.scale = this.buildScale(astRoot); - } - - @Override - public void synchronizeWith(CompilationUnit astRoot) { - super.synchronizeWith(astRoot); - this.syncLength(this.buildLength(astRoot)); - this.syncPrecision(this.buildPrecision(astRoot)); - this.syncScale(this.buildScale(astRoot)); - } - - - // ********** ColumnAnnotation implementation ********** - - // ***** length - public Integer getLength() { - return this.length; - } - - public void setLength(Integer length) { - if (this.attributeValueHasChanged(this.length, length)) { - this.length = length; - this.lengthAdapter.setValue(length); - } - } - - private void syncLength(Integer astLength) { - Integer old = this.length; - this.length = astLength; - this.firePropertyChanged(LENGTH_PROPERTY, old, astLength); - } - - private Integer buildLength(CompilationUnit astRoot) { - return this.lengthAdapter.getValue(astRoot); - } - - public TextRange getLengthTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.lengthDeclarationAdapter, astRoot); - } - - protected abstract String getLengthElementName(); - - // ***** precision - public Integer getPrecision() { - return this.precision; - } - - public void setPrecision(Integer precision) { - if (this.attributeValueHasChanged(this.precision, precision)) { - this.precision = precision; - this.precisionAdapter.setValue(precision); - } - } - - private void syncPrecision(Integer astPrecision) { - Integer old = this.precision; - this.precision = astPrecision; - this.firePropertyChanged(PRECISION_PROPERTY, old, astPrecision); - } - - private Integer buildPrecision(CompilationUnit astRoot) { - return this.precisionAdapter.getValue(astRoot); - } - - public TextRange getPrecisionTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.precisionDeclarationAdapter, astRoot); - } - - protected abstract String getPrecisionElementName(); - - // ***** scale - public Integer getScale() { - return this.scale; - } - - public void setScale(Integer scale) { - if (this.attributeValueHasChanged(this.scale, scale)) { - this.scale = scale; - this.scaleAdapter.setValue(scale); - } - } - - private void syncScale(Integer astScale) { - Integer old = this.scale; - this.scale = astScale; - this.firePropertyChanged(SCALE_PROPERTY, old, astScale); - } - - private Integer buildScale(CompilationUnit astRoot) { - return this.scaleAdapter.getValue(astRoot); - } - - public TextRange getScaleTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.scaleDeclarationAdapter, astRoot); - } - - protected abstract String getScaleElementName(); -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceDiscriminatorColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceDiscriminatorColumnAnnotation.java deleted file mode 100644 index 8bb0374ca0..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceDiscriminatorColumnAnnotation.java +++ /dev/null @@ -1,144 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.AnnotatedElementAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.DiscriminatorColumnAnnotation; -import org.eclipse.jpt.core.resource.java.DiscriminatorType; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.DiscriminatorColumn - */ -public final class SourceDiscriminatorColumnAnnotation - extends SourceNamedColumnAnnotation - implements DiscriminatorColumnAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter<String> DISCRIMINATOR_TYPE_ADAPTER = buildDiscriminatorTypeAdapter(); - private final AnnotationElementAdapter<String> discriminatorTypeAdapter; - private DiscriminatorType discriminatorType; - - private final DeclarationAnnotationElementAdapter<Integer> lengthDeclarationAdapter; - private final AnnotationElementAdapter<Integer> lengthAdapter; - private Integer length; - - - public SourceDiscriminatorColumnAnnotation(JavaResourcePersistentType parent, Type type) { - super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - this.discriminatorTypeAdapter = new AnnotatedElementAnnotationElementAdapter<String>(type, DISCRIMINATOR_TYPE_ADAPTER); - this.lengthDeclarationAdapter = this.buildIntegerElementAdapter(JPA.DISCRIMINATOR_COLUMN__LENGTH); - this.lengthAdapter = this.buildShortCircuitIntegerElementAdapter(this.lengthDeclarationAdapter); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.discriminatorType = this.buildDiscriminatorType(astRoot); - this.length = this.buildLength(astRoot); - } - - @Override - public void synchronizeWith(CompilationUnit astRoot) { - super.synchronizeWith(astRoot); - this.syncLength(this.buildLength(astRoot)); - this.syncDiscriminatorType(this.buildDiscriminatorType(astRoot)); - } - - - // ********** JavaSourceNamedColumnAnnotation implementation ********** - - @Override - protected String getNameElementName() { - return JPA.DISCRIMINATOR_COLUMN__NAME; - } - - @Override - protected String getColumnDefinitionElementName() { - return JPA.DISCRIMINATOR_COLUMN__COLUMN_DEFINITION; - } - - - // ********** DiscriminatorColumn implementation ********** - - // ***** discriminator type - public DiscriminatorType getDiscriminatorType() { - return this.discriminatorType; - } - - public void setDiscriminatorType(DiscriminatorType discriminatorType) { - if (this.attributeValueHasChanged(this.discriminatorType, discriminatorType)) { - this.discriminatorType = discriminatorType; - this.discriminatorTypeAdapter.setValue(DiscriminatorType.toJavaAnnotationValue(discriminatorType)); - } - } - - private void syncDiscriminatorType(DiscriminatorType astDiscriminatorType) { - DiscriminatorType old = this.discriminatorType; - this.discriminatorType = astDiscriminatorType; - this.firePropertyChanged(DISCRIMINATOR_TYPE_PROPERTY, old, astDiscriminatorType); - } - - private DiscriminatorType buildDiscriminatorType(CompilationUnit astRoot) { - return DiscriminatorType.fromJavaAnnotationValue(this.discriminatorTypeAdapter.getValue(astRoot)); - } - - // ***** length - public Integer getLength() { - return this.length; - } - - public void setLength(Integer length) { - if (this.attributeValueHasChanged(this.length, length)) { - this.length = length; - this.lengthAdapter.setValue(length); - } - } - - private void syncLength(Integer astLength) { - Integer old = this.length; - this.length = astLength; - this.firePropertyChanged(LENGTH_PROPERTY, old, astLength); - } - - private Integer buildLength(CompilationUnit astRoot) { - return this.lengthAdapter.getValue(astRoot); - } - - - // ********** NestableAnnotation implementation ********** - - @Override - public void initializeFrom(NestableAnnotation oldAnnotation) { - throw new UnsupportedOperationException("DiscriminatorColumn is not a nestable annotation"); //$NON-NLS-1$ - } - - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter<String> buildDiscriminatorTypeAdapter() { - return new EnumDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.DISCRIMINATOR_COLUMN__DISCRIMINATOR_TYPE); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceDiscriminatorValueAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceDiscriminatorValueAnnotation.java deleted file mode 100644 index df25fe7c7c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceDiscriminatorValueAnnotation.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.AnnotatedElementAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.DiscriminatorValueAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.DiscriminatorValue - */ -public final class SourceDiscriminatorValueAnnotation - extends SourceAnnotation<Type> - implements DiscriminatorValueAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter<String> VALUE_ADAPTER = buildValueAdapter(); - private final AnnotationElementAdapter<String> valueAdapter; - private String value; - - - public SourceDiscriminatorValueAnnotation(JavaResourcePersistentType parent, Type type) { - super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - this.valueAdapter = new AnnotatedElementAnnotationElementAdapter<String>(type, VALUE_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - this.value = this.buildValue(astRoot); - } - - public void synchronizeWith(CompilationUnit astRoot) { - this.syncValue(this.buildValue(astRoot)); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.value); - } - - - // ********** DiscriminatorValueAnnotation implementation ********** - - // ***** value - public String getValue() { - return this.value; - } - - public void setValue(String value) { - if (this.attributeValueHasChanged(this.value, value)) { - this.value = value; - this.valueAdapter.setValue(value); - } - } - - private void syncValue(String astValue) { - String old = this.value; - this.value = astValue; - this.firePropertyChanged(VALUE_PROPERTY, old, astValue); - } - - private String buildValue(CompilationUnit astRoot) { - return this.valueAdapter.getValue(astRoot); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(VALUE_ADAPTER, astRoot); - } - - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter<String> buildValueAdapter() { - return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.DISCRIMINATOR_VALUE__VALUE); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddableAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddableAnnotation.java deleted file mode 100644 index a336c4466f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddableAnnotation.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.EmbeddableAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.Embeddable - */ -public final class SourceEmbeddableAnnotation - extends SourceAnnotation<Type> - implements EmbeddableAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - - public SourceEmbeddableAnnotation(JavaResourcePersistentType parent, Type type) { - super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - // nothing to initialize - } - - public void synchronizeWith(CompilationUnit astRoot) { - // nothing to update - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddedAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddedAnnotation.java deleted file mode 100644 index 2e29565656..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddedAnnotation.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.EmbeddedAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; - -/** - * javax.persistence.Embedded - */ -public final class SourceEmbeddedAnnotation - extends SourceAnnotation<Attribute> - implements EmbeddedAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - - public SourceEmbeddedAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - // nothing to initialize - } - - public void synchronizeWith(CompilationUnit astRoot) { - // nothing to update - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddedIdAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddedIdAnnotation.java deleted file mode 100644 index 17901e5a7b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddedIdAnnotation.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.EmbeddedIdAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; - -/** - * javax.persistence.EmbeddedId - */ -public final class SourceEmbeddedIdAnnotation - extends SourceAnnotation<Attribute> - implements EmbeddedIdAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - - public SourceEmbeddedIdAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - // nothing to initialize - } - - public void synchronizeWith(CompilationUnit astRoot) { - // nothing to update - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEntityAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEntityAnnotation.java deleted file mode 100644 index 5d360990c7..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEntityAnnotation.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.AnnotatedElementAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.EntityAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.Entity - */ -public final class SourceEntityAnnotation - extends SourceAnnotation<Type> - implements EntityAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter<String> NAME_ADAPTER = buildNameAdapter(); - private final AnnotationElementAdapter<String> nameAdapter; - private String name; - - - public SourceEntityAnnotation(JavaResourcePersistentType parent, Type type) { - super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - this.nameAdapter = new AnnotatedElementAnnotationElementAdapter<String>(this.annotatedElement, NAME_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - this.name = this.buildName(astRoot); - } - - public void synchronizeWith(CompilationUnit astRoot) { - this.syncName(this.buildName(astRoot)); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - // ********** EntityAnnotation implementation ********** - - // ***** name - public String getName() { - return this.name; - } - - public void setName(String name) { - if (this.attributeValueHasChanged(this.name, name)) { - this.name = name; - this.nameAdapter.setValue(name); - } - } - - private void syncName(String astName) { - String old = this.name; - this.name = astName; - this.firePropertyChanged(NAME_PROPERTY, old, astName); - } - - private String buildName(CompilationUnit astRoot) { - return this.nameAdapter.getValue(astRoot); - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(NAME_ADAPTER, astRoot); - } - - - //*********** static methods **************** - - private static DeclarationAnnotationElementAdapter<String> buildNameAdapter() { - return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.ENTITY__NAME, false); // false = do not remove annotation when empty - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEnumeratedAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEnumeratedAnnotation.java deleted file mode 100644 index 031706d84c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEnumeratedAnnotation.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; - -/** - * javax.persistence.Enumerated - */ -public final class SourceEnumeratedAnnotation - extends SourceBaseEnumeratedAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - public SourceEnumeratedAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - protected String getValueElementName() { - return JPA.ENUMERATED__VALUE; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceGeneratedValueAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceGeneratedValueAnnotation.java deleted file mode 100644 index 94bf3142ca..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceGeneratedValueAnnotation.java +++ /dev/null @@ -1,141 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.AnnotatedElementAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.GeneratedValueAnnotation; -import org.eclipse.jpt.core.resource.java.GenerationType; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.GeneratedValue - */ -public final class SourceGeneratedValueAnnotation - extends SourceAnnotation<Member> - implements GeneratedValueAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter<String> STRATEGY_ADAPTER = buildStrategyAdapter(); - private final AnnotationElementAdapter<String> strategyAdapter; - private GenerationType strategy; - - private static final DeclarationAnnotationElementAdapter<String> GENERATOR_ADAPTER = buildGeneratorAdapter(); - private final AnnotationElementAdapter<String> generatorAdapter; - private String generator; - - - public SourceGeneratedValueAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.strategyAdapter = new AnnotatedElementAnnotationElementAdapter<String>(attribute, STRATEGY_ADAPTER); - this.generatorAdapter = new AnnotatedElementAnnotationElementAdapter<String>(attribute, GENERATOR_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - this.strategy = this.buildStrategy(astRoot); - this.generator = this.buildGenerator(astRoot); - } - - public void synchronizeWith(CompilationUnit astRoot) { - this.syncStrategy(this.buildStrategy(astRoot)); - this.syncGenerator(this.buildGenerator(astRoot)); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.strategy); - } - - - // ********** GeneratedValueAnnotation implementation ********** - - // ***** strategy - public GenerationType getStrategy() { - return this.strategy; - } - - public void setStrategy(GenerationType strategy) { - if (this.attributeValueHasChanged(this.strategy, strategy)) { - this.strategy = strategy; - this.strategyAdapter.setValue(GenerationType.toJavaAnnotationValue(strategy)); - } - } - - private void syncStrategy(GenerationType astStrategy) { - GenerationType old = this.strategy; - this.strategy = astStrategy; - this.firePropertyChanged(STRATEGY_PROPERTY, old, astStrategy); - } - - private GenerationType buildStrategy(CompilationUnit astRoot) { - return GenerationType.fromJavaAnnotationValue(this.strategyAdapter.getValue(astRoot)); - } - - public TextRange getStrategyTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(STRATEGY_ADAPTER, astRoot); - } - - // ***** generator - public String getGenerator() { - return this.generator; - } - - public void setGenerator(String generator) { - if (this.attributeValueHasChanged(this.generator, generator)) { - this.generator = generator; - this.generatorAdapter.setValue(generator); - } - } - - private void syncGenerator(String astGenerator) { - String old = this.generator; - this.generator = astGenerator; - this.firePropertyChanged(GENERATOR_PROPERTY, old, astGenerator); - } - - private String buildGenerator(CompilationUnit astRoot) { - return this.generatorAdapter.getValue(astRoot); - } - - public TextRange getGeneratorTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(GENERATOR_ADAPTER, astRoot); - } - - public boolean generatorTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(GENERATOR_ADAPTER, pos, astRoot); - } - - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter<String> buildStrategyAdapter() { - return new EnumDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.GENERATED_VALUE__STRATEGY, false); - } - - private static DeclarationAnnotationElementAdapter<String> buildGeneratorAdapter() { - return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.GENERATED_VALUE__GENERATOR, false); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceGeneratorAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceGeneratorAnnotation.java deleted file mode 100644 index ef415a7e50..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceGeneratorAnnotation.java +++ /dev/null @@ -1,178 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.AnnotatedElementAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.NumberIntegerExpressionConverter; -import org.eclipse.jpt.core.resource.java.GeneratorAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.SequenceGenerator - * javax.persistence.TableGenerator - */ -abstract class SourceGeneratorAnnotation - extends SourceAnnotation<Member> - implements GeneratorAnnotation -{ - final DeclarationAnnotationElementAdapter<String> nameDeclarationAdapter; - final AnnotationElementAdapter<String> nameAdapter; - String name; - - final DeclarationAnnotationElementAdapter<Integer> initialValueDeclarationAdapter; - final AnnotationElementAdapter<Integer> initialValueAdapter; - Integer initialValue; - - final DeclarationAnnotationElementAdapter<Integer> allocationSizeDeclarationAdapter; - final AnnotationElementAdapter<Integer> allocationSizeAdapter; - Integer allocationSize; - - - SourceGeneratorAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa) { - super(parent, member, daa); - this.nameDeclarationAdapter = this.getNameAdapter(); - this.nameAdapter = this.buildAdapter(this.nameDeclarationAdapter); - this.initialValueDeclarationAdapter = this.getInitialValueAdapter(); - this.initialValueAdapter = this.buildIntegerAdapter(this.initialValueDeclarationAdapter); - this.allocationSizeDeclarationAdapter = this.getAllocationSizeAdapter(); - this.allocationSizeAdapter = this.buildIntegerAdapter(this.allocationSizeDeclarationAdapter); - } - - protected AnnotationElementAdapter<String> buildAdapter(DeclarationAnnotationElementAdapter<String> daea) { - return new AnnotatedElementAnnotationElementAdapter<String>(this.annotatedElement, daea); - } - - protected AnnotationElementAdapter<Integer> buildIntegerAdapter(DeclarationAnnotationElementAdapter<Integer> daea) { - return new AnnotatedElementAnnotationElementAdapter<Integer>(this.annotatedElement, daea); - } - - public void initialize(CompilationUnit astRoot) { - this.name = this.buildName(astRoot); - this.initialValue = this.buildInitialValue(astRoot); - this.allocationSize = this.buildAllocationSize(astRoot); - } - - public void synchronizeWith(CompilationUnit astRoot) { - this.syncName(this.buildName(astRoot)); - this.syncInitialValue(this.buildInitialValue(astRoot)); - this.syncAllocationSize(this.buildAllocationSize(astRoot)); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - // ********** GeneratorAnnotation implementation ********** - - // ***** name - public String getName() { - return this.name; - } - - public void setName(String name) { - if (this.attributeValueHasChanged(this.name, name)) { - this.name = name; - this.nameAdapter.setValue(name); - } - } - - private void syncName(String astName) { - String old = this.name; - this.name = astName; - this.firePropertyChanged(NAME_PROPERTY, old, astName); - } - - private String buildName(CompilationUnit astRoot) { - return this.nameAdapter.getValue(astRoot); - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.nameDeclarationAdapter, astRoot); - } - - abstract DeclarationAnnotationElementAdapter<String> getNameAdapter(); - - // ***** initial value - public Integer getInitialValue() { - return this.initialValue; - } - - public void setInitialValue(Integer initialValue) { - if (this.attributeValueHasChanged(this.initialValue, initialValue)) { - this.initialValue = initialValue; - this.initialValueAdapter.setValue(initialValue); - } - } - - private void syncInitialValue(Integer astIinitialValue) { - Integer old = this.initialValue; - this.initialValue = astIinitialValue; - this.firePropertyChanged(INITIAL_VALUE_PROPERTY, old, astIinitialValue); - } - - private Integer buildInitialValue(CompilationUnit astRoot) { - return this.initialValueAdapter.getValue(astRoot); - } - - public TextRange getInitialValueTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.initialValueDeclarationAdapter, astRoot); - } - - abstract DeclarationAnnotationElementAdapter<Integer> getInitialValueAdapter(); - - // ***** allocation size - public Integer getAllocationSize() { - return this.allocationSize; - } - - public void setAllocationSize(Integer allocationSize) { - if (this.attributeValueHasChanged(this.allocationSize, allocationSize)) { - this.allocationSize = allocationSize; - this.allocationSizeAdapter.setValue(allocationSize); - } - } - - private void syncAllocationSize(Integer astAllocationSize) { - Integer old = this.allocationSize; - this.allocationSize = astAllocationSize; - this.firePropertyChanged(ALLOCATION_SIZE_PROPERTY, old, astAllocationSize); - } - - private Integer buildAllocationSize(CompilationUnit astRoot) { - return this.allocationSizeAdapter.getValue(astRoot); - } - - public TextRange getAllocationSizeTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.allocationSizeDeclarationAdapter, astRoot); - } - - abstract DeclarationAnnotationElementAdapter<Integer> getAllocationSizeAdapter(); - - - // ********** static methods ********** - - static DeclarationAnnotationElementAdapter<String> buildAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { - return ConversionDeclarationAnnotationElementAdapter.forStrings(annotationAdapter, elementName); - } - - static DeclarationAnnotationElementAdapter<Integer> buildIntegerAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { - return new ConversionDeclarationAnnotationElementAdapter<Integer>(annotationAdapter, elementName, NumberIntegerExpressionConverter.instance()); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceIdAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceIdAnnotation.java deleted file mode 100644 index 63cbbd11d9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceIdAnnotation.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.IdAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; - -/** - * javax.persistence.Id - */ -public final class SourceIdAnnotation - extends SourceAnnotation<Attribute> - implements IdAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - - public SourceIdAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - // nothing to initialize - } - - public void synchronizeWith(CompilationUnit astRoot) { - // nothing to update - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceIdClassAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceIdClassAnnotation.java deleted file mode 100644 index 485eff8b71..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceIdClassAnnotation.java +++ /dev/null @@ -1,118 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ASTTools; -import org.eclipse.jpt.core.internal.utility.jdt.AnnotatedElementAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleTypeStringExpressionConverter; -import org.eclipse.jpt.core.resource.java.IdClassAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.IdClass - */ -public final class SourceIdClassAnnotation - extends SourceAnnotation<Type> - implements IdClassAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter<String> VALUE_ADAPTER = buildValueAdapter(); - private final AnnotationElementAdapter<String> valueAdapter; - private String value; - - private String fullyQualifiedClassName; - - - public SourceIdClassAnnotation(JavaResourcePersistentType parent, Type type) { - super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - this.valueAdapter = new AnnotatedElementAnnotationElementAdapter<String>(type, VALUE_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - this.value = this.buildValue(astRoot); - this.fullyQualifiedClassName = this.buildFullyQualifiedClassName(astRoot); - } - - public void synchronizeWith(CompilationUnit astRoot) { - this.syncValue(this.buildValue(astRoot)); - this.syncFullyQualifiedClassName(this.buildFullyQualifiedClassName(astRoot)); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.value); - } - - - // ********** IdClassAnnotation implementation ********** - - // ***** value - public String getValue() { - return this.value; - } - - public void setValue(String value) { - if (this.attributeValueHasChanged(this.value, value)) { - this.value = value; - this.valueAdapter.setValue(value); - } - } - - private void syncValue(String astValue) { - String old = this.value; - this.value = astValue; - this.firePropertyChanged(VALUE_PROPERTY, old, astValue); - } - - private String buildValue(CompilationUnit astRoot) { - return this.valueAdapter.getValue(astRoot); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(VALUE_ADAPTER, astRoot); - } - - // ***** fully-qualified class name - public String getFullyQualifiedClassName() { - return this.fullyQualifiedClassName; - } - - private void syncFullyQualifiedClassName(String astFullyQualifiedClassName) { - String old = this.fullyQualifiedClassName; - this.fullyQualifiedClassName = astFullyQualifiedClassName; - this.firePropertyChanged(FULLY_QUALIFIED_CLASS_NAME_PROPERTY, old, astFullyQualifiedClassName); - } - - private String buildFullyQualifiedClassName(CompilationUnit astRoot) { - return (this.value == null) ? null : ASTTools.resolveFullyQualifiedName(this.valueAdapter.getExpression(astRoot)); - } - - - // ********** static methods ********** - - protected static DeclarationAnnotationElementAdapter<String> buildValueAdapter() { - return new ConversionDeclarationAnnotationElementAdapter<String>(DECLARATION_ANNOTATION_ADAPTER, JPA.ID_CLASS__VALUE, SimpleTypeStringExpressionConverter.instance()); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceInheritanceAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceInheritanceAnnotation.java deleted file mode 100644 index da5d8429e3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceInheritanceAnnotation.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.AnnotatedElementAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.InheritanceAnnotation; -import org.eclipse.jpt.core.resource.java.InheritanceType; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.Inheritance - */ -public final class SourceInheritanceAnnotation - extends SourceAnnotation<Type> - implements InheritanceAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter<String> STRATEGY_ADAPTER = buildStrategyAdapter(); - private final AnnotationElementAdapter<String> strategyAdapter; - private InheritanceType strategy; - - - public SourceInheritanceAnnotation(JavaResourcePersistentType parent, Type type) { - super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - this.strategyAdapter = new AnnotatedElementAnnotationElementAdapter<String>(type, STRATEGY_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - this.strategy = this.buildStrategy(astRoot); - } - - public void synchronizeWith(CompilationUnit astRoot) { - this.syncStrategy(this.buildStrategy(astRoot)); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.strategy); - } - - - // ********** InheritanceAnnotation implementation ********** - - // ***** strategy - public InheritanceType getStrategy() { - return this.strategy; - } - - public void setStrategy(InheritanceType strategy) { - if (this.attributeValueHasChanged(this.strategy, strategy)) { - this.strategy = strategy; - this.strategyAdapter.setValue(InheritanceType.toJavaAnnotationValue(strategy)); - } - } - - private void syncStrategy(InheritanceType astStrategy) { - InheritanceType old = this.strategy; - this.strategy = astStrategy; - this.firePropertyChanged(STRATEGY_PROPERTY, old, astStrategy); - } - - private InheritanceType buildStrategy(CompilationUnit astRoot) { - return InheritanceType.fromJavaAnnotationValue(this.strategyAdapter.getValue(astRoot)); - } - - public TextRange getStrategyTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(STRATEGY_ADAPTER, astRoot); - } - - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter<String> buildStrategyAdapter() { - return new EnumDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.INHERITANCE__STRATEGY); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinColumnAnnotation.java deleted file mode 100644 index f040d96de5..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinColumnAnnotation.java +++ /dev/null @@ -1,124 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import org.eclipse.jpt.core.internal.utility.jdt.ElementAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ElementIndexedAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableJoinColumnAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.JoinColumn - */ -public final class SourceJoinColumnAnnotation - extends SourceBaseJoinColumnAnnotation - implements NestableJoinColumnAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - - public SourceJoinColumnAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { - super(parent, member, daa, annotationAdapter); - } - - public SourceJoinColumnAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa) { - this(parent, member, daa, new ElementAnnotationAdapter(member, daa)); - } - - public SourceJoinColumnAnnotation(JavaResourceNode parent, Member member, IndexedDeclarationAnnotationAdapter idaa) { - this(parent, member, idaa, new ElementIndexedAnnotationAdapter(member, idaa)); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - // ********** SourceNamedColumnAnnotation implementation ********** - - @Override - protected String getNameElementName() { - return JPA.JOIN_COLUMN__NAME; - } - - @Override - protected String getColumnDefinitionElementName() { - return JPA.JOIN_COLUMN__COLUMN_DEFINITION; - } - - - // ********** SourceBaseColumnAnnotation implementation ********** - - @Override - protected String getTableElementName() { - return JPA.JOIN_COLUMN__TABLE; - } - - @Override - protected String getUniqueElementName() { - return JPA.JOIN_COLUMN__UNIQUE; - } - - @Override - protected String getNullableElementName() { - return JPA.JOIN_COLUMN__NULLABLE; - } - - @Override - protected String getInsertableElementName() { - return JPA.JOIN_COLUMN__INSERTABLE; - } - - @Override - protected String getUpdatableElementName() { - return JPA.JOIN_COLUMN__UPDATABLE; - } - - - // ********** SourceBaseJoinColumnAnnotation implementation ********** - - @Override - protected String getReferencedColumnNameElementName() { - return JPA.JOIN_COLUMN__REFERENCED_COLUMN_NAME; - } - - - // ********** static methods ********** - - public static SourceJoinColumnAnnotation createJoinColumn(JavaResourceNode parent, Member member) { - return new SourceJoinColumnAnnotation(parent, member, DECLARATION_ANNOTATION_ADAPTER); - } - - static SourceJoinColumnAnnotation createNestedJoinColumn(JavaResourceNode parent, Member member, int index, DeclarationAnnotationAdapter joinColumnsAdapter) { - IndexedDeclarationAnnotationAdapter idaa = buildNestedDeclarationAnnotationAdapter(index, joinColumnsAdapter); - IndexedAnnotationAdapter annotationAdapter = new ElementIndexedAnnotationAdapter(member, idaa); - return new SourceJoinColumnAnnotation(parent, member, idaa, annotationAdapter); - } - - private static IndexedDeclarationAnnotationAdapter buildNestedDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter joinColumnsAdapter) { - return new NestedIndexedDeclarationAnnotationAdapter(joinColumnsAdapter, index, JPA.JOIN_COLUMN); - } - - static NestableJoinColumnAnnotation createAssociationOverrideJoinColumn(DeclarationAnnotationAdapter associationOverrideAdapter, JavaResourceNode parent, Member member, int index) { - return new SourceJoinColumnAnnotation(parent, member, buildAssociationOverrideAnnotationAdapter(associationOverrideAdapter, index)); - } - - private static IndexedDeclarationAnnotationAdapter buildAssociationOverrideAnnotationAdapter(DeclarationAnnotationAdapter associationOverrideAdapter, int index) { - return new NestedIndexedDeclarationAnnotationAdapter(associationOverrideAdapter, JPA.ASSOCIATION_OVERRIDE__JOIN_COLUMNS, index, JPA.JOIN_COLUMN); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinColumnsAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinColumnsAnnotation.java deleted file mode 100644 index ab52ca0f56..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinColumnsAnnotation.java +++ /dev/null @@ -1,111 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import java.util.Vector; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JoinColumnsAnnotation; -import org.eclipse.jpt.core.resource.java.NestableJoinColumnAnnotation; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable; - -/** - * javax.persistence.JoinColumns - */ -public final class SourceJoinColumnsAnnotation - extends SourceAnnotation<Member> - implements JoinColumnsAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final Vector<NestableJoinColumnAnnotation> joinColumns = new Vector<NestableJoinColumnAnnotation>(); - - - public SourceJoinColumnsAnnotation(JavaResourceNode parent, Member member) { - super(parent, member, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - AnnotationContainerTools.initialize(this, astRoot); - } - - public void synchronizeWith(CompilationUnit astRoot) { - AnnotationContainerTools.synchronize(this, astRoot); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.joinColumns); - } - - - // ********** AnnotationContainer implementation ********** - - public String getElementName() { - return JPA.JOIN_COLUMNS__VALUE; - } - - public String getNestedAnnotationName() { - return JoinColumnAnnotation.ANNOTATION_NAME; - } - - public Iterable<NestableJoinColumnAnnotation> getNestedAnnotations() { - return new LiveCloneIterable<NestableJoinColumnAnnotation>(this.joinColumns); - } - - public int getNestedAnnotationsSize() { - return this.joinColumns.size(); - } - - public NestableJoinColumnAnnotation addNestedAnnotation() { - return this.addNestedAnnotation(this.joinColumns.size()); - } - - private NestableJoinColumnAnnotation addNestedAnnotation(int index) { - NestableJoinColumnAnnotation joinColumn = this.buildJoinColumn(index); - this.joinColumns.add(joinColumn); - return joinColumn; - } - - public void syncAddNestedAnnotation(org.eclipse.jdt.core.dom.Annotation astAnnotation) { - int index = this.joinColumns.size(); - NestableJoinColumnAnnotation joinColumn = this.addNestedAnnotation(index); - joinColumn.initialize((CompilationUnit) astAnnotation.getRoot()); - this.fireItemAdded(JOIN_COLUMNS_LIST, index, joinColumn); - } - - private NestableJoinColumnAnnotation buildJoinColumn(int index) { - return SourceJoinColumnAnnotation.createNestedJoinColumn(this, this.annotatedElement, index, this.daa); - } - - public NestableJoinColumnAnnotation moveNestedAnnotation(int targetIndex, int sourceIndex) { - return CollectionTools.move(this.joinColumns, targetIndex, sourceIndex).get(targetIndex); - } - - public NestableJoinColumnAnnotation removeNestedAnnotation(int index) { - return this.joinColumns.remove(index); - } - - public void syncRemoveNestedAnnotations(int index) { - this.removeItemsFromList(index, this.joinColumns, JOIN_COLUMNS_LIST); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinTableAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinTableAnnotation.java deleted file mode 100644 index 219b32fa1f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinTableAnnotation.java +++ /dev/null @@ -1,376 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.AnnotationContainer; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JoinTableAnnotation; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.resource.java.NestableJoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.NestableJoinTableAnnotation; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.StringTools; -import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.JoinTable - */ -public final class SourceJoinTableAnnotation - extends SourceBaseTableAnnotation - implements NestableJoinTableAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(JoinTableAnnotation.ANNOTATION_NAME); - - - private final Vector<NestableJoinColumnAnnotation> joinColumns = new Vector<NestableJoinColumnAnnotation>(); - private final JoinColumnsAnnotationContainer joinColumnsContainer = new JoinColumnsAnnotationContainer(); - - private final Vector<NestableJoinColumnAnnotation> inverseJoinColumns = new Vector<NestableJoinColumnAnnotation>(); - private final InverseJoinColumnsContainerAnnotation inverseJoinColumnsContainer = new InverseJoinColumnsContainerAnnotation(); - - - public SourceJoinTableAnnotation(JavaResourceNode parent, Member member) { - this(parent, member, DECLARATION_ANNOTATION_ADAPTER); - } - - public SourceJoinTableAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa) { - super(parent, member, daa); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - AnnotationContainerTools.initialize(this.joinColumnsContainer, astRoot); - AnnotationContainerTools.initialize(this.inverseJoinColumnsContainer, astRoot); - } - - @Override - public void synchronizeWith(CompilationUnit astRoot) { - super.synchronizeWith(astRoot); - AnnotationContainerTools.synchronize(this.joinColumnsContainer, astRoot); - AnnotationContainerTools.synchronize(this.inverseJoinColumnsContainer, astRoot); - } - - - // ********** SourceBaseTableAnnotation implementation ********** - - @Override - protected DeclarationAnnotationElementAdapter<String> getNameAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { - return ConversionDeclarationAnnotationElementAdapter.forStrings(declarationAnnotationAdapter, JPA.JOIN_TABLE__NAME); - } - - @Override - protected DeclarationAnnotationElementAdapter<String> getSchemaAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { - return ConversionDeclarationAnnotationElementAdapter.forStrings(declarationAnnotationAdapter, JPA.JOIN_TABLE__SCHEMA); - } - - @Override - protected DeclarationAnnotationElementAdapter<String> getCatalogAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { - return ConversionDeclarationAnnotationElementAdapter.forStrings(declarationAnnotationAdapter, JPA.JOIN_TABLE__CATALOG); - } - - @Override - protected String getUniqueConstraintsElementName() { - return JPA.JOIN_TABLE__UNIQUE_CONSTRAINTS; - } - - // ********** JoinTableAnnotation implementation ********** - - // ***** join columns - public ListIterator<JoinColumnAnnotation> joinColumns() { - return new CloneListIterator<JoinColumnAnnotation>(this.joinColumns); - } - - Iterable<NestableJoinColumnAnnotation> getNestableJoinColumns() { - return new LiveCloneIterable<NestableJoinColumnAnnotation>(this.joinColumns); - } - - public int joinColumnsSize() { - return this.joinColumns.size(); - } - - public NestableJoinColumnAnnotation joinColumnAt(int index) { - return this.joinColumns.get(index); - } - - public int indexOfJoinColumn(JoinColumnAnnotation joinColumn) { - return this.joinColumns.indexOf(joinColumn); - } - - public NestableJoinColumnAnnotation addJoinColumn(int index) { - return (NestableJoinColumnAnnotation) AnnotationContainerTools.addNestedAnnotation(index, this.joinColumnsContainer); - } - - NestableJoinColumnAnnotation addJoinColumn_() { - return this.addJoinColumn_(this.joinColumns.size()); - } - - private NestableJoinColumnAnnotation addJoinColumn_(int index) { - NestableJoinColumnAnnotation joinColumn = this.buildJoinColumn(index); - this.joinColumns.add(index, joinColumn); - return joinColumn; - } - - void syncAddJoinColumn(org.eclipse.jdt.core.dom.Annotation astAnnotation) { - int index = this.joinColumns.size(); - NestableJoinColumnAnnotation joinColumn = this.addJoinColumn_(index); - joinColumn.initialize((CompilationUnit) astAnnotation.getRoot()); - this.fireItemAdded(JOIN_COLUMNS_LIST, index, joinColumn); - } - - private NestableJoinColumnAnnotation buildJoinColumn(int index) { - return new SourceJoinColumnAnnotation(this, this.annotatedElement, buildJoinColumnAnnotationAdapter(index)); - } - - private IndexedDeclarationAnnotationAdapter buildJoinColumnAnnotationAdapter(int index) { - return new NestedIndexedDeclarationAnnotationAdapter(this.daa, JPA.JOIN_TABLE__JOIN_COLUMNS, index, JPA.JOIN_COLUMN); - } - - public void moveJoinColumn(int targetIndex, int sourceIndex) { - AnnotationContainerTools.moveNestedAnnotation(targetIndex, sourceIndex, this.joinColumnsContainer); - } - - NestableJoinColumnAnnotation moveJoinColumn_(int targetIndex, int sourceIndex) { - return CollectionTools.move(this.joinColumns, targetIndex, sourceIndex).get(targetIndex); - } - - public void removeJoinColumn(int index) { - AnnotationContainerTools.removeNestedAnnotation(index, this.joinColumnsContainer); - } - - NestableJoinColumnAnnotation removeJoinColumn_(int index) { - return this.joinColumns.remove(index); - } - - void syncRemoveJoinColumns(int index) { - this.removeItemsFromList(index, this.joinColumns, JOIN_COLUMNS_LIST); - } - - // ***** inverse join columns - public ListIterator<JoinColumnAnnotation> inverseJoinColumns() { - return new CloneListIterator<JoinColumnAnnotation>(this.inverseJoinColumns); - } - - Iterable<NestableJoinColumnAnnotation> getNestableInverseJoinColumns() { - return new LiveCloneIterable<NestableJoinColumnAnnotation>(this.inverseJoinColumns); - } - - public int inverseJoinColumnsSize() { - return this.inverseJoinColumns.size(); - } - - public NestableJoinColumnAnnotation inverseJoinColumnAt(int index) { - return this.inverseJoinColumns.get(index); - } - - public int indexOfInverseJoinColumn(JoinColumnAnnotation joinColumn) { - return this.inverseJoinColumns.indexOf(joinColumn); - } - - public NestableJoinColumnAnnotation addInverseJoinColumn(int index) { - return (NestableJoinColumnAnnotation) AnnotationContainerTools.addNestedAnnotation(index, this.inverseJoinColumnsContainer); - } - - NestableJoinColumnAnnotation addInverseJoinColumn_() { - return this.addInverseJoinColumn_(this.inverseJoinColumns.size()); - } - - private NestableJoinColumnAnnotation addInverseJoinColumn_(int index) { - NestableJoinColumnAnnotation joinColumn = this.buildInverseJoinColumn(index); - this.inverseJoinColumns.add(joinColumn); - return joinColumn; - } - - void syncAddInverseJoinColumn(org.eclipse.jdt.core.dom.Annotation astAnnotation) { - int index = this.inverseJoinColumns.size(); - NestableJoinColumnAnnotation joinColumn = this.addInverseJoinColumn_(index); - joinColumn.initialize((CompilationUnit) astAnnotation.getRoot()); - this.fireItemAdded(INVERSE_JOIN_COLUMNS_LIST, index, joinColumn); - } - - private NestableJoinColumnAnnotation buildInverseJoinColumn(int index) { - return new SourceJoinColumnAnnotation(this, this.annotatedElement, buildInverseJoinColumnAnnotationAdapter(index)); - } - - private IndexedDeclarationAnnotationAdapter buildInverseJoinColumnAnnotationAdapter(int index) { - return new NestedIndexedDeclarationAnnotationAdapter(this.daa, JPA.JOIN_TABLE__INVERSE_JOIN_COLUMNS, index, JPA.JOIN_COLUMN); - } - - void inverseJoinColumnAdded(int index, NestableJoinColumnAnnotation joinColumn) { - this.fireItemAdded(INVERSE_JOIN_COLUMNS_LIST, index, joinColumn); - } - - public void moveInverseJoinColumn(int targetIndex, int sourceIndex) { - AnnotationContainerTools.moveNestedAnnotation(targetIndex, sourceIndex, this.inverseJoinColumnsContainer); - } - - NestableJoinColumnAnnotation moveInverseJoinColumn_(int targetIndex, int sourceIndex) { - return CollectionTools.move(this.inverseJoinColumns, targetIndex, sourceIndex).get(targetIndex); - } - - void inverseJoinColumnMoved(int targetIndex, int sourceIndex) { - this.fireItemMoved(INVERSE_JOIN_COLUMNS_LIST, targetIndex, sourceIndex); - } - - public void removeInverseJoinColumn(int index) { - AnnotationContainerTools.removeNestedAnnotation(index, this.inverseJoinColumnsContainer); - } - - NestableJoinColumnAnnotation removeInverseJoinColumn_(int index) { - return this.inverseJoinColumns.remove(index); - } - - void syncRemoveInverseJoinColumns(int index) { - this.removeItemsFromList(index, this.inverseJoinColumns, INVERSE_JOIN_COLUMNS_LIST); - } - - // ********** NestableAnnotation implementation ********** - - @Override - public void initializeFrom(NestableAnnotation oldAnnotation) { - super.initializeFrom(oldAnnotation); - JoinTableAnnotation oldJoinTable = (JoinTableAnnotation) oldAnnotation; - for (JoinColumnAnnotation oldJoinColumn : CollectionTools.iterable(oldJoinTable.joinColumns())) { - NestableJoinColumnAnnotation newJoinColumn = this.addJoinColumn(oldJoinTable.indexOfJoinColumn(oldJoinColumn)); - newJoinColumn.initializeFrom((NestableAnnotation) oldJoinColumn); - } - for (JoinColumnAnnotation oldInverseJoinColumn : CollectionTools.iterable(oldJoinTable.inverseJoinColumns())) { - NestableJoinColumnAnnotation newInverseJoinColumn = this.addInverseJoinColumn(oldJoinTable.indexOfInverseJoinColumn(oldInverseJoinColumn)); - newInverseJoinColumn.initializeFrom((NestableAnnotation) oldInverseJoinColumn); - } - } - - public void moveAnnotation(int newIndex) { - // the only place where a join table annotation is nested is in an - // association override; and that only nests a single join table, not an array - // of join tables; so #moveAnnotation(int) is never called - // TODO maybe NestableAnnotation should be split up; - // moving this method to something like IndexableAnnotation - throw new UnsupportedOperationException(); - } - - // ********** annotation containers ********** - - abstract class AbstractJoinColumnAnnotationContainer - implements AnnotationContainer<NestableJoinColumnAnnotation> - { - public org.eclipse.jdt.core.dom.Annotation getAstAnnotation(CompilationUnit astRoot) { - return SourceJoinTableAnnotation.this.getAstAnnotation(astRoot); - } - - public String getNestedAnnotationName() { - return JoinColumnAnnotation.ANNOTATION_NAME; - } - - @Override - public String toString() { - return StringTools.buildToStringFor(this); - } - } - - - /** - * adapt the AnnotationContainer interface to the join table's join columns - */ - class JoinColumnsAnnotationContainer - extends AbstractJoinColumnAnnotationContainer - { - public String getElementName() { - return JPA.JOIN_TABLE__JOIN_COLUMNS; - } - - public Iterable<NestableJoinColumnAnnotation> getNestedAnnotations() { - return SourceJoinTableAnnotation.this.getNestableJoinColumns(); - } - - public int getNestedAnnotationsSize() { - return SourceJoinTableAnnotation.this.joinColumnsSize(); - } - - public NestableJoinColumnAnnotation addNestedAnnotation() { - return SourceJoinTableAnnotation.this.addJoinColumn_(); - } - - public void syncAddNestedAnnotation(org.eclipse.jdt.core.dom.Annotation astAnnotation) { - SourceJoinTableAnnotation.this.syncAddJoinColumn(astAnnotation); - } - - public NestableJoinColumnAnnotation moveNestedAnnotation(int targetIndex, int sourceIndex) { - return SourceJoinTableAnnotation.this.moveJoinColumn_(targetIndex, sourceIndex); - } - - public NestableJoinColumnAnnotation removeNestedAnnotation(int index) { - return SourceJoinTableAnnotation.this.removeJoinColumn_(index); - } - - public void syncRemoveNestedAnnotations(int index) { - SourceJoinTableAnnotation.this.syncRemoveJoinColumns(index); - } - } - - - /** - * adapt the AnnotationContainer interface to the join table's inverse join columns - */ - class InverseJoinColumnsContainerAnnotation - extends AbstractJoinColumnAnnotationContainer - { - public String getElementName() { - return JPA.JOIN_TABLE__INVERSE_JOIN_COLUMNS; - } - - public Iterable<NestableJoinColumnAnnotation> getNestedAnnotations() { - return SourceJoinTableAnnotation.this.getNestableInverseJoinColumns(); - } - - public int getNestedAnnotationsSize() { - return SourceJoinTableAnnotation.this.inverseJoinColumnsSize(); - } - - public NestableJoinColumnAnnotation addNestedAnnotation() { - return SourceJoinTableAnnotation.this.addInverseJoinColumn_(); - } - - public void syncAddNestedAnnotation(org.eclipse.jdt.core.dom.Annotation astAnnotation) { - SourceJoinTableAnnotation.this.syncAddInverseJoinColumn(astAnnotation); - } - - public NestableJoinColumnAnnotation moveNestedAnnotation(int targetIndex, int sourceIndex) { - return SourceJoinTableAnnotation.this.moveInverseJoinColumn_(targetIndex, sourceIndex); - } - - public NestableJoinColumnAnnotation removeNestedAnnotation(int index) { - return SourceJoinTableAnnotation.this.removeInverseJoinColumn_(index); - } - - public void syncRemoveNestedAnnotations(int index) { - SourceJoinTableAnnotation.this.syncRemoveInverseJoinColumns(index); - } - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceLobAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceLobAnnotation.java deleted file mode 100644 index 103b3bc40a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceLobAnnotation.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.LobAnnotation; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; - -/** - * javax.persistence.Lob - */ -public final class SourceLobAnnotation - extends SourceAnnotation<Attribute> - implements LobAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - - public SourceLobAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - // nothing to initialize - } - - public void synchronizeWith(CompilationUnit astRoot) { - // nothing to update - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceManyToManyAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceManyToManyAnnotation.java deleted file mode 100644 index 59216f217e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceManyToManyAnnotation.java +++ /dev/null @@ -1,135 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.jpa2.resource.java.ManyToMany2_0Annotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; - -/** - * javax.persistence.ManyToMany - */ -public final class SourceManyToManyAnnotation - extends SourceRelationshipMappingAnnotation - implements ManyToMany2_0Annotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter<String> TARGET_ENTITY_ADAPTER = buildTargetEntityAdapter(); - - private static final DeclarationAnnotationElementAdapter<String> FETCH_ADAPTER = buildFetchAdapter(); - - private static final DeclarationAnnotationElementAdapter<String[]> CASCADE_ADAPTER = buildCascadeAdapter(); - - private static final DeclarationAnnotationElementAdapter<String> MAPPED_BY_ADAPTER = buildMappedByAdapter(); - private final AnnotationElementAdapter<String> mappedByAdapter; - private String mappedBy; - - - public SourceManyToManyAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.mappedByAdapter = this.buildAnnotationElementAdapter(MAPPED_BY_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.mappedBy = this.buildMappedBy(astRoot); - } - - @Override - public void synchronizeWith(CompilationUnit astRoot) { - super.synchronizeWith(astRoot); - this.syncMappedBy(this.buildMappedBy(astRoot)); - } - - - // ********** SourceRelationshipMappingAnnotation implementation ********** - - @Override - DeclarationAnnotationElementAdapter<String> getTargetEntityAdapter() { - return TARGET_ENTITY_ADAPTER; - } - - @Override - DeclarationAnnotationElementAdapter<String> getFetchAdapter() { - return FETCH_ADAPTER; - } - - @Override - DeclarationAnnotationElementAdapter<String[]> getCascadeAdapter() { - return CASCADE_ADAPTER; - } - - - //**************** OwnableRelationshipMappingAnnotation implementation ************** - - // ***** mapped by - public String getMappedBy() { - return this.mappedBy; - } - - public void setMappedBy(String mappedBy) { - if (this.attributeValueHasChanged(this.mappedBy, mappedBy)) { - this.mappedBy = mappedBy; - this.mappedByAdapter.setValue(mappedBy); - } - } - - private void syncMappedBy(String astMappedBy) { - String old = this.mappedBy; - this.mappedBy = astMappedBy; - this.firePropertyChanged(MAPPED_BY_PROPERTY, old, astMappedBy); - } - - private String buildMappedBy(CompilationUnit astRoot) { - return this.mappedByAdapter.getValue(astRoot); - } - - public TextRange getMappedByTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(MAPPED_BY_ADAPTER, astRoot); - } - - public boolean mappedByTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(MAPPED_BY_ADAPTER, pos, astRoot); - } - - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter<String> buildTargetEntityAdapter() { - return buildTargetEntityAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.MANY_TO_MANY__TARGET_ENTITY); - } - - private static DeclarationAnnotationElementAdapter<String> buildMappedByAdapter() { - return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.MANY_TO_MANY__MAPPED_BY, false); // false = do not remove annotation when empty - } - - private static DeclarationAnnotationElementAdapter<String> buildFetchAdapter() { - return buildFetchAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.MANY_TO_MANY__FETCH); - } - - private static DeclarationAnnotationElementAdapter<String[]> buildCascadeAdapter() { - return buildEnumArrayAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.MANY_TO_MANY__CASCADE); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceManyToOneAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceManyToOneAnnotation.java deleted file mode 100644 index 12ec5ec84b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceManyToOneAnnotation.java +++ /dev/null @@ -1,136 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.BooleanExpressionConverter; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.jpa2.resource.java.ManyToOne2_0Annotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; - -/** - * javax.persistence.ManyToOne - */ -public final class SourceManyToOneAnnotation - extends SourceRelationshipMappingAnnotation - implements ManyToOne2_0Annotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter<String> TARGET_ENTITY_ADAPTER = buildTargetEntityAdapter(); - - private static final DeclarationAnnotationElementAdapter<String> FETCH_ADAPTER = buildFetchAdapter(); - - private static final DeclarationAnnotationElementAdapter<String[]> CASCADE_ADAPTER = buildCascadeAdapter(); - - private static final DeclarationAnnotationElementAdapter<Boolean> OPTIONAL_ADAPTER = buildOptionalAdapter(); - private final AnnotationElementAdapter<Boolean> optionalAdapter; - private Boolean optional; - - - public SourceManyToOneAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.optionalAdapter = this.buildBooleanAnnotationElementAdapter(OPTIONAL_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.optional = this.buildOptional(astRoot); - } - - @Override - public void synchronizeWith(CompilationUnit astRoot) { - super.synchronizeWith(astRoot); - this.syncOptional(this.buildOptional(astRoot)); - } - - - // ********** SourceRelationshipMappingAnnotation implementation ********** - - @Override - DeclarationAnnotationElementAdapter<String> getTargetEntityAdapter() { - return TARGET_ENTITY_ADAPTER; - } - - @Override - DeclarationAnnotationElementAdapter<String> getFetchAdapter() { - return FETCH_ADAPTER; - } - - @Override - DeclarationAnnotationElementAdapter<String[]> getCascadeAdapter() { - return CASCADE_ADAPTER; - } - - - // ********** ManyToOneMappingAnnotation implementation ********** - - // ***** optional - public Boolean getOptional() { - return this.optional; - } - - public void setOptional(Boolean optional) { - if (this.attributeValueHasChanged(this.optional, optional)) { - this.optional = optional; - this.optionalAdapter.setValue(optional); - } - } - - private void syncOptional(Boolean astOptional) { - Boolean old = this.optional; - this.optional = astOptional; - this.firePropertyChanged(OPTIONAL_PROPERTY, old, astOptional); - } - - private Boolean buildOptional(CompilationUnit astRoot) { - return this.optionalAdapter.getValue(astRoot); - } - - public TextRange getOptionalTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(OPTIONAL_ADAPTER, astRoot); - } - - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter<String> buildTargetEntityAdapter() { - return buildTargetEntityAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.MANY_TO_ONE__TARGET_ENTITY); - } - - private static DeclarationAnnotationElementAdapter<String> buildFetchAdapter() { - return buildFetchAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.MANY_TO_ONE__FETCH); - } - - private static DeclarationAnnotationElementAdapter<Boolean> buildOptionalAdapter() { - return buildOptionalAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.MANY_TO_ONE__OPTIONAL); - } - - private static DeclarationAnnotationElementAdapter<String[]> buildCascadeAdapter() { - return buildEnumArrayAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.MANY_TO_ONE__CASCADE); - } - - private static DeclarationAnnotationElementAdapter<Boolean> buildOptionalAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { - return new ConversionDeclarationAnnotationElementAdapter<Boolean>(annotationAdapter, elementName, false, BooleanExpressionConverter.instance()); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceMapKeyAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceMapKeyAnnotation.java deleted file mode 100644 index daa721257c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceMapKeyAnnotation.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.AnnotatedElementAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.MapKeyAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; - -/** - * javax.persistence.MapKey - */ -public final class SourceMapKeyAnnotation - extends SourceAnnotation<Attribute> - implements MapKeyAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter<String> NAME_ADAPTER = buildNameAdapter(); - private final AnnotationElementAdapter<String> nameAdapter; - private String name; - - - public SourceMapKeyAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.nameAdapter = new AnnotatedElementAnnotationElementAdapter<String>(attribute, NAME_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - this.name = this.buildName(astRoot); - } - - public void synchronizeWith(CompilationUnit astRoot) { - this.syncName(this.buildName(astRoot)); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - // ********** MapKeyAnnotation implementation ********** - - // ***** name - public String getName() { - return this.name; - } - - public void setName(String name) { - if (this.attributeValueHasChanged(this.name, name)) { - this.name = name; - this.nameAdapter.setValue(name); - } - } - - private void syncName(String astName) { - String old = this.name; - this.name = astName; - this.firePropertyChanged(NAME_PROPERTY, old, astName); - } - - private String buildName(CompilationUnit astRoot) { - return this.nameAdapter.getValue(astRoot); - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(NAME_ADAPTER, astRoot); - } - - public boolean nameTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(NAME_ADAPTER, pos, astRoot); - } - - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter<String> buildNameAdapter() { - return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.MAP_KEY__NAME, false); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceMappedSuperclassAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceMappedSuperclassAnnotation.java deleted file mode 100644 index 75f8cc48e1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceMappedSuperclassAnnotation.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.resource.java.MappedSuperclassAnnotation; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.MappedSuperclass - */ -public final class SourceMappedSuperclassAnnotation - extends SourceAnnotation<Type> - implements MappedSuperclassAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - - public SourceMappedSuperclassAnnotation(JavaResourcePersistentType parent, Type type) { - super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - // nothing to initialize - } - - public void synchronizeWith(CompilationUnit astRoot) { - // nothing to update - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedColumnAnnotation.java deleted file mode 100644 index 8806402301..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedColumnAnnotation.java +++ /dev/null @@ -1,178 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.BooleanExpressionConverter; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ElementAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.AnnotatedElementAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.NumberIntegerExpressionConverter; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NamedColumnAnnotation; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.Column - * javax.persistence.JoinColumn - * javax.persistence.DiscriminatorColumn - * javax.persistence.PrimaryKeyJoinColumn. - */ -public abstract class SourceNamedColumnAnnotation - extends SourceAnnotation<Member> - implements NamedColumnAnnotation -{ - private final DeclarationAnnotationElementAdapter<String> nameDeclarationAdapter; - private final AnnotationElementAdapter<String> nameAdapter; - private String name; - - private final DeclarationAnnotationElementAdapter<String> columnDefinitionDeclarationAdapter; - private final AnnotationElementAdapter<String> columnDefinitionAdapter; - private String columnDefinition; - - - protected SourceNamedColumnAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa) { - this(parent, member, daa, new ElementAnnotationAdapter(member, daa)); - } - - protected SourceNamedColumnAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { - super(parent, member, daa, annotationAdapter); - this.nameDeclarationAdapter = this.buildStringElementAdapter(this.getNameElementName()); - this.nameAdapter = this.buildShortCircuitElementAdapter(this.nameDeclarationAdapter); - this.columnDefinitionDeclarationAdapter = this.buildStringElementAdapter(this.getColumnDefinitionElementName()); - this.columnDefinitionAdapter = this.buildShortCircuitElementAdapter(this.columnDefinitionDeclarationAdapter); - } - - protected DeclarationAnnotationElementAdapter<String> buildStringElementAdapter(String elementName) { - return ConversionDeclarationAnnotationElementAdapter.forStrings(this.daa, elementName); - } - - protected DeclarationAnnotationElementAdapter<Boolean> buildBooleanElementAdapter(String elementName) { - return new ConversionDeclarationAnnotationElementAdapter<Boolean>(this.daa, elementName, BooleanExpressionConverter.instance()); - } - - protected DeclarationAnnotationElementAdapter<Integer> buildIntegerElementAdapter(String elementName) { - return new ConversionDeclarationAnnotationElementAdapter<Integer>(this.daa, elementName, NumberIntegerExpressionConverter.instance()); - } - - AnnotationElementAdapter<String> buildShortCircuitElementAdapter(DeclarationAnnotationElementAdapter<String> daea) { - return new AnnotatedElementAnnotationElementAdapter<String>(this.annotatedElement, daea); - } - - protected AnnotationElementAdapter<Boolean> buildShortCircuitBooleanElementAdapter(DeclarationAnnotationElementAdapter<Boolean> daea) { - return new AnnotatedElementAnnotationElementAdapter<Boolean>(this.annotatedElement, daea); - } - - protected AnnotationElementAdapter<Integer> buildShortCircuitIntegerElementAdapter(DeclarationAnnotationElementAdapter<Integer> daea) { - return new AnnotatedElementAnnotationElementAdapter<Integer>(this.annotatedElement, daea); - } - - AnnotationElementAdapter<String> buildShortCircuitStringElementAdapter(String elementName) { - return this.buildShortCircuitElementAdapter(this.buildStringElementAdapter(elementName)); - } - - public void initialize(CompilationUnit astRoot) { - this.name = this.buildName(astRoot); - this.columnDefinition = this.buildColumnDefinition(astRoot); - } - - public void synchronizeWith(CompilationUnit astRoot) { - this.syncName(this.buildName(astRoot)); - this.syncColumnDefinition(this.buildColumnDefinition(astRoot)); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - // ********** NamedColumn implementation ********** - - public boolean isSpecified() { - return true; - } - - // ***** name - public String getName() { - return this.name; - } - - public void setName(String name) { - if (this.attributeValueHasChanged(this.name, name)) { - this.name = name; - this.nameAdapter.setValue(name); - } - } - - private void syncName(String astName) { - String old = this.name; - this.name = astName; - this.firePropertyChanged(NAME_PROPERTY, old, astName); - } - - private String buildName(CompilationUnit astRoot) { - return this.nameAdapter.getValue(astRoot); - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.nameDeclarationAdapter, astRoot); - } - - public boolean nameTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(this.nameDeclarationAdapter, pos, astRoot); - } - - protected abstract String getNameElementName(); - - // ***** column definition - public String getColumnDefinition() { - return this.columnDefinition; - } - - public void setColumnDefinition(String columnDefinition) { - if (this.attributeValueHasChanged(this.columnDefinition, columnDefinition)) { - this.columnDefinition = columnDefinition; - this.columnDefinitionAdapter.setValue(columnDefinition); - } - } - - private void syncColumnDefinition(String astColumnDefinition) { - String old = this.columnDefinition; - this.columnDefinition = astColumnDefinition; - this.firePropertyChanged(COLUMN_DEFINITION_PROPERTY, old, astColumnDefinition); - } - - private String buildColumnDefinition(CompilationUnit astRoot) { - return this.columnDefinitionAdapter.getValue(astRoot); - } - - public TextRange getColumnDefinitionTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.columnDefinitionDeclarationAdapter, astRoot); - } - - protected abstract String getColumnDefinitionElementName(); - - - // ********** NestableAnnotation implementation ********** - - public void initializeFrom(NestableAnnotation oldAnnotation) { - NamedColumnAnnotation oldColumn = (NamedColumnAnnotation) oldAnnotation; - this.setName(oldColumn.getName()); - this.setColumnDefinition(oldColumn.getColumnDefinition()); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedNativeQueriesAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedNativeQueriesAnnotation.java deleted file mode 100644 index c12fdef5b5..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedNativeQueriesAnnotation.java +++ /dev/null @@ -1,112 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import java.util.Vector; - -import org.eclipse.jdt.core.dom.Annotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NamedNativeQueriesAnnotation; -import org.eclipse.jpt.core.resource.java.NamedNativeQueryAnnotation; -import org.eclipse.jpt.core.resource.java.NestableNamedNativeQueryAnnotation; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Type; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable; - -/** - * javax.persistence.NamedNativeQueries - */ -public final class SourceNamedNativeQueriesAnnotation - extends SourceAnnotation<Type> - implements NamedNativeQueriesAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final Vector<NestableNamedNativeQueryAnnotation> namedNativeQueries = new Vector<NestableNamedNativeQueryAnnotation>(); - - - public SourceNamedNativeQueriesAnnotation(JavaResourceNode parent, Type type) { - super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - AnnotationContainerTools.initialize(this, astRoot); - } - - public void synchronizeWith(CompilationUnit astRoot) { - AnnotationContainerTools.synchronize(this, astRoot); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.namedNativeQueries); - } - - - // ********** AnnotationContainer implementation ********** - - public String getElementName() { - return JPA.NAMED_NATIVE_QUERIES__VALUE; - } - - public String getNestedAnnotationName() { - return NamedNativeQueryAnnotation.ANNOTATION_NAME; - } - - public Iterable<NestableNamedNativeQueryAnnotation> getNestedAnnotations() { - return new LiveCloneIterable<NestableNamedNativeQueryAnnotation>(this.namedNativeQueries); - } - - public int getNestedAnnotationsSize() { - return this.namedNativeQueries.size(); - } - - public NestableNamedNativeQueryAnnotation addNestedAnnotation() { - return this.addNestedAnnotation(this.namedNativeQueries.size()); - } - - private NestableNamedNativeQueryAnnotation addNestedAnnotation(int index) { - NestableNamedNativeQueryAnnotation namedNativeQuery = this.buildNamedNativeQuery(index); - this.namedNativeQueries.add(namedNativeQuery); - return namedNativeQuery; - } - - public void syncAddNestedAnnotation(Annotation astAnnotation) { - int index = this.namedNativeQueries.size(); - NestableNamedNativeQueryAnnotation namedNativeQuery = this.addNestedAnnotation(index); - namedNativeQuery.initialize((CompilationUnit) astAnnotation.getRoot()); - this.fireItemAdded(NAMED_NATIVE_QUERIES_LIST, index, namedNativeQuery); - } - - private NestableNamedNativeQueryAnnotation buildNamedNativeQuery(int index) { - return SourceNamedNativeQueryAnnotation.createNestedNamedNativeQuery(this, this.annotatedElement, index, this.daa); - } - - public NestableNamedNativeQueryAnnotation moveNestedAnnotation(int targetIndex, int sourceIndex) { - return CollectionTools.move(this.namedNativeQueries, targetIndex, sourceIndex).get(targetIndex); - } - - public NestableNamedNativeQueryAnnotation removeNestedAnnotation(int index) { - return this.namedNativeQueries.remove(index); - } - - public void syncRemoveNestedAnnotations(int index) { - this.removeItemsFromList(index, this.namedNativeQueries, NAMED_NATIVE_QUERIES_LIST); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedNativeQueryAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedNativeQueryAnnotation.java deleted file mode 100644 index 2418e05a4c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedNativeQueryAnnotation.java +++ /dev/null @@ -1,212 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ASTTools; -import org.eclipse.jpt.core.internal.utility.jdt.ElementAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ElementIndexedAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleTypeStringExpressionConverter; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NamedNativeQueryAnnotation; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.resource.java.NestableNamedNativeQueryAnnotation; -import org.eclipse.jpt.core.resource.java.NestableQueryHintAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.NamedNativeQuery - */ -public final class SourceNamedNativeQueryAnnotation - extends SourceBaseNamedQueryAnnotation - implements NestableNamedNativeQueryAnnotation -{ - public static final SimpleDeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final DeclarationAnnotationElementAdapter<String> resultClassDeclarationAdapter; - private final AnnotationElementAdapter<String> resultClassAdapter; - private String resultClass; - - private String fullyQualifiedResultClassName; - - private final DeclarationAnnotationElementAdapter<String> resultSetMappingDeclarationAdapter; - private final AnnotationElementAdapter<String> resultSetMappingAdapter; - private String resultSetMapping; - - - public SourceNamedNativeQueryAnnotation(JavaResourceNode parent, Type type, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { - super(parent, type, daa, annotationAdapter); - this.resultClassDeclarationAdapter = this.buildResultClassAdapter(daa); - this.resultClassAdapter = this.buildAdapter(this.resultClassDeclarationAdapter); - this.resultSetMappingDeclarationAdapter = this.buildResultSetMappingAdapter(daa); - this.resultSetMappingAdapter = this.buildAdapter(this.resultSetMappingDeclarationAdapter); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.resultClass = this.buildResultClass(astRoot); - this.fullyQualifiedResultClassName = this.buildFullyQualifiedResultClassName(astRoot); - this.resultSetMapping = this.buildResultSetMapping(astRoot); - } - - @Override - public void synchronizeWith(CompilationUnit astRoot) { - super.synchronizeWith(astRoot); - this.syncResultClass(this.buildResultClass(astRoot)); - this.syncFullyQualifiedResultClassName(this.buildFullyQualifiedResultClassName(astRoot)); - this.syncResultSetMapping(this.buildResultSetMapping(astRoot)); - } - - - // ********** AbstractBaseNamedQueryAnnotation implementation ********** - - @Override - String getNameElementName() { - return JPA.NAMED_NATIVE_QUERY__NAME; - } - - @Override - String getQueryElementName() { - return JPA.NAMED_NATIVE_QUERY__QUERY; - } - - @Override - String getHintsElementName() { - return JPA.NAMED_NATIVE_QUERY__HINTS; - } - - @Override - NestableQueryHintAnnotation buildHint(int index) { - return SourceQueryHintAnnotation.createNamedNativeQueryQueryHint(this, this.annotatedElement, this.daa, index); - } - - - // ********** NamedNativeQueryAnnotation implementation ********** - - // ***** result class - public String getResultClass() { - return this.resultClass; - } - - public void setResultClass(String resultClass) { - if (this.attributeValueHasChanged(this.resultClass, resultClass)) { - this.resultClass = resultClass; - this.resultClassAdapter.setValue(resultClass); - } - } - - private void syncResultClass(String astResultClass) { - String old = this.resultClass; - this.resultClass = astResultClass; - this.firePropertyChanged(RESULT_CLASS_PROPERTY, old, astResultClass); - } - - private String buildResultClass(CompilationUnit astRoot) { - return this.resultClassAdapter.getValue(astRoot); - } - - public TextRange getResultClassTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.resultClassDeclarationAdapter, astRoot); - } - - private DeclarationAnnotationElementAdapter<String> buildResultClassAdapter(DeclarationAnnotationAdapter daAdapter) { - return new ConversionDeclarationAnnotationElementAdapter<String>(daAdapter, JPA.NAMED_NATIVE_QUERY__RESULT_CLASS, SimpleTypeStringExpressionConverter.instance()); - } - - // ***** fully-qualified result class name - public String getFullyQualifiedResultClassName() { - return this.fullyQualifiedResultClassName; - } - - private void syncFullyQualifiedResultClassName(String astName) { - String old = this.fullyQualifiedResultClassName; - this.fullyQualifiedResultClassName = astName; - this.firePropertyChanged(FULLY_QUALIFIED_RESULT_CLASS_NAME_PROPERTY, old, astName); - } - - private String buildFullyQualifiedResultClassName(CompilationUnit astRoot) { - return (this.resultClass == null) ? null : ASTTools.resolveFullyQualifiedName(this.resultClassAdapter.getExpression(astRoot)); - } - - // ***** result set mapping - public String getResultSetMapping() { - return this.resultSetMapping; - } - - public void setResultSetMapping(String resultSetMapping) { - if (this.attributeValueHasChanged(this.resultSetMapping, resultSetMapping)) { - this.resultSetMapping = resultSetMapping; - this.resultSetMappingAdapter.setValue(resultSetMapping); - } - } - - private void syncResultSetMapping(String astResultSetMapping) { - String old = this.resultSetMapping; - this.resultSetMapping = astResultSetMapping; - this.firePropertyChanged(RESULT_SET_MAPPING_PROPERTY, old, astResultSetMapping); - } - - private String buildResultSetMapping(CompilationUnit astRoot) { - return this.resultSetMappingAdapter.getValue(astRoot); - } - - public TextRange getResultSetMappingTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.resultSetMappingDeclarationAdapter, astRoot); - } - - private DeclarationAnnotationElementAdapter<String> buildResultSetMappingAdapter(DeclarationAnnotationAdapter daAdapter) { - return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter, JPA.NAMED_NATIVE_QUERY__RESULT_SET_MAPPING); - } - - - // ********** NestableAnnotation implementation ********** - - @Override - public void initializeFrom(NestableAnnotation oldAnnotation) { - super.initializeFrom(oldAnnotation); - NamedNativeQueryAnnotation oldQuery = (NamedNativeQueryAnnotation) oldAnnotation; - this.setResultClass(oldQuery.getResultClass()); - this.setResultSetMapping(oldQuery.getResultSetMapping()); - } - - - // ********** static methods ********** - - public static SourceNamedNativeQueryAnnotation createNamedNativeQuery(JavaResourceNode parent, Type type) { - return new SourceNamedNativeQueryAnnotation(parent, type, DECLARATION_ANNOTATION_ADAPTER, new ElementAnnotationAdapter(type, DECLARATION_ANNOTATION_ADAPTER)); - } - - static SourceNamedNativeQueryAnnotation createNestedNamedNativeQuery(JavaResourceNode parent, Type type, int index, DeclarationAnnotationAdapter attributeOverridesAdapter) { - IndexedDeclarationAnnotationAdapter idaa = buildNestedDeclarationAnnotationAdapter(index, attributeOverridesAdapter); - IndexedAnnotationAdapter annotationAdapter = new ElementIndexedAnnotationAdapter(type, idaa); - return new SourceNamedNativeQueryAnnotation(parent, type, idaa, annotationAdapter); - } - - private static IndexedDeclarationAnnotationAdapter buildNestedDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter namedQueriesAdapter) { - return new NestedIndexedDeclarationAnnotationAdapter(namedQueriesAdapter, index, JPA.NAMED_NATIVE_QUERY); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedQueries1_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedQueries1_0Annotation.java deleted file mode 100644 index 4d73fa4732..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedQueries1_0Annotation.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableNamedQueryAnnotation; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.NamedQueries - */ -public final class SourceNamedQueries1_0Annotation - extends SourceNamedQueriesAnnotation -{ - public SourceNamedQueries1_0Annotation(JavaResourceNode parent, Type type) { - super(parent, type); - } - - @Override - protected NestableNamedQueryAnnotation buildNamedQuery(int index) { - return SourceNamedQueryAnnotation.createNestedNamedQuery(this, this.annotatedElement, index, this.daa); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedQueriesAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedQueriesAnnotation.java deleted file mode 100644 index 2c097d285f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedQueriesAnnotation.java +++ /dev/null @@ -1,110 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import java.util.Vector; - -import org.eclipse.jdt.core.dom.Annotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NamedQueriesAnnotation; -import org.eclipse.jpt.core.resource.java.NamedQueryAnnotation; -import org.eclipse.jpt.core.resource.java.NestableNamedQueryAnnotation; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Type; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable; - -/** - * javax.persistence.NamedQueries - */ -public abstract class SourceNamedQueriesAnnotation - extends SourceAnnotation<Type> - implements NamedQueriesAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final Vector<NestableNamedQueryAnnotation> namedQueries = new Vector<NestableNamedQueryAnnotation>(); - - - public SourceNamedQueriesAnnotation(JavaResourceNode parent, Type type) { - super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - AnnotationContainerTools.initialize(this, astRoot); - } - - public void synchronizeWith(CompilationUnit astRoot) { - AnnotationContainerTools.synchronize(this, astRoot); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.namedQueries); - } - - - // ********** AnnotationContainer implementation ********** - - public String getElementName() { - return JPA.NAMED_QUERIES__VALUE; - } - - public String getNestedAnnotationName() { - return NamedQueryAnnotation.ANNOTATION_NAME; - } - - public Iterable<NestableNamedQueryAnnotation> getNestedAnnotations() { - return new LiveCloneIterable<NestableNamedQueryAnnotation>(this.namedQueries); - } - - public int getNestedAnnotationsSize() { - return this.namedQueries.size(); - } - - public NestableNamedQueryAnnotation addNestedAnnotation() { - return this.addNestedAnnotation(this.namedQueries.size()); - } - - private NestableNamedQueryAnnotation addNestedAnnotation(int index) { - NestableNamedQueryAnnotation namedQuery = this.buildNamedQuery(index); - this.namedQueries.add(namedQuery); - return namedQuery; - } - - public void syncAddNestedAnnotation(Annotation astAnnotation) { - int index = this.namedQueries.size(); - NestableNamedQueryAnnotation namedQuery = this.addNestedAnnotation(index); - namedQuery.initialize((CompilationUnit) astAnnotation.getRoot()); - this.fireItemAdded(NAMED_QUERIES_LIST, index, namedQuery); - } - - protected abstract NestableNamedQueryAnnotation buildNamedQuery(int index); - - public NestableNamedQueryAnnotation moveNestedAnnotation(int targetIndex, int sourceIndex) { - return CollectionTools.move(this.namedQueries, targetIndex, sourceIndex).get(targetIndex); - } - - public NestableNamedQueryAnnotation removeNestedAnnotation(int index) { - return this.namedQueries.remove(index); - } - - public void syncRemoveNestedAnnotations(int index) { - this.removeItemsFromList(index, this.namedQueries, NAMED_QUERIES_LIST); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedQueryAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedQueryAnnotation.java deleted file mode 100644 index 9c178a1cc4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedQueryAnnotation.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import org.eclipse.jpt.core.internal.jpa1.resource.java.source.SourceNamedQuery1_0Annotation; -import org.eclipse.jpt.core.internal.utility.jdt.ElementAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ElementIndexedAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NamedQueryAnnotation; -import org.eclipse.jpt.core.resource.java.NestableQueryHintAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.NamedQuery - */ -public abstract class SourceNamedQueryAnnotation - extends SourceBaseNamedQueryAnnotation - implements NamedQueryAnnotation -{ - public static final SimpleDeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - // ********** constructors ********** - public SourceNamedQueryAnnotation(JavaResourceNode parent, Type type) { - super(parent, type, DECLARATION_ANNOTATION_ADAPTER, new ElementAnnotationAdapter(type, DECLARATION_ANNOTATION_ADAPTER)); - } - - public SourceNamedQueryAnnotation(JavaResourceNode parent, Type type, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { - super(parent, type, daa, annotationAdapter); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - - // ********** AbstractBaseNamedQueryAnnotation implementation ********** - - @Override - String getNameElementName() { - return JPA.NAMED_QUERY__NAME; - } - - @Override - String getQueryElementName() { - return JPA.NAMED_QUERY__QUERY; - } - - @Override - String getHintsElementName() { - return JPA.NAMED_QUERY__HINTS; - } - - @Override - NestableQueryHintAnnotation buildHint(int index) { - return SourceQueryHintAnnotation.createNamedQueryQueryHint(this, this.annotatedElement, this.daa, index); - } - - - // ********** static methods ********** - - static SourceNamedQueryAnnotation createNestedNamedQuery(JavaResourceNode parent, Type type, int index, DeclarationAnnotationAdapter attributeOverridesAdapter) { - IndexedDeclarationAnnotationAdapter idaa = buildNestedDeclarationAnnotationAdapter(index, attributeOverridesAdapter); - IndexedAnnotationAdapter annotationAdapter = new ElementIndexedAnnotationAdapter(type, idaa); - - return new SourceNamedQuery1_0Annotation(parent, type, idaa, annotationAdapter); - } - - private static IndexedDeclarationAnnotationAdapter buildNestedDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter namedQueriesAdapter) { - return new NestedIndexedDeclarationAnnotationAdapter(namedQueriesAdapter, index, JPA.NAMED_QUERY); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNode.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNode.java deleted file mode 100644 index 354ba9d633..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNode.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * 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.source; - -import org.eclipse.jpt.core.internal.resource.java.AbstractJavaResourceNode; -import org.eclipse.jpt.core.resource.java.JavaResourceCompilationUnit; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; - -/** - * Source convenience methods - */ -public abstract class SourceNode - extends AbstractJavaResourceNode -{ - - public SourceNode(JavaResourceNode parent) { - super(parent); - } - - public JavaResourceCompilationUnit getJavaResourceCompilationUnit() { - return (JavaResourceCompilationUnit) this.getRoot(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceOneToManyAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceOneToManyAnnotation.java deleted file mode 100644 index 925ed56585..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceOneToManyAnnotation.java +++ /dev/null @@ -1,178 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.BooleanExpressionConverter; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; -import org.eclipse.jpt.core.jpa2.resource.java.OneToMany2_0Annotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; - -/** - * javax.persistence.OneToMany - */ -public final class SourceOneToManyAnnotation - extends SourceRelationshipMappingAnnotation - implements OneToMany2_0Annotation -{ - protected static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter<String> TARGET_ENTITY_ADAPTER = buildTargetEntityAdapter(); - - private static final DeclarationAnnotationElementAdapter<String> FETCH_ADAPTER = buildFetchAdapter(); - - private static final DeclarationAnnotationElementAdapter<String[]> CASCADE_ADAPTER = buildCascadeAdapter(); - - private static final DeclarationAnnotationElementAdapter<String> MAPPED_BY_ADAPTER = buildMappedByAdapter(); - private final AnnotationElementAdapter<String> mappedByAdapter; - private String mappedBy; - - //added in JPA2.0 - private static final DeclarationAnnotationElementAdapter<Boolean> ORPHAN_REMOVAL_ADAPTER = buildOrphanRemovalAdapter(); - private final AnnotationElementAdapter<Boolean> orphanRemovalAdapter; - private Boolean orphanRemoval; - - public SourceOneToManyAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.mappedByAdapter = this.buildAnnotationElementAdapter(MAPPED_BY_ADAPTER); - this.orphanRemovalAdapter = this.buildBooleanAnnotationElementAdapter(ORPHAN_REMOVAL_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.mappedBy = this.buildMappedBy(astRoot); - this.orphanRemoval = this.buildOrphanRemoval(astRoot); - } - - @Override - public void synchronizeWith(CompilationUnit astRoot) { - super.synchronizeWith(astRoot); - this.syncMappedBy(this.buildMappedBy(astRoot)); - this.syncOrphanRemoval(this.buildOrphanRemoval(astRoot)); - } - - - // ********** SourceRelationshipMappingAnnotation implementation ********** - - @Override - DeclarationAnnotationElementAdapter<String> getTargetEntityAdapter() { - return TARGET_ENTITY_ADAPTER; - } - - @Override - DeclarationAnnotationElementAdapter<String> getFetchAdapter() { - return FETCH_ADAPTER; - } - - @Override - DeclarationAnnotationElementAdapter<String[]> getCascadeAdapter() { - return CASCADE_ADAPTER; - } - - - // ********** OwnableRelationshipMappingAnnotation implementation ********** - - public String getMappedBy() { - return this.mappedBy; - } - - public void setMappedBy(String mappedBy) { - if (this.attributeValueHasChanged(this.mappedBy, mappedBy)) { - this.mappedBy = mappedBy; - this.mappedByAdapter.setValue(mappedBy); - } - } - - private void syncMappedBy(String astMappedBy) { - String old = this.mappedBy; - this.mappedBy = astMappedBy; - this.firePropertyChanged(MAPPED_BY_PROPERTY, old, astMappedBy); - } - - private String buildMappedBy(CompilationUnit astRoot) { - return this.mappedByAdapter.getValue(astRoot); - } - - public TextRange getMappedByTextRange(CompilationUnit astRoot) { - return getElementTextRange(MAPPED_BY_ADAPTER, astRoot); - } - - public boolean mappedByTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(MAPPED_BY_ADAPTER, pos, astRoot); - } - - // ********** OneToMany2_0Annotation implementation ********** - - public Boolean getOrphanRemoval() { - return this.orphanRemoval; - } - - public void setOrphanRemoval(Boolean orphanRemoval) { - if (this.attributeValueHasChanged(this.orphanRemoval, orphanRemoval)) { - this.orphanRemoval = orphanRemoval; - this.orphanRemovalAdapter.setValue(orphanRemoval); - } - } - - private void syncOrphanRemoval(Boolean astOrphanRemoval) { - Boolean old = this.orphanRemoval; - this.orphanRemoval = astOrphanRemoval; - this.firePropertyChanged(ORPHAN_REMOVAL_PROPERTY, old, astOrphanRemoval); - } - - public TextRange getOrphanRemovalTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(ORPHAN_REMOVAL_ADAPTER, astRoot); - } - - private Boolean buildOrphanRemoval(CompilationUnit astRoot) { - return this.orphanRemovalAdapter.getValue(astRoot); - } - - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter<String> buildTargetEntityAdapter() { - return buildTargetEntityAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.ONE_TO_MANY__TARGET_ENTITY); - } - - private static DeclarationAnnotationElementAdapter<String> buildMappedByAdapter() { - return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.ONE_TO_MANY__MAPPED_BY, false); // false = do not remove annotation when empty - } - - private static DeclarationAnnotationElementAdapter<String> buildFetchAdapter() { - return buildFetchAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.ONE_TO_MANY__FETCH); - } - - private static DeclarationAnnotationElementAdapter<String[]> buildCascadeAdapter() { - return buildEnumArrayAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.ONE_TO_MANY__CASCADE); - } - - private static DeclarationAnnotationElementAdapter<Boolean> buildOrphanRemovalAdapter() { - return buildOrphanRemovalAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA2_0.ONE_TO_MANY__ORPHAN_REMOVAL); - } - - private static DeclarationAnnotationElementAdapter<Boolean> buildOrphanRemovalAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { - return new ConversionDeclarationAnnotationElementAdapter<Boolean>(annotationAdapter, elementName, false, BooleanExpressionConverter.instance()); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceOneToOneAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceOneToOneAnnotation.java deleted file mode 100644 index 3ebc6a9ce2..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceOneToOneAnnotation.java +++ /dev/null @@ -1,219 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.BooleanExpressionConverter; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; -import org.eclipse.jpt.core.jpa2.resource.java.OneToOne2_0Annotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; - -/** - * javax.persistence.OneToOne - */ -public final class SourceOneToOneAnnotation - extends SourceRelationshipMappingAnnotation - implements OneToOne2_0Annotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - static final DeclarationAnnotationElementAdapter<String> TARGET_ENTITY_ADAPTER = buildTargetEntityAdapter(); - - private static final DeclarationAnnotationElementAdapter<String> FETCH_ADAPTER = buildFetchAdapter(); - - private static final DeclarationAnnotationElementAdapter<String[]> CASCADE_ADAPTER = buildCascadeAdapter(); - - private static final DeclarationAnnotationElementAdapter<Boolean> OPTIONAL_ADAPTER = buildOptionalAdapter(); - private final AnnotationElementAdapter<Boolean> optionalAdapter; - private Boolean optional; - - private static final DeclarationAnnotationElementAdapter<String> MAPPED_BY_ADAPTER = buildMappedByAdapter(); - private final AnnotationElementAdapter<String> mappedByAdapter; - private String mappedBy; - - //added in JPA 2.0 - private static final DeclarationAnnotationElementAdapter<Boolean> ORPHAN_REMOVAL_ADAPTER = buildOrphanRemovalAdapter(); - private final AnnotationElementAdapter<Boolean> orphanRemovalAdapter; - private Boolean orphanRemoval; - - public SourceOneToOneAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.mappedByAdapter = this.buildAnnotationElementAdapter(MAPPED_BY_ADAPTER); - this.optionalAdapter = this.buildBooleanAnnotationElementAdapter(OPTIONAL_ADAPTER); - this.orphanRemovalAdapter = this.buildBooleanAnnotationElementAdapter(ORPHAN_REMOVAL_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.mappedBy = this.buildMappedBy(astRoot); - this.optional = this.buildOptional(astRoot); - this.orphanRemoval = this.buildOrphanRemoval(astRoot); - } - - @Override - public void synchronizeWith(CompilationUnit astRoot) { - super.synchronizeWith(astRoot); - this.syncMappedBy(this.buildMappedBy(astRoot)); - this.syncOptional(this.buildOptional(astRoot)); - this.syncOrphanRemoval(this.buildOrphanRemoval(astRoot)); - } - - - // ********** SourceRelationshipMappingAnnotation implementation ********** - - @Override - DeclarationAnnotationElementAdapter<String> getTargetEntityAdapter() { - return TARGET_ENTITY_ADAPTER; - } - - @Override - DeclarationAnnotationElementAdapter<String> getFetchAdapter() { - return FETCH_ADAPTER; - } - - @Override - DeclarationAnnotationElementAdapter<String[]> getCascadeAdapter() { - return CASCADE_ADAPTER; - } - - - // ********** OneToOneAnnotation implementation ********** - - // ***** mapped by - public String getMappedBy() { - return this.mappedBy; - } - - public void setMappedBy(String mappedBy) { - if (this.attributeValueHasChanged(this.mappedBy, mappedBy)) { - this.mappedBy = mappedBy; - this.mappedByAdapter.setValue(mappedBy); - } - } - - private void syncMappedBy(String astMappedBy) { - String old = this.mappedBy; - this.mappedBy = astMappedBy; - this.firePropertyChanged(MAPPED_BY_PROPERTY, old, astMappedBy); - } - - private String buildMappedBy(CompilationUnit astRoot) { - return this.mappedByAdapter.getValue(astRoot); - } - - public TextRange getMappedByTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(MAPPED_BY_ADAPTER, astRoot); - } - - public boolean mappedByTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(MAPPED_BY_ADAPTER, pos, astRoot); - } - - // ***** optional - public Boolean getOptional() { - return this.optional; - } - - public void setOptional(Boolean optional) { - if (this.attributeValueHasChanged(this.optional, optional)) { - this.optional = optional; - this.optionalAdapter.setValue(optional); - } - } - - private void syncOptional(Boolean astOptional) { - Boolean old = this.optional; - this.optional = astOptional; - this.firePropertyChanged(OPTIONAL_PROPERTY, old, astOptional); - } - - private Boolean buildOptional(CompilationUnit astRoot) { - return this.optionalAdapter.getValue(astRoot); - } - - public TextRange getOptionalTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(OPTIONAL_ADAPTER, astRoot); - } - - // ********** OneToOne2_0Annotation implementation ********** - - public Boolean getOrphanRemoval() { - return this.orphanRemoval; - } - - public void setOrphanRemoval(Boolean orphanRemoval) { - if (this.attributeValueHasChanged(this.orphanRemoval, orphanRemoval)) { - this.orphanRemoval = orphanRemoval; - this.orphanRemovalAdapter.setValue(orphanRemoval); - } - } - - private void syncOrphanRemoval(Boolean astOrphanRemoval) { - Boolean old = this.orphanRemoval; - this.orphanRemoval = astOrphanRemoval; - this.firePropertyChanged(ORPHAN_REMOVAL_PROPERTY, old, astOrphanRemoval); - } - - public TextRange getOrphanRemovalTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(ORPHAN_REMOVAL_ADAPTER, astRoot); - } - - private Boolean buildOrphanRemoval(CompilationUnit astRoot) { - return this.orphanRemovalAdapter.getValue(astRoot); - } - - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter<String> buildTargetEntityAdapter() { - return buildTargetEntityAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.ONE_TO_ONE__TARGET_ENTITY); - } - - private static DeclarationAnnotationElementAdapter<String> buildMappedByAdapter() { - return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.ONE_TO_ONE__MAPPED_BY, false); // false = do not remove annotation when empty - } - - private static DeclarationAnnotationElementAdapter<String> buildFetchAdapter() { - return buildFetchAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.ONE_TO_ONE__FETCH); - } - - private static DeclarationAnnotationElementAdapter<Boolean> buildOptionalAdapter() { - return buildOptionalAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.ONE_TO_ONE__OPTIONAL); - } - - private static DeclarationAnnotationElementAdapter<Boolean> buildOptionalAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { - return new ConversionDeclarationAnnotationElementAdapter<Boolean>(annotationAdapter, elementName, false, BooleanExpressionConverter.instance()); - } - - private static DeclarationAnnotationElementAdapter<String[]> buildCascadeAdapter() { - return buildEnumArrayAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.ONE_TO_ONE__CASCADE); - } - - private static DeclarationAnnotationElementAdapter<Boolean> buildOrphanRemovalAdapter() { - return buildOrphanRemovalAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA2_0.ONE_TO_ONE__ORPHAN_REMOVAL); - } - - private static DeclarationAnnotationElementAdapter<Boolean> buildOrphanRemovalAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { - return new ConversionDeclarationAnnotationElementAdapter<Boolean>(annotationAdapter, elementName, false, BooleanExpressionConverter.instance()); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceOrderByAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceOrderByAnnotation.java deleted file mode 100644 index 8f146b5eea..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceOrderByAnnotation.java +++ /dev/null @@ -1,96 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.AnnotatedElementAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.OrderByAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; - -/** - * javax.persistence.OrderBy - */ -public final class SourceOrderByAnnotation - extends SourceAnnotation<Attribute> - implements OrderByAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter<String> VALUE_ADAPTER = buildValueAdapter(); - private final AnnotationElementAdapter<String> valueAdapter; - private String value; - - - public SourceOrderByAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.valueAdapter = new AnnotatedElementAnnotationElementAdapter<String>(attribute, VALUE_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - this.value = this.buildValue(astRoot); - } - - public void synchronizeWith(CompilationUnit astRoot) { - this.syncValue(this.buildValue(astRoot)); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.value); - } - - - // ********** OrderByAnnotation implementation ********** - - public String getValue() { - return this.value; - } - - public void setValue(String value) { - if (this.attributeValueHasChanged(this.value, value)) { - this.value = value; - this.valueAdapter.setValue(value); - } - } - - private void syncValue(String astValue) { - String old = this.value; - this.value = astValue; - this.firePropertyChanged(VALUE_PROPERTY, old, astValue); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(VALUE_ADAPTER, astRoot); - } - - private String buildValue(CompilationUnit astRoot) { - return this.valueAdapter.getValue(astRoot); - } - - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter<String> buildValueAdapter() { - return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.ORDER_BY__VALUE, false); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceOverrideAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceOverrideAnnotation.java deleted file mode 100644 index c9f26ce48b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceOverrideAnnotation.java +++ /dev/null @@ -1,116 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.AnnotatedElementAnnotationElementAdapter; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.resource.java.OverrideAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * Common behavior for - * javax.persistence.AttributeOverride - * javax.persistence.AssociationOverride - */ -abstract class SourceOverrideAnnotation - extends SourceAnnotation<Member> - implements OverrideAnnotation -{ - final DeclarationAnnotationElementAdapter<String> nameDeclarationAdapter; - final AnnotationElementAdapter<String> nameAdapter; - String name; - - - // ********** construction/initialization ********** - - SourceOverrideAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { - super(parent, member, daa, annotationAdapter); - this.nameDeclarationAdapter = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, this.getNameElementName(), false); // false = do not remove annotation when empty - this.nameAdapter = new AnnotatedElementAnnotationElementAdapter<String>(this.annotatedElement, this.nameDeclarationAdapter); - } - - public void initialize(CompilationUnit astRoot) { - this.name = this.buildName(astRoot); - } - - public void synchronizeWith(CompilationUnit astRoot) { - this.syncName(this.buildName(astRoot)); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - // ********** OverrideAnnotation implementation ********** - - // ***** name - public String getName() { - return this.name; - } - - public void setName(String name) { - if (this.attributeValueHasChanged(this.name, name)) { - this.name = name; - this.nameAdapter.setValue(name); - } - } - - private void syncName(String astName) { - String old = this.name; - this.name = astName; - this.firePropertyChanged(NAME_PROPERTY, old, astName); - } - - private String buildName(CompilationUnit astRoot) { - return this.nameAdapter.getValue(astRoot); - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.nameDeclarationAdapter, astRoot); - } - - public boolean nameTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(this.nameDeclarationAdapter, pos, astRoot); - } - - protected abstract String getNameElementName(); - - - // ********** NestableAnnotation implementation ********** - - void initializeFrom(NestableAnnotation oldAnnotation) { - OverrideAnnotation oldOverride = (OverrideAnnotation) oldAnnotation; - this.setName(oldOverride.getName()); - } - - /** - * convenience implementation of method from NestableAnnotation interface - * for subclasses - */ - public void moveAnnotation(int index) { - this.getIndexedAnnotationAdapter().moveAnnotation(index); - } - - private IndexedAnnotationAdapter getIndexedAnnotationAdapter() { - return (IndexedAnnotationAdapter) this.annotationAdapter; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePackage.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePackage.java deleted file mode 100644 index d48e1c4551..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePackage.java +++ /dev/null @@ -1,118 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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 - * - * Contributor: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import java.util.Iterator; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jdt.core.dom.IPackageBinding; -import org.eclipse.jdt.core.dom.PackageDeclaration; -import org.eclipse.jpt.core.internal.utility.jdt.JDTPackage; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourceCompilationUnit; -import org.eclipse.jpt.core.resource.java.JavaResourcePackage; -import org.eclipse.jpt.core.utility.jdt.AnnotatedPackage; - -/** - * @author Dmitry Geraskov - * Source package-info.java - * - */ -public final class SourcePackage - extends SourceAnnotatedElement<AnnotatedPackage> - implements JavaResourcePackage { - - private String name; - - /** - * construct package info - */ - public static JavaResourcePackage newInstance( - JavaResourceCompilationUnit parent, - PackageDeclaration declaringPackage, - CompilationUnit astRoot) { - AnnotatedPackage pack = new JDTPackage( - declaringPackage, - parent.getCompilationUnit(), - parent.getModifySharedDocumentCommandExecutor(), - parent.getAnnotationEditFormatter()); - JavaResourcePackage jrpp = new SourcePackage(parent, pack); - jrpp.initialize(astRoot); - return jrpp; - } - - private SourcePackage( - JavaResourceCompilationUnit parent, - AnnotatedPackage pack){ - super(parent, pack); - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.name = this.buildName(astRoot); - } - - - // ********** JavaResourcePackageInfo implementation ********** - - // ***** name - public String getName() { - return this.name; - } - - private void syncName(String astName) { - if (valuesAreDifferent(astName, this.name)){ - String old = this.name; - this.name = astName; - this.firePropertyChanged(NAME_PROPERTY, old, astName); - } - } - - private String buildName(CompilationUnit astRoot) { - IPackageBinding binding = this.annotatedElement.getBinding(astRoot); - return (binding == null) ? null : binding.getName(); - } - - - // ********** Java changes ********** - - @Override - public void synchronizeWith(CompilationUnit astRoot) { - super.synchronizeWith(astRoot); - this.syncName(this.buildName(astRoot)); - } - - // ********** SourceAnnotatedElement implementation ********** - - @Override - Iterator<String> validAnnotationNames() { - return this.getAnnotationProvider().packageAnnotationNames(); - } - - - @Override - Annotation buildAnnotation(String annotationName) { - return this.getAnnotationProvider().buildPackageAnnotation(this, this.annotatedElement, annotationName); - } - - @Override - Annotation buildNullAnnotation(String annotationName) { - return this.getAnnotationProvider().buildNullPackageAnnotation(this, annotationName); - } - - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePackageInfoCompilationUnit.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePackageInfoCompilationUnit.java deleted file mode 100644 index 67b97ebcef..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePackageInfoCompilationUnit.java +++ /dev/null @@ -1,121 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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 - * - * Contributor: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import java.util.Iterator; - -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jdt.core.dom.PackageDeclaration; -import org.eclipse.jpt.core.JpaAnnotationProvider; -import org.eclipse.jpt.core.JpaResourceType; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.resource.java.JavaResourcePackage; -import org.eclipse.jpt.core.resource.java.JavaResourcePackageInfoCompilationUnit; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.jdt.AnnotationEditFormatter; -import org.eclipse.jpt.utility.CommandExecutor; -import org.eclipse.jpt.utility.internal.iterators.EmptyIterator; - -/** - * @author Dmitry Geraskov - * Source package-info.java - * - */ -public final class SourcePackageInfoCompilationUnit - extends SourceCompilationUnit - implements JavaResourcePackageInfoCompilationUnit { - - private JavaResourcePackage package_; - - public SourcePackageInfoCompilationUnit( - ICompilationUnit compilationUnit, - JpaAnnotationProvider annotationProvider, - AnnotationEditFormatter annotationEditFormatter, - CommandExecutor modifySharedDocumentCommandExecutor) { - super(compilationUnit, annotationProvider, annotationEditFormatter, modifySharedDocumentCommandExecutor); // the JPA compilation unit is the root of its sub-tree - this.package_ = this.buildPackage(); - } - - - private JavaResourcePackage buildPackage() { - this.openCompilationUnit(); - CompilationUnit astRoot = this.buildASTRoot(); - this.closeCompilationUnit(); - return this.buildPackage(astRoot); - } - - - // ********** JavaResourceNode.Root implementation ********** - - public Iterator<JavaResourcePersistentType> persistentTypes() { - return EmptyIterator.instance(); - } - - - // ********** JpaResourceModel implementation ********** - - public JpaResourceType getResourceType() { - return JptCorePlugin.JAVA_SOURCE_PACKAGE_INFO_RESOURCE_TYPE; - } - - - // ********** Java changes ********** - - public void synchronizeWith(CompilationUnit astRoot) { - this.syncPackage(astRoot); - } - - - // ********** JavaResourceCompilationUnit implementation ********** - - public void resolveTypes() { - //no-op - } - - // ********** package-info ********** - - public JavaResourcePackage getPackage() { - return this.package_; - } - - private JavaResourcePackage buildPackage(CompilationUnit astRoot) { - return this.buildPackage(astRoot, this.getPackageDeclaration(astRoot)); - } - - private void syncPackage(CompilationUnit astRoot) { - PackageDeclaration pd = this.getPackageDeclaration(astRoot); - if (pd == null) { - this.syncPackage_(null); - } else { - if (this.package_ == null) { - this.syncPackage_(this.buildPackage(astRoot, pd)); - } else { - this.package_.synchronizeWith(astRoot); - } - } - } - - private PackageDeclaration getPackageDeclaration(CompilationUnit astRoot) { - return astRoot.getPackage(); - } - - private void syncPackage_(JavaResourcePackage astPackage) { - JavaResourcePackage old = this.package_; - this.package_ = astPackage; - this.firePropertyChanged(PACKAGE, old, astPackage); - } - - private JavaResourcePackage buildPackage(CompilationUnit astRoot, PackageDeclaration packageDeclaration) { - return SourcePackage.newInstance(this, packageDeclaration, astRoot); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentAttribute.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentAttribute.java deleted file mode 100644 index 6868e2c2e2..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentAttribute.java +++ /dev/null @@ -1,400 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jdt.core.dom.IBinding; -import org.eclipse.jdt.core.dom.ITypeBinding; -import org.eclipse.jpt.core.internal.utility.jdt.JDTFieldAttribute; -import org.eclipse.jpt.core.internal.utility.jdt.JDTMethodAttribute; -import org.eclipse.jpt.core.jpa2.resource.java.Access2_0Annotation; -import org.eclipse.jpt.core.resource.java.AccessType; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourceCompilationUnit; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.MethodAttribute; -import org.eclipse.jpt.core.utility.jdt.Type; -import org.eclipse.jpt.utility.MethodSignature; -import org.eclipse.jpt.utility.internal.ClassName; -import org.eclipse.jpt.utility.internal.iterators.CloneIterator; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * Java source persistent attribute (field or property) - */ -final class SourcePersistentAttribute - extends SourcePersistentMember<Attribute> - implements JavaResourcePersistentAttribute -{ - private int modifiers; - - private String typeName; - - private boolean typeIsInterface; - - private boolean typeIsEnum; - - private final Vector<String> typeSuperclassNames = new Vector<String>(); - - private final Vector<String> typeInterfaceNames = new Vector<String>(); - - private final Vector<String> typeTypeArgumentNames = new Vector<String>(); - - - /** - * construct field attribute - */ - static JavaResourcePersistentAttribute newInstance( - JavaResourcePersistentType parent, - Type declaringType, - String name, - int occurrence, - JavaResourceCompilationUnit javaResourceCompilationUnit, - CompilationUnit astRoot) { - Attribute attribute = new JDTFieldAttribute( - declaringType, - name, - occurrence, - javaResourceCompilationUnit.getCompilationUnit(), - javaResourceCompilationUnit.getModifySharedDocumentCommandExecutor(), - javaResourceCompilationUnit.getAnnotationEditFormatter()); - JavaResourcePersistentAttribute jrpa = new SourcePersistentAttribute(parent, attribute); - jrpa.initialize(astRoot); - return jrpa; - } - - /** - * construct property attribute - */ - static JavaResourcePersistentAttribute newInstance( - JavaResourcePersistentType parent, - Type declaringType, - MethodSignature signature, - int occurrence, - JavaResourceCompilationUnit javaResourceCompilationUnit, - CompilationUnit astRoot) { - Attribute attribute = JDTMethodAttribute.newInstance( - declaringType, - signature, - occurrence, - javaResourceCompilationUnit.getCompilationUnit(), - javaResourceCompilationUnit.getModifySharedDocumentCommandExecutor(), - javaResourceCompilationUnit.getAnnotationEditFormatter()); - JavaResourcePersistentAttribute jrpa = new SourcePersistentAttribute(parent, attribute); - jrpa.initialize(astRoot); - return jrpa; - } - - private SourcePersistentAttribute(JavaResourcePersistentType parent, Attribute attribute){ - super(parent, attribute); - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - ITypeBinding typeBinding = this.getTypeBinding(astRoot); //build once, minor performance tweak for major benefit - this.modifiers = this.buildModifiers(astRoot); - this.typeName = this.buildTypeName(typeBinding); - this.typeIsInterface = this.buildTypeIsInterface(typeBinding); - this.typeIsEnum = this.buildTypeIsEnum(typeBinding); - this.typeSuperclassNames.addAll(this.buildTypeSuperclassNames(typeBinding)); - this.typeInterfaceNames.addAll(this.buildTypeInterfaceNames(typeBinding)); - this.typeTypeArgumentNames.addAll(this.buildTypeTypeArgumentNames(typeBinding)); - } - - - // ******** overrides ******** - - @Override - public void resolveTypes(CompilationUnit astRoot) { - super.resolveTypes(astRoot); - ITypeBinding typeBinding = this.getTypeBinding(astRoot);//build once, minor performance tweak for major benefit - this.syncTypeName(this.buildTypeName(typeBinding)); - this.syncTypeSuperclassNames(this.buildTypeSuperclassNames(typeBinding)); - this.syncTypeInterfaceNames(this.buildTypeInterfaceNames(typeBinding)); - this.syncTypeTypeArgumentNames(this.buildTypeTypeArgumentNames(typeBinding)); - } - - @Override - public void synchronizeWith(CompilationUnit astRoot) { - super.synchronizeWith(astRoot); - ITypeBinding typeBinding = this.getTypeBinding(astRoot);//build once, minor performance tweak for major benefit - this.syncModifiers(this.buildModifiers(astRoot)); - this.syncTypeName(this.buildTypeName(typeBinding)); - this.syncTypeIsInterface(this.buildTypeIsInterface(typeBinding)); - this.syncTypeIsEnum(this.buildTypeIsEnum(typeBinding)); - this.syncTypeSuperclassNames(this.buildTypeSuperclassNames(typeBinding)); - this.syncTypeInterfaceNames(this.buildTypeInterfaceNames(typeBinding)); - this.syncTypeTypeArgumentNames(this.buildTypeTypeArgumentNames(typeBinding)); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.getName()); - } - - - // ******** AbstractJavaResourcePersistentMember implementation ******** - - @Override - Iterator<String> validAnnotationNames() { - return this.getAnnotationProvider().attributeAnnotationNames(); - } - - @Override - Annotation buildAnnotation(String annotationName) { - return this.getAnnotationProvider().buildAttributeAnnotation(this, this.annotatedElement, annotationName); - } - - Annotation buildNullAnnotation_(String annotationName) { - return this.getAnnotationProvider().buildNullAttributeAnnotation(this, annotationName); - } - - public boolean isFor(MethodSignature signature, int occurrence) { - return ((MethodAttribute) this.annotatedElement).matches(signature, occurrence); - } - - - // ******** JavaResourcePersistentAttribute implementation ******** - - public String getName() { - return this.annotatedElement.getAttributeName(); - } - - @Override - public Annotation buildNullAnnotation(String annotationName) { - return (annotationName == null) ? null : this.buildNullAnnotation_(annotationName); - } - - public boolean isField() { - return this.annotatedElement.isField(); - } - - public boolean isProperty() { - return ! this.isField(); - } - - public AccessType getSpecifiedAccess() { - Access2_0Annotation accessAnnotation = this.getAccessAnnotation(); - return (accessAnnotation == null) ? null : accessAnnotation.getValue(); - } - - private Access2_0Annotation getAccessAnnotation() { - return (Access2_0Annotation) this.getAnnotation(Access2_0Annotation.ANNOTATION_NAME); - } - - public boolean typeIsSubTypeOf(String tn) { - if (this.typeName == null) { - return false; - } - return this.typeName.equals(tn) - || this.typeInterfaceNames.contains(tn) - || this.typeSuperclassNames.contains(tn); - } - - public boolean typeIsVariablePrimitive() { - return (this.typeName != null) && ClassName.isVariablePrimitive(this.typeName); - } - - private ITypeBinding getTypeBinding(CompilationUnit astRoot) { - return this.annotatedElement.getTypeBinding(astRoot); - } - - - // ***** modifiers - public int getModifiers() { - return this.modifiers; - } - - private void syncModifiers(int astModifiers) { - int old = this.modifiers; - this.modifiers = astModifiers; - this.firePropertyChanged(MODIFIERS_PROPERTY, old, astModifiers); - } - - /** - * zero seems like a reasonable default... - */ - private int buildModifiers(CompilationUnit astRoot) { - IBinding binding = this.annotatedElement.getBinding(astRoot); - return (binding == null) ? 0 : binding.getModifiers(); - } - - // ***** type name - public String getTypeName() { - return this.typeName; - } - - private void syncTypeName(String astTypeName) { - String old = this.typeName; - this.typeName = astTypeName; - this.firePropertyChanged(TYPE_NAME_PROPERTY, old, astTypeName); - } - - /** - * this can be an array (e.g. "java.lang.String[]"); - * but no generic type arguments - */ - private String buildTypeName(ITypeBinding typeBinding) { - if (typeBinding == null) { - return null; - } - // a type variable is what is declared by a generic type; - // e.g. "E" is a type variable declared by the generic type "Collection" in - // public interface Collection<E> - if (typeBinding.isTypeVariable()) { - // e.g. "E extends Number" has an erasure of "Number" - typeBinding = typeBinding.getErasure(); - } - String tbName = typeBinding.getTypeDeclaration().getQualifiedName(); - return (tbName.length() == 0) ? null : tbName; - } - - // ***** type is interface - public boolean typeIsInterface() { - return this.typeIsInterface; - } - - private void syncTypeIsInterface(boolean astTypeIsInterface) { - boolean old = this.typeIsInterface; - this.typeIsInterface = astTypeIsInterface; - this.firePropertyChanged(TYPE_IS_INTERFACE_PROPERTY, old, astTypeIsInterface); - } - - private boolean buildTypeIsInterface(ITypeBinding typeBinding) { - return (typeBinding != null) && ( ! typeBinding.isArray()) && typeBinding.isInterface(); - } - - // ***** type is enum - public boolean typeIsEnum() { - return this.typeIsEnum; - } - - private void syncTypeIsEnum(boolean astTypeIsEnum) { - boolean old = this.typeIsEnum; - this.typeIsEnum = astTypeIsEnum; - this.firePropertyChanged(TYPE_IS_ENUM_PROPERTY, old, astTypeIsEnum); - } - - private boolean buildTypeIsEnum(ITypeBinding typeBinding) { - return (typeBinding != null) && ( ! typeBinding.isArray()) && typeBinding.isEnum(); - } - - // ***** type superclass hierarchy - public ListIterator<String> typeSuperclassNames() { - return new CloneListIterator<String>(this.typeSuperclassNames); - } - - private void syncTypeSuperclassNames(List<String> astTypeSuperclassNames) { - this.synchronizeList(astTypeSuperclassNames, this.typeSuperclassNames, TYPE_SUPERCLASS_NAMES_LIST); - } - - private List<String> buildTypeSuperclassNames(ITypeBinding typeBinding) { - if (typeBinding == null) { - return Collections.emptyList(); - } - ArrayList<String> names = new ArrayList<String>(); - typeBinding = typeBinding.getSuperclass(); - while (typeBinding != null) { - names.add(typeBinding.getQualifiedName()); - typeBinding = typeBinding.getSuperclass(); - } - return names; - } - - // ***** type interface hierarchy - public Iterator<String> typeInterfaceNames() { - return new CloneIterator<String>(this.typeInterfaceNames); - } - -// private boolean typeInterfaceNamesContains(String interfaceName) { -// return this.typeInterfaceNames.contains(interfaceName); -// } -// - private void syncTypeInterfaceNames(Collection<String> astTypeInterfaceNames) { - this.synchronizeCollection(astTypeInterfaceNames, this.typeInterfaceNames, TYPE_INTERFACE_NAMES_COLLECTION); - } - - private Collection<String> buildTypeInterfaceNames(ITypeBinding typeBinding) { - if (typeBinding == null) { - return Collections.emptySet(); - } - HashSet<String> names = new HashSet<String>(); - while (typeBinding != null) { - this.addInterfaceNamesTo(typeBinding, names); - typeBinding = typeBinding.getSuperclass(); - } - return names; - } - - private void addInterfaceNamesTo(ITypeBinding typeBinding, HashSet<String> names) { - for (ITypeBinding interfaceBinding : typeBinding.getInterfaces()) { - names.add(interfaceBinding.getTypeDeclaration().getQualifiedName()); - this.addInterfaceNamesTo(interfaceBinding, names); // recurse - } - } - - // ***** type type argument names - public ListIterator<String> typeTypeArgumentNames() { - return new CloneListIterator<String>(this.typeTypeArgumentNames); - } - - public int typeTypeArgumentNamesSize() { - return this.typeTypeArgumentNames.size(); - } - - public String getTypeTypeArgumentName(int index) { - return this.typeTypeArgumentNames.get(index); - } - - private void syncTypeTypeArgumentNames(List<String> astTypeTypeArgumentNames) { - this.synchronizeList(astTypeTypeArgumentNames, this.typeTypeArgumentNames, TYPE_TYPE_ARGUMENT_NAMES_LIST); - } - - /** - * these types can be arrays (e.g. "java.lang.String[]"); - * but they won't have any further nested generic type arguments - * (e.g. "java.util.Collection<java.lang.String>") - */ - private List<String> buildTypeTypeArgumentNames(ITypeBinding typeBinding) { - if (typeBinding == null) { - return Collections.emptyList(); - } - - ITypeBinding[] typeArguments = typeBinding.getTypeArguments(); - if (typeArguments.length == 0) { - return Collections.emptyList(); - } - - ArrayList<String> names = new ArrayList<String>(typeArguments.length); - for (ITypeBinding typeArgument : typeArguments) { - if (typeArgument == null) { - names.add(null); - } else { - // e.g. "? extends Number" has an erasure of "Number" - ITypeBinding erasure = typeArgument.getErasure(); - names.add(erasure.getTypeDeclaration().getQualifiedName()); - } - } - return names; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentMember.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentMember.java deleted file mode 100644 index bcfe6a851e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentMember.java +++ /dev/null @@ -1,139 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import java.util.ArrayList; -import java.util.Iterator; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jdt.core.dom.IBinding; -import org.eclipse.jdt.core.dom.Modifier; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterators.FilteringIterator; - -/** - * Java source persistent member (annotations, "persistable") - */ -abstract class SourcePersistentMember<M extends Member> - extends SourceAnnotatedElement<M> - implements JavaResourcePersistentMember -{ - - boolean persistable; - - boolean final_; // 'final' is a reserved word - - - // ********** construction/initialization ********** - - SourcePersistentMember(JavaResourceNode parent, M member) { - super(parent, member); - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.persistable = this.buildPersistable(astRoot); - IBinding binding = this.annotatedElement.getBinding(astRoot); - this.final_ = this.buildFinal(binding); - } - - @Override - public void synchronizeWith(CompilationUnit astRoot) { - super.synchronizeWith(astRoot); - this.syncPersistable(this.buildPersistable(astRoot)); - IBinding binding = this.annotatedElement.getBinding(astRoot); - this.syncFinal(this.buildFinal(binding)); - } - - - // ********** annotations ********** - - public Annotation setPrimaryAnnotation(String primaryAnnotationName, Iterable<String> supportingAnnotationNames) { - ArrayList<String> annotationNames = new ArrayList<String>(); - CollectionTools.addAll(annotationNames, supportingAnnotationNames); - if (primaryAnnotationName != null) { - annotationNames.add(primaryAnnotationName); - } - for (Annotation annotation : this.getAnnotations()) { - if ( ! CollectionTools.contains(annotationNames, annotation.getAnnotationName())) { - this.annotations.remove(annotation); - annotation.removeAnnotation(); - } - } - Annotation newPrimaryAnnotation = null; - if ((primaryAnnotationName != null) && (this.getAnnotation(primaryAnnotationName) == null)) { - newPrimaryAnnotation = this.buildAnnotation(primaryAnnotationName); - this.annotations.add(newPrimaryAnnotation); - newPrimaryAnnotation.newAnnotation(); - } - // fire collection change event after all annotation changes are done - this.fireCollectionChanged(ANNOTATIONS_COLLECTION, this.annotations); - return newPrimaryAnnotation; - } - - - // ********** persistable ********** - - public boolean isPersistable() { - return this.persistable; - } - - private void syncPersistable(boolean astPersistable) { - boolean old = this.persistable; - this.persistable = astPersistable; - this.firePropertyChanged(PERSISTABLE_PROPERTY, old, astPersistable); - } - - private boolean buildPersistable(CompilationUnit astRoot) { - return this.annotatedElement.isPersistable(astRoot); - } - - // ***** final - public boolean isFinal() { - return this.final_; - } - - private void syncFinal(boolean astFinal) { - boolean old = this.final_; - this.final_ = astFinal; - this.firePropertyChanged(FINAL_PROPERTY, old, astFinal); - } - - private boolean buildFinal(IBinding binding) { - return (binding == null) ? false : Modifier.isFinal(binding.getModifiers()); - } - - - // ********** miscellaneous ********** - - public boolean isFor(String memberName, int occurrence) { - return this.annotatedElement.matches(memberName, occurrence); - } - - public void resolveTypes(CompilationUnit astRoot) { - this.syncPersistable(this.buildPersistable(astRoot)); - } - - /** - * convenience method - */ - <T extends JavaResourcePersistentMember> Iterator<T> persistableMembers(Iterator<T> members) { - return new FilteringIterator<T>(members) { - @Override - protected boolean accept(T m) { - return m.isPersistable(); - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentType.java deleted file mode 100644 index 138da40533..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentType.java +++ /dev/null @@ -1,948 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Vector; - -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jdt.core.dom.FieldDeclaration; -import org.eclipse.jdt.core.dom.IAnnotationBinding; -import org.eclipse.jdt.core.dom.IMethodBinding; -import org.eclipse.jdt.core.dom.ITypeBinding; -import org.eclipse.jdt.core.dom.MethodDeclaration; -import org.eclipse.jdt.core.dom.Modifier; -import org.eclipse.jdt.core.dom.TypeDeclaration; -import org.eclipse.jdt.core.dom.VariableDeclarationFragment; -import org.eclipse.jpt.core.internal.jpa2.resource.java.GeneratedAnnotationDefinition; -import org.eclipse.jpt.core.internal.jpa2.resource.java.StaticMetamodelAnnotationDefinition; -import org.eclipse.jpt.core.internal.utility.jdt.ASTTools; -import org.eclipse.jpt.core.internal.utility.jdt.JDTType; -import org.eclipse.jpt.core.internal.utility.jdt.JPTTools; -import org.eclipse.jpt.core.jpa2.resource.java.GeneratedAnnotation; -import org.eclipse.jpt.core.jpa2.resource.java.JavaResourcePersistentType2_0; -import org.eclipse.jpt.core.jpa2.resource.java.StaticMetamodelAnnotation; -import org.eclipse.jpt.core.resource.java.AccessType; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourceCompilationUnit; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.jdt.Type; -import org.eclipse.jpt.utility.MethodSignature; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.IntReference; -import org.eclipse.jpt.utility.internal.StringTools; -import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable; -import org.eclipse.jpt.utility.internal.iterators.CompositeIterator; -import org.eclipse.jpt.utility.internal.iterators.FilteringIterator; -import org.eclipse.jpt.utility.internal.iterators.TreeIterator; - -/** - * Java source persistent type - */ -final class SourcePersistentType - extends SourcePersistentMember<Type> - implements JavaResourcePersistentType2_0 -{ - private String name; - - private String qualifiedName; - - private String packageName; - - private String superclassQualifiedName; - - private String declaringTypeName; - - private boolean abstract_; // 'abstract' is a reserved word - - private boolean static_; // 'static' is a reserved word - - private boolean memberType; - - private boolean hasPrivateNoArgConstructor; - - private boolean hasNoArgConstructor; - - private final Vector<JavaResourcePersistentType> types; - - private final Vector<JavaResourcePersistentAttribute> fields; - - private final Vector<JavaResourcePersistentAttribute> methods; - - private AccessType access; - - private StaticMetamodelAnnotation staticMetamodelAnnotation; - //TODO move to interface after maintenance - public static final String STATIC_METAMODEL_ANNOTATION_PROPERTY = "staticMetamodelAnnotation"; //$NON-NLS-1$ - - private GeneratedAnnotation generatedAnnotation; - //TODO move to interface after maintenance - public static final String GENERATED_ANNOTATION_PROPERTY = "generatedAnnotation"; //$NON-NLS-1$ - - - private static final StaticMetamodelAnnotationDefinition STATIC_METAMODEL_ANNOTATION_DEFINITION = StaticMetamodelAnnotationDefinition.instance(); - private static final GeneratedAnnotationDefinition GENERATED_ANNOTATION_DEFINITION = GeneratedAnnotationDefinition.instance(); - - - // ********** construction/initialization ********** - - /** - * build top-level persistent type - */ - static JavaResourcePersistentType newInstance( - JavaResourceCompilationUnit javaResourceCompilationUnit, - TypeDeclaration typeDeclaration, - CompilationUnit astRoot) { - Type type = new JDTType( - typeDeclaration, - javaResourceCompilationUnit.getCompilationUnit(), - javaResourceCompilationUnit.getModifySharedDocumentCommandExecutor(), - javaResourceCompilationUnit.getAnnotationEditFormatter()); - JavaResourcePersistentType jrpt = new SourcePersistentType(javaResourceCompilationUnit, type); - jrpt.initialize(astRoot); - return jrpt; - } - - /** - * build nested persistent type - */ - private static JavaResourcePersistentType newInstance( - JavaResourceCompilationUnit javaResourceCompilationUnit, - Type declaringType, - TypeDeclaration typeDeclaration, - int occurrence, - CompilationUnit astRoot) { - Type type = new JDTType( - declaringType, - typeDeclaration, - occurrence, - javaResourceCompilationUnit.getCompilationUnit(), - javaResourceCompilationUnit.getModifySharedDocumentCommandExecutor(), - javaResourceCompilationUnit.getAnnotationEditFormatter()); - JavaResourcePersistentType jrpt = new SourcePersistentType(javaResourceCompilationUnit, type); - jrpt.initialize(astRoot); - return jrpt; - } - - private SourcePersistentType(JavaResourceCompilationUnit javaResourceCompilationUnit, Type type) { - super(javaResourceCompilationUnit, type); - this.types = new Vector<JavaResourcePersistentType>(); - this.fields = new Vector<JavaResourcePersistentAttribute>(); - this.methods = new Vector<JavaResourcePersistentAttribute>(); - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - ITypeBinding binding = this.annotatedElement.getBinding(astRoot); - this.name = this.buildName(binding); - this.qualifiedName = this.buildQualifiedName(binding); - this.packageName = this.buildPackageName(binding); - this.superclassQualifiedName = this.buildSuperclassQualifiedName(binding); - this.declaringTypeName = this.buildDeclaringTypeName(binding); - this.abstract_ = this.buildAbstract(binding); - this.static_ = this.buildStatic(binding); - this.memberType = this.buildMemberType(binding); - this.hasNoArgConstructor = this.buildHasNoArgConstructor(binding); - this.hasPrivateNoArgConstructor = this.buildHasPrivateNoArgConstructor(binding); - this.initializeTypes(astRoot); - this.initializeFields(astRoot); - this.initializeMethods(astRoot); - // need to wait until everything is built to calculate 'access' - this.access = this.buildAccess(); - } - - /** - * Handle the <code>StaticMetamodel</code> and <code>Generated</code> - * annotations differently, since they are not really JPA "mapping" - * annotations.... - */ - @Override - void addInitialAnnotation(String jdtAnnotationName, CompilationUnit astRoot) { - if (jdtAnnotationName.equals(STATIC_METAMODEL_ANNOTATION_DEFINITION.getAnnotationName())) { - if (this.staticMetamodelAnnotation == null) { // ignore duplicates - this.staticMetamodelAnnotation = STATIC_METAMODEL_ANNOTATION_DEFINITION.buildAnnotation(this, this.annotatedElement); - this.staticMetamodelAnnotation.initialize(astRoot); - } - } else if (jdtAnnotationName.equals(GENERATED_ANNOTATION_DEFINITION.getAnnotationName())) { - if (this.generatedAnnotation == null) { // ignore duplicates - this.generatedAnnotation = GENERATED_ANNOTATION_DEFINITION.buildAnnotation(this, this.annotatedElement); - this.generatedAnnotation.initialize(astRoot); - } - } else { - super.addInitialAnnotation(jdtAnnotationName, astRoot); - } - } - - - // ********** update ********** - - @Override - public void synchronizeWith(CompilationUnit astRoot) { - super.synchronizeWith(astRoot); - ITypeBinding binding = this.annotatedElement.getBinding(astRoot); - this.syncName(this.buildName(binding)); - this.syncQualifiedName(this.buildQualifiedName(binding)); - this.syncPackageName(this.buildPackageName(binding)); - this.syncSuperclassQualifiedName(this.buildSuperclassQualifiedName(binding)); - this.syncDeclaringTypeName(this.buildDeclaringTypeName(binding)); - this.syncAbstract(this.buildAbstract(binding)); - this.syncStatic(this.buildStatic(binding)); - this.syncMemberType(this.buildMemberType(binding)); - this.syncHasNoArgConstructor(this.buildHasNoArgConstructor(binding)); - this.syncHasPrivateNoArgConstructor(this.buildHasPrivateNoArgConstructor(binding)); - this.syncTypes(astRoot); - this.syncFields(astRoot); - this.syncMethods(astRoot); - this.syncMetamodelAnnotations(astRoot); - // need to wait until everything is built to calculate 'access' - this.syncAccess(this.buildAccess()); - } - - /** - * Handle the <code>StaticMetamodel</code> and <code>Generated</code> - * annotations differently, since they are not really JPA "mapping" - * annotations. We aren't overriding {@link #addOrSyncAnnotation(String, CompilationUnit, java.util.Set)} - * because we also have to handle removing these annotations separately. - */ - private void syncMetamodelAnnotations(CompilationUnit astRoot) { - ITypeBinding binding = this.annotatedElement.getBinding(astRoot); - this.syncStaticMetamodelAnnotation(astRoot, binding); - this.syncGeneratedAnnotation(astRoot, binding); - } - - private void syncStaticMetamodelAnnotation(CompilationUnit astRoot, ITypeBinding binding) { - if (binding != null && this.containsStaticMetamodelAnnotation(binding)) { - if (this.staticMetamodelAnnotation != null) { - this.staticMetamodelAnnotation.synchronizeWith(astRoot); - } - else { - StaticMetamodelAnnotation newStaticMetamodelAnnotation = STATIC_METAMODEL_ANNOTATION_DEFINITION.buildAnnotation(this, this.annotatedElement); - newStaticMetamodelAnnotation.initialize(astRoot); - this.setStaticMetamodelAnnotation(newStaticMetamodelAnnotation); - } - } - else { - this.setStaticMetamodelAnnotation(null); - } - } - - private void syncGeneratedAnnotation(CompilationUnit astRoot, ITypeBinding binding) { - if (binding != null && this.containsGeneratedAnnotation(binding)) { - if (this.generatedAnnotation != null) { - this.generatedAnnotation.synchronizeWith(astRoot); - } - else { - GeneratedAnnotation newGeneratedAnnotation = GENERATED_ANNOTATION_DEFINITION.buildAnnotation(this, this.annotatedElement); - newGeneratedAnnotation.initialize(astRoot); - this.setGeneratedAnnotation(newGeneratedAnnotation); - } - } - else { - this.setGeneratedAnnotation(null); - } - } - - private boolean containsStaticMetamodelAnnotation(ITypeBinding binding) { - return this.containsAnnotation(binding, STATIC_METAMODEL_ANNOTATION_DEFINITION.getAnnotationName()); - } - - private boolean containsGeneratedAnnotation(ITypeBinding binding) { - return this.containsAnnotation(binding, GENERATED_ANNOTATION_DEFINITION.getAnnotationName()); - } - - private boolean containsAnnotation(ITypeBinding binding, String annotationName) { - for (IAnnotationBinding annotationBinding : binding.getAnnotations()) { - ITypeBinding annotationTypeBinding = annotationBinding.getAnnotationType(); - if (annotationTypeBinding != null && annotationTypeBinding.getQualifiedName().equals(annotationName)) { - return true; - } - } - return false; - } - - // ********** SourcePersistentMember implementation ********** - - @Override - Iterator<String> validAnnotationNames() { - return this.getAnnotationProvider().typeAnnotationNames(); - } - - @Override - Annotation buildAnnotation(String annotationName) { - return this.getAnnotationProvider().buildTypeAnnotation(this, this.annotatedElement, annotationName); - } - - @Override - Annotation buildNullAnnotation(String annotationName) { - return this.getAnnotationProvider().buildNullTypeAnnotation(this, annotationName); - } - - @Override - public void resolveTypes(CompilationUnit astRoot) { - super.resolveTypes(astRoot); - - this.syncSuperclassQualifiedName(this.buildSuperclassQualifiedName(this.annotatedElement.getBinding(astRoot))); - - for (JavaResourcePersistentAttribute field : this.getFields()) { - field.resolveTypes(astRoot); - } - - // a new type can trigger a method parameter type to be a resolved, - // fully-qualified name, so we need to rebuild our list of methods: - // "setFoo(Foo)" is not the same as "setFoo(com.bar.Foo)" - // and, vice-versa, a removed type can "unresolve" a parameter type - this.syncMethods(astRoot); - - for (JavaResourcePersistentAttribute method : this.getMethods()) { - method.resolveTypes(astRoot); - } - for (JavaResourcePersistentType type : this.getTypes()) { - type.resolveTypes(astRoot); - } - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - // ******** JavaResourcePersistentType implementation ******** - - // ***** name - public String getName() { - return this.name; - } - - private void syncName(String astName) { - String old = this.name; - this.name = astName; - this.firePropertyChanged(NAME_PROPERTY, old, astName); - } - - private String buildName(ITypeBinding binding) { - return (binding == null) ? null : binding.getName(); - } - - // ***** qualified name - public String getQualifiedName() { - return this.qualifiedName; - } - - private void syncQualifiedName(String astQualifiedName) { - String old = this.qualifiedName; - this.qualifiedName = astQualifiedName; - this.firePropertyChanged(QUALIFIED_NAME_PROPERTY, old, astQualifiedName); - } - - private String buildQualifiedName(ITypeBinding binding) { - return (binding == null) ? null : binding.getQualifiedName(); - } - - // ***** package name - public String getPackageName() { - return this.packageName; - } - - private void syncPackageName(String astPackageName) { - String old = this.packageName; - this.packageName = astPackageName; - this.firePropertyChanged(PACKAGE_NAME_PROPERTY, old, astPackageName); - } - - private String buildPackageName(ITypeBinding binding) { - return (binding == null) ? null : binding.getPackage().getName(); - } - - // ***** superclass qualified name - public String getSuperclassQualifiedName() { - return this.superclassQualifiedName; - } - - private void syncSuperclassQualifiedName(String astSuperclassQualifiedName) { - String old = this.superclassQualifiedName; - this.superclassQualifiedName = astSuperclassQualifiedName; - this.firePropertyChanged(SUPERCLASS_QUALIFIED_NAME_PROPERTY, old, astSuperclassQualifiedName); - } - - private String buildSuperclassQualifiedName(ITypeBinding binding) { - if (binding == null) { - return null; - } - ITypeBinding superclass = binding.getSuperclass(); - return (superclass == null) ? null : superclass.getTypeDeclaration().getQualifiedName(); - } - - // ***** package - public boolean isIn(IPackageFragment packageFragment) { - return StringTools.stringsAreEqual(packageFragment.getElementName(), this.packageName); - } - - // ***** declaring type name - public String getDeclaringTypeName() { - return this.declaringTypeName; - } - - private void syncDeclaringTypeName(String astDeclaringTypeName) { - String old = this.declaringTypeName; - this.declaringTypeName = astDeclaringTypeName; - this.firePropertyChanged(DECLARING_TYPE_NAME_PROPERTY, old, astDeclaringTypeName); - } - - private String buildDeclaringTypeName(ITypeBinding binding) { - if (binding == null) { - return null; - } - ITypeBinding declaringClass = binding.getDeclaringClass(); - return (declaringClass == null) ? null : declaringClass.getTypeDeclaration().getQualifiedName(); - } - - // ***** abstract - public boolean isAbstract() { - return this.abstract_; - } - - private void syncAbstract(boolean astAbstract) { - boolean old = this.abstract_; - this.abstract_ = astAbstract; - this.firePropertyChanged(ABSTRACT_PROPERTY, old, astAbstract); - } - - private boolean buildAbstract(ITypeBinding binding) { - return (binding == null) ? false : Modifier.isAbstract(binding.getModifiers()); - } - - // ***** static - public boolean isStatic() { - return this.static_; - } - - private void syncStatic(boolean static_) { - boolean old = this.static_; - this.static_ = static_; - this.firePropertyChanged(STATIC_PROPERTY, old, static_); - } - - private boolean buildStatic(ITypeBinding binding) { - return (binding == null) ? false : Modifier.isStatic(binding.getModifiers()); - } - - // ***** member type - public boolean isMemberType() { - return this.memberType; - } - - private void syncMemberType(boolean memberType) { - boolean old = this.memberType; - this.memberType = memberType; - this.firePropertyChanged(MEMBER_TYPE_PROPERTY, old, memberType); - } - - private boolean buildMemberType(ITypeBinding binding) { - return (binding == null) ? false : binding.isMember(); - } - - // ***** no-arg constructor - public boolean hasNoArgConstructor() { - return this.hasNoArgConstructor; - } - - private void syncHasNoArgConstructor(boolean hasNoArgConstructor) { - boolean old = this.hasNoArgConstructor; - this.hasNoArgConstructor = hasNoArgConstructor; - this.firePropertyChanged(NO_ARG_CONSTRUCTOR_PROPERTY, old, hasNoArgConstructor); - } - - private boolean buildHasNoArgConstructor(ITypeBinding binding) { - return (binding == null) ? false : typeHasNoArgConstructor(binding); - } - - protected static boolean typeHasNoArgConstructor(ITypeBinding binding) { - return findNoArgConstructor(binding) != null; - } - - protected static IMethodBinding findNoArgConstructor(ITypeBinding binding) { - for (IMethodBinding method : binding.getDeclaredMethods()) { - if (method.isConstructor()) { - if (method.getParameterTypes().length == 0) { - return method; - } - } - } - return null; - } - - // ***** private no-arg constructor - public boolean hasPrivateNoArgConstructor() { - return this.hasPrivateNoArgConstructor; - } - - private void syncHasPrivateNoArgConstructor(boolean hasPrivateNoArgConstructor) { - boolean old = this.hasPrivateNoArgConstructor; - this.hasPrivateNoArgConstructor = hasPrivateNoArgConstructor; - this.firePropertyChanged(PRIVATE_NO_ARG_CONSTRUCTOR_PROPERTY, old, hasPrivateNoArgConstructor); - } - - private boolean buildHasPrivateNoArgConstructor(ITypeBinding binding) { - return (binding == null) ? false : typeHasPrivateNoArgConstructor(binding); - } - - protected static boolean typeHasPrivateNoArgConstructor(ITypeBinding binding) { - IMethodBinding method = findNoArgConstructor(binding); - return method != null && Modifier.isPrivate(method.getModifiers()); - } - - // ***** access - public AccessType getAccess() { - return this.access; - } - - // TODO - //seems we could have a public changeAccess() api which would - //move all annotations from fields to their corresponding methods or vice versa - //though of course it's more complicated than that since what if the - //corresponding field/method does not exist? - //making this internal since it should only be set based on changes in the source, the - //context model should not need to set this - private void syncAccess(AccessType astAccess) { - AccessType old = this.access; - this.access = astAccess; - this.firePropertyChanged(ACCESS_PROPERTY, old, astAccess); - } - - private AccessType buildAccess() { - return JPTTools.buildAccess(this); - } - - public boolean isMapped() { - for (Annotation each : this.getAnnotations()) { - if (this.annotationIsMappingAnnotation(each)) { - return true; - } - } - return false; - } - - private boolean annotationIsMappingAnnotation(Annotation annotation) { - return CollectionTools.contains(this.mappingAnnotationNames(), annotation.getAnnotationName()); - } - - private Iterator<String> mappingAnnotationNames() { - return this.getAnnotationProvider().typeMappingAnnotationNames(); - } - - /** - * check only persistable attributes - */ - public boolean hasAnyAnnotatedAttributes() { - for (Iterator<JavaResourcePersistentAttribute> stream = this.persistableAttributes(); stream.hasNext(); ) { - if (stream.next().isAnnotated()) { - return true; - } - } - return false; - } - - - // ********** types ********** - - public Iterator<JavaResourcePersistentType> types() { - return this.getTypes().iterator(); - } - - private Iterable<JavaResourcePersistentType> getTypes() { - return new LiveCloneIterable<JavaResourcePersistentType>(this.types); // read-only - } - - public Iterator<JavaResourcePersistentType> allTypes() { - return new TreeIterator<JavaResourcePersistentType>(this) { - @Override - protected Iterator<? extends JavaResourcePersistentType> children(JavaResourcePersistentType type) { - return type.types(); - } - }; - } - - public Iterator<JavaResourcePersistentType> persistableTypes() { - return this.persistableMembers(this.types()); - } - - private JavaResourcePersistentType getType(String typeName, int occurrence) { - for (JavaResourcePersistentType type : this.getTypes()) { - if (type.isFor(typeName, occurrence)) { - return type; - } - } - return null; - } - - private void addType(JavaResourcePersistentType type) { - this.addItemToCollection(type, this.types, TYPES_COLLECTION); - } - - private void removeTypes(Collection<JavaResourcePersistentType> remove) { - this.removeItemsFromCollection(remove, this.types, TYPES_COLLECTION); - } - - private void initializeTypes(CompilationUnit astRoot) { - TypeDeclaration[] typeDeclarations = this.annotatedElement.getTypes(astRoot); - CounterMap counters = new CounterMap(typeDeclarations.length); - for (TypeDeclaration td : typeDeclarations) { - String tdName = td.getName().getFullyQualifiedName(); - int occurrence = counters.increment(tdName); - this.types.add(this.buildType(td, occurrence, astRoot)); - } - } - - private void syncTypes(CompilationUnit astRoot) { - TypeDeclaration[] typeDeclarations = this.annotatedElement.getTypes(astRoot); - CounterMap counters = new CounterMap(typeDeclarations.length); - HashSet<JavaResourcePersistentType> typesToRemove = new HashSet<JavaResourcePersistentType>(this.types); - for (TypeDeclaration typeDeclaration : typeDeclarations) { - String tdName = typeDeclaration.getName().getFullyQualifiedName(); - int occurrence = counters.increment(tdName); - - JavaResourcePersistentType type = this.getType(tdName, occurrence); - if (type == null) { - this.addType(this.buildType(typeDeclaration, occurrence, astRoot)); - } else { - typesToRemove.remove(type); - type.synchronizeWith(astRoot); - } - } - this.removeTypes(typesToRemove); - } - - private JavaResourcePersistentType buildType(TypeDeclaration nestedTypeDeclaration, int occurrence, CompilationUnit astRoot) { - return newInstance(this.getJavaResourceCompilationUnit(), this.annotatedElement, nestedTypeDeclaration, occurrence, astRoot); - } - - - // ********** fields ********** - - public Iterator<JavaResourcePersistentAttribute> fields() { - return this.getFields().iterator(); - } - - private Iterable<JavaResourcePersistentAttribute> getFields() { - return new LiveCloneIterable<JavaResourcePersistentAttribute>(this.fields); - } - - public Iterator<JavaResourcePersistentAttribute> persistableFields() { - return this.persistableMembers(this.fields()); - } - - public Iterator<JavaResourcePersistentAttribute> persistableFieldsWithSpecifiedFieldAccess() { - return new FilteringIterator<JavaResourcePersistentAttribute>(this.persistableFields()) { - @Override - protected boolean accept(JavaResourcePersistentAttribute resourceAttribute) { - return resourceAttribute.getSpecifiedAccess() == AccessType.FIELD; - } - }; - } - - private void addField(JavaResourcePersistentAttribute field) { - this.addItemToCollection(field, this.fields, FIELDS_COLLECTION); - } - - private JavaResourcePersistentAttribute getField(String fieldName, int occurrence) { - for (JavaResourcePersistentAttribute field : this.getFields()) { - if (field.isFor(fieldName, occurrence)) { - return field; - } - } - return null; - } - - private void removeFields(Collection<JavaResourcePersistentAttribute> remove) { - this.removeItemsFromCollection(remove, this.fields, FIELDS_COLLECTION); - } - - private void initializeFields(CompilationUnit astRoot) { - FieldDeclaration[] fieldDeclarations = this.annotatedElement.getFields(astRoot); - CounterMap counters = new CounterMap(fieldDeclarations.length); - for (FieldDeclaration fieldDeclaration : fieldDeclarations) { - for (VariableDeclarationFragment fragment : fragments(fieldDeclaration)) { - String fieldName = fragment.getName().getFullyQualifiedName(); - int occurrence = counters.increment(fieldName); - this.fields.add(this.buildField(fieldName, occurrence, astRoot)); - } - } - } - - private void syncFields(CompilationUnit astRoot) { - FieldDeclaration[] fieldDeclarations = this.annotatedElement.getFields(astRoot); - CounterMap counters = new CounterMap(fieldDeclarations.length); - HashSet<JavaResourcePersistentAttribute> fieldsToRemove = new HashSet<JavaResourcePersistentAttribute>(this.fields); - for (FieldDeclaration fieldDeclaration : fieldDeclarations) { - for (VariableDeclarationFragment fragment : fragments(fieldDeclaration)) { - String fieldName = fragment.getName().getFullyQualifiedName(); - int occurrence = counters.increment(fieldName); - - JavaResourcePersistentAttribute field = this.getField(fieldName, occurrence); - if (field == null) { - this.addField(this.buildField(fieldName, occurrence, astRoot)); - } else { - fieldsToRemove.remove(field); - field.synchronizeWith(astRoot); - } - } - } - this.removeFields(fieldsToRemove); - } - - private JavaResourcePersistentAttribute buildField(String fieldName, int occurrence, CompilationUnit astRoot) { - return SourcePersistentAttribute.newInstance(this, this.annotatedElement, fieldName, occurrence, this.getJavaResourceCompilationUnit(), astRoot); - } - - // minimize scope of suppressed warnings - @SuppressWarnings("unchecked") - private static List<VariableDeclarationFragment> fragments(FieldDeclaration fd) { - return fd.fragments(); - } - - - // ********** methods ********** - - public Iterator<JavaResourcePersistentAttribute> methods() { - return this.getMethods().iterator(); - } - - private Iterable<JavaResourcePersistentAttribute> getMethods() { - return new LiveCloneIterable<JavaResourcePersistentAttribute>(this.methods); - } - - public Iterator<JavaResourcePersistentAttribute> persistableProperties() { - return this.persistableMembers(this.methods()); - } - - public Iterator<JavaResourcePersistentAttribute> persistablePropertiesWithSpecifiedPropertyAccess() { - return new FilteringIterator<JavaResourcePersistentAttribute>(this.persistableProperties()) { - @Override - protected boolean accept(JavaResourcePersistentAttribute resourceAttribute) { - return resourceAttribute.getSpecifiedAccess() == AccessType.PROPERTY; - } - }; - } - - private JavaResourcePersistentAttribute getMethod(MethodSignature signature, int occurrence) { - for (JavaResourcePersistentAttribute method : this.getMethods()) { - if (method.isFor(signature, occurrence)) { - return method; - } - } - return null; - } - - private void addMethod(JavaResourcePersistentAttribute method) { - this.addItemToCollection(method, this.methods, METHODS_COLLECTION); - } - - private void removeMethods(Collection<JavaResourcePersistentAttribute> remove) { - this.removeItemsFromCollection(remove, this.methods, METHODS_COLLECTION); - } - - private void initializeMethods(CompilationUnit astRoot) { - MethodDeclaration[] methodDeclarations = this.annotatedElement.getMethods(astRoot); - CounterMap counters = new CounterMap(methodDeclarations.length); - for (MethodDeclaration methodDeclaration : methodDeclarations) { - MethodSignature signature = ASTTools.buildMethodSignature(methodDeclaration); - int occurrence = counters.increment(signature); - this.methods.add(this.buildMethod(signature, occurrence, astRoot)); - } - } - - private void syncMethods(CompilationUnit astRoot) { - MethodDeclaration[] methodDeclarations = this.annotatedElement.getMethods(astRoot); - CounterMap counters = new CounterMap(methodDeclarations.length); - HashSet<JavaResourcePersistentAttribute> methodsToRemove = new HashSet<JavaResourcePersistentAttribute>(this.methods); - for (MethodDeclaration methodDeclaration : methodDeclarations) { - MethodSignature signature = ASTTools.buildMethodSignature(methodDeclaration); - int occurrence = counters.increment(signature); - - JavaResourcePersistentAttribute method = this.getMethod(signature, occurrence); - if (method == null) { - this.addMethod(this.buildMethod(signature, occurrence, astRoot)); - } else { - methodsToRemove.remove(method); - method.synchronizeWith(astRoot); - } - } - this.removeMethods(methodsToRemove); - } - - private JavaResourcePersistentAttribute buildMethod(MethodSignature signature, int occurrence, CompilationUnit astRoot) { - return SourcePersistentAttribute.newInstance(this, this.annotatedElement, signature, occurrence, this.getJavaResourceCompilationUnit(), astRoot); - } - - - // ********** attributes ********** - - @SuppressWarnings("unchecked") - public Iterator<JavaResourcePersistentAttribute> persistableAttributes() { - return new CompositeIterator<JavaResourcePersistentAttribute>( - this.persistableFields(), - this.persistableProperties() - ); - } - - public Iterator<JavaResourcePersistentAttribute> persistableAttributes(AccessType specifiedAccess) { - if (specifiedAccess == null) { - throw new IllegalArgumentException("specified access is null"); //$NON-NLS-1$ - } - return (specifiedAccess == AccessType.FIELD) ? - this.persistableAttributesForFieldAccessType() : - this.persistableAttributesForPropertyAccessType(); - } - - @SuppressWarnings("unchecked") - private Iterator<JavaResourcePersistentAttribute> persistableAttributesForFieldAccessType() { - return new CompositeIterator<JavaResourcePersistentAttribute>( - this.persistableFields(), - this.persistablePropertiesWithSpecifiedPropertyAccess() - ); - } - - @SuppressWarnings("unchecked") - private Iterator<JavaResourcePersistentAttribute> persistableAttributesForPropertyAccessType() { - return new CompositeIterator<JavaResourcePersistentAttribute>( - this.persistableProperties(), - this.persistableFieldsWithSpecifiedFieldAccess() - ); - } - - - // ********** metamodel ********** - - public GeneratedAnnotation getGeneratedAnnotation() { - return this.generatedAnnotation; - } - - private void setGeneratedAnnotation(GeneratedAnnotation generatedAnnotation) { - GeneratedAnnotation old = this.generatedAnnotation; - this.generatedAnnotation = generatedAnnotation; - firePropertyChanged(GENERATED_ANNOTATION_PROPERTY, old, this.generatedAnnotation); - } - - private void setStaticMetamodelAnnotation(StaticMetamodelAnnotation staticMetamodelAnnotation) { - StaticMetamodelAnnotation old = this.staticMetamodelAnnotation; - this.staticMetamodelAnnotation = staticMetamodelAnnotation; - firePropertyChanged(STATIC_METAMODEL_ANNOTATION_PROPERTY, old, this.staticMetamodelAnnotation); - } - - /** - * The type must be:<ul> - * <li>in the specified source folder - * <li>a top-level type - * <li>annotated with <code>@javax.annotation.Generated</code> with - * the appropriate <code>value</code> and <code>date</code> - * <li>either itself or one of its nested types annotated with - * <code>@javax.persistence.metamodel.StaticMetamodel</code> - * </ul> - */ - public boolean isGeneratedMetamodelTopLevelType(IPackageFragmentRoot sourceFolder) { - if ( ! this.getSourceFolder().equals(sourceFolder)) { - return false; - } - return this.isGeneratedMetamodelTopLevelType(); - } - - /** - * The type must be:<ul> - * <li>a top-level type - * <li>annotated with <code>@javax.annotation.Generated</code> with - * the appropriate <code>value</code> and <code>date</code> - * <li>either itself or one of its nested types annotated with - * <code>@javax.persistence.metamodel.StaticMetamodel</code> - * </ul> - */ - public boolean isGeneratedMetamodelTopLevelType() { - if ( ! this.isGenerated()) { - return false; - } - // if we get here we know we have a top-level type, since only top-level - // types are annotated @Generated; now see if anything is a metamodel - for (Iterator<JavaResourcePersistentType> stream = this.allTypes(); stream.hasNext(); ) { - JavaResourcePersistentType2_0 type = (JavaResourcePersistentType2_0) stream.next(); - if (type.isMetamodel()) { - return true; - } - } - return false; - } - - /** - * The type must be annotated with - * <code>@javax.annotation.Generated</code> with the appropriate - * <code>value</code> and <code>date</code>. - */ - protected boolean isGenerated() { - if (this.generatedAnnotation == null) { - return false; - } - if (this.generatedAnnotation.valuesSize() != 1) { - return false; - } - if ( ! this.generatedAnnotation.getValue(0).equals(METAMODEL_GENERATED_ANNOTATION_VALUE)) { - return false; - } - if (StringTools.stringIsEmpty(this.generatedAnnotation.getDate())) { - return false; - } - return true; - } - - /** - * The type must be annotated with - * <code>@javax.persistence.metamodel.StaticMetamodel</code>. - */ - public boolean isMetamodel() { - return this.staticMetamodelAnnotation != null; - } - - private IPackageFragmentRoot getSourceFolder() { - return (IPackageFragmentRoot) this.getJavaResourceCompilationUnit().getCompilationUnit().getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT); - } - - - // ********** CounterMap ********** - - private static class CounterMap { - private final HashMap<Object, IntReference> counters; - - protected CounterMap(int initialCapacity) { - super(); - this.counters = new HashMap<Object, IntReference>(initialCapacity); - } - - /** - * Return the incremented count for the specified object. - */ - int increment(Object o) { - IntReference counter = this.counters.get(o); - if (counter == null) { - counter = new IntReference(); - this.counters.put(o, counter); - } - counter.increment(); - return counter.getValue(); - } - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePrimaryKeyJoinColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePrimaryKeyJoinColumnAnnotation.java deleted file mode 100644 index 592ed040af..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePrimaryKeyJoinColumnAnnotation.java +++ /dev/null @@ -1,164 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.ElementAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ElementIndexedAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.resource.java.NestablePrimaryKeyJoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.PrimaryKeyJoinColumnAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.PrimaryKeyJoinColumn - */ -public final class SourcePrimaryKeyJoinColumnAnnotation - extends SourceNamedColumnAnnotation - implements NestablePrimaryKeyJoinColumnAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final DeclarationAnnotationElementAdapter<String> referencedColumnNameDeclarationAdapter; - private final AnnotationElementAdapter<String> referencedColumnNameAdapter; - private String referencedColumnName; - - - public SourcePrimaryKeyJoinColumnAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { - super(parent, member, daa, annotationAdapter); - this.referencedColumnNameDeclarationAdapter = this.buildStringElementAdapter(JPA.PRIMARY_KEY_JOIN_COLUMN__REFERENCED_COLUMN_NAME); - this.referencedColumnNameAdapter = this.buildShortCircuitElementAdapter(this.referencedColumnNameDeclarationAdapter); - } - - public SourcePrimaryKeyJoinColumnAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa) { - this(parent, member, daa, new ElementAnnotationAdapter(member, daa)); - } - - public SourcePrimaryKeyJoinColumnAnnotation(JavaResourceNode parent, Member member, IndexedDeclarationAnnotationAdapter idaa) { - this(parent, member, idaa, new ElementIndexedAnnotationAdapter(member, idaa)); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.referencedColumnName = this.buildReferencedColumnName(astRoot); - } - - @Override - public void synchronizeWith(CompilationUnit astRoot) { - super.synchronizeWith(astRoot); - this.syncReferencedColumnName(this.buildReferencedColumnName(astRoot)); - } - - - // ********** JavaSourceNamedColumnAnnotation implementation ********** - - @Override - protected String getNameElementName() { - return JPA.PRIMARY_KEY_JOIN_COLUMN__NAME; - } - - @Override - protected String getColumnDefinitionElementName() { - return JPA.PRIMARY_KEY_JOIN_COLUMN__COLUMN_DEFINITION; - } - - - // ********** PrimaryKeyJoinColumn implementation ********** - - // ***** referenced column name - public String getReferencedColumnName() { - return this.referencedColumnName; - } - - public void setReferencedColumnName(String referencedColumnName) { - if (this.attributeValueHasChanged(this.referencedColumnName, referencedColumnName)) { - this.referencedColumnName = referencedColumnName; - this.referencedColumnNameAdapter.setValue(referencedColumnName); - } - } - - private void syncReferencedColumnName(String astReferencedColumnName) { - String old = this.referencedColumnName; - this.referencedColumnName = astReferencedColumnName; - this.firePropertyChanged(REFERENCED_COLUMN_NAME_PROPERTY, old, astReferencedColumnName); - } - - private String buildReferencedColumnName(CompilationUnit astRoot) { - return this.referencedColumnNameAdapter.getValue(astRoot); - } - - public TextRange getReferencedColumnNameTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.referencedColumnNameDeclarationAdapter, astRoot); - } - - public boolean referencedColumnNameTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(this.referencedColumnNameDeclarationAdapter, pos, astRoot); - } - - - // ********** NestableAnnotation implementation ********** - - @Override - public void initializeFrom(NestableAnnotation oldAnnotation) { - super.initializeFrom(oldAnnotation); - PrimaryKeyJoinColumnAnnotation oldJoinColumn = (PrimaryKeyJoinColumnAnnotation) oldAnnotation; - this.setReferencedColumnName(oldJoinColumn.getReferencedColumnName()); - } - - public void moveAnnotation(int newIndex) { - this.getIndexedAnnotationAdapter().moveAnnotation(newIndex); - } - - protected IndexedAnnotationAdapter getIndexedAnnotationAdapter() { - return (IndexedAnnotationAdapter) this.annotationAdapter; - } - - - // ********** static methods ********** - - public static SourcePrimaryKeyJoinColumnAnnotation createPrimaryKeyJoinColumn(JavaResourceNode parent, Member member) { - return new SourcePrimaryKeyJoinColumnAnnotation(parent, member, DECLARATION_ANNOTATION_ADAPTER); - } - - static SourcePrimaryKeyJoinColumnAnnotation createNestedPrimaryKeyJoinColumn(JavaResourceNode parent, Member member, int index, DeclarationAnnotationAdapter pkJoinColumnsAdapter) { - IndexedDeclarationAnnotationAdapter idaa = buildNestedDeclarationAnnotationAdapter(index, pkJoinColumnsAdapter); - IndexedAnnotationAdapter annotationAdapter = new ElementIndexedAnnotationAdapter(member, idaa); - return new SourcePrimaryKeyJoinColumnAnnotation(parent, member, idaa, annotationAdapter); - } - - private static IndexedDeclarationAnnotationAdapter buildNestedDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter pkJoinColumnsAdapter) { - return new NestedIndexedDeclarationAnnotationAdapter(pkJoinColumnsAdapter, index, JPA.PRIMARY_KEY_JOIN_COLUMN); - } - - static NestablePrimaryKeyJoinColumnAnnotation createSecondaryTablePrimaryKeyJoinColumn(DeclarationAnnotationAdapter secondaryTableAdapter, JavaResourceNode parent, Member member, int index) { - return new SourcePrimaryKeyJoinColumnAnnotation(parent, member, buildSecondaryTableAnnotationAdapter(secondaryTableAdapter, index)); - } - - private static IndexedDeclarationAnnotationAdapter buildSecondaryTableAnnotationAdapter(DeclarationAnnotationAdapter secondaryTableAdapter, int index) { - return new NestedIndexedDeclarationAnnotationAdapter(secondaryTableAdapter, JPA.SECONDARY_TABLE__PK_JOIN_COLUMNS, index, JPA.PRIMARY_KEY_JOIN_COLUMN); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePrimaryKeyJoinColumnsAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePrimaryKeyJoinColumnsAnnotation.java deleted file mode 100644 index d98f7ffec0..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePrimaryKeyJoinColumnsAnnotation.java +++ /dev/null @@ -1,112 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import java.util.Vector; - -import org.eclipse.jdt.core.dom.Annotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestablePrimaryKeyJoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.PrimaryKeyJoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.PrimaryKeyJoinColumnsAnnotation; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable; - -/** - * javax.persistence.PrimaryKeyJoinColumns - */ -public final class SourcePrimaryKeyJoinColumnsAnnotation - extends SourceAnnotation<Member> - implements PrimaryKeyJoinColumnsAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final Vector<NestablePrimaryKeyJoinColumnAnnotation> pkJoinColumns = new Vector<NestablePrimaryKeyJoinColumnAnnotation>(); - - - public SourcePrimaryKeyJoinColumnsAnnotation(JavaResourceNode parent, Member member) { - super(parent, member, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - AnnotationContainerTools.initialize(this, astRoot); - } - - public void synchronizeWith(CompilationUnit astRoot) { - AnnotationContainerTools.synchronize(this, astRoot); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.pkJoinColumns); - } - - - // ********** AnnotationContainer Implementation ********** - - public String getElementName() { - return JPA.PRIMARY_KEY_JOIN_COLUMNS__VALUE; - } - - public String getNestedAnnotationName() { - return PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME; - } - - public Iterable<NestablePrimaryKeyJoinColumnAnnotation> getNestedAnnotations() { - return new LiveCloneIterable<NestablePrimaryKeyJoinColumnAnnotation>(this.pkJoinColumns); - } - - public int getNestedAnnotationsSize() { - return this.pkJoinColumns.size(); - } - - public NestablePrimaryKeyJoinColumnAnnotation addNestedAnnotation() { - return this.addNestedAnnotation(this.pkJoinColumns.size()); - } - - private NestablePrimaryKeyJoinColumnAnnotation addNestedAnnotation(int index) { - NestablePrimaryKeyJoinColumnAnnotation pkJoinColumn = this.buildPrimaryKeyJoinColumn(index); - this.pkJoinColumns.add(pkJoinColumn); - return pkJoinColumn; - } - - public void syncAddNestedAnnotation(Annotation astAnnotation) { - int index = this.pkJoinColumns.size(); - NestablePrimaryKeyJoinColumnAnnotation pkJoinColumn = this.addNestedAnnotation(index); - pkJoinColumn.initialize((CompilationUnit) astAnnotation.getRoot()); - this.fireItemAdded(PK_JOIN_COLUMNS_LIST, index, pkJoinColumn); - } - - private NestablePrimaryKeyJoinColumnAnnotation buildPrimaryKeyJoinColumn(int index) { - return SourcePrimaryKeyJoinColumnAnnotation.createNestedPrimaryKeyJoinColumn(this, this.annotatedElement, index, this.daa); - } - - public NestablePrimaryKeyJoinColumnAnnotation moveNestedAnnotation(int targetIndex, int sourceIndex) { - return CollectionTools.move(this.pkJoinColumns, targetIndex, sourceIndex).get(targetIndex); - } - - public NestablePrimaryKeyJoinColumnAnnotation removeNestedAnnotation(int index) { - return this.pkJoinColumns.remove(index); - } - - public void syncRemoveNestedAnnotations(int index) { - this.removeItemsFromList(index, this.pkJoinColumns, PK_JOIN_COLUMNS_LIST); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceQueryHintAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceQueryHintAnnotation.java deleted file mode 100644 index 4bc6fcd8b8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceQueryHintAnnotation.java +++ /dev/null @@ -1,176 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.AnnotatedElementAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ElementIndexedAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.resource.java.NestableQueryHintAnnotation; -import org.eclipse.jpt.core.resource.java.QueryHintAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.QueryHint - */ -public final class SourceQueryHintAnnotation - extends SourceAnnotation<Type> - implements NestableQueryHintAnnotation -{ - private final DeclarationAnnotationElementAdapter<String> nameDeclarationAdapter; - private final AnnotationElementAdapter<String> nameAdapter; - private String name; - - private final DeclarationAnnotationElementAdapter<String> valueDeclarationAdapter; - private final AnnotationElementAdapter<String> valueAdapter; - private String value; - - - public SourceQueryHintAnnotation(JavaResourceNode parent, Type type, IndexedDeclarationAnnotationAdapter idaa) { - super(parent, type, idaa, new ElementIndexedAnnotationAdapter(type, idaa)); - this.nameDeclarationAdapter = this.buildNameAdapter(idaa); - this.nameAdapter = this.buildAdapter(this.nameDeclarationAdapter); - this.valueDeclarationAdapter = this.buildValueAdapter(idaa); - this.valueAdapter = this.buildAdapter(this.valueDeclarationAdapter); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - private AnnotationElementAdapter<String> buildAdapter(DeclarationAnnotationElementAdapter<String> daea) { - return new AnnotatedElementAnnotationElementAdapter<String>(this.annotatedElement, daea); - } - - private DeclarationAnnotationElementAdapter<String> buildNameAdapter(DeclarationAnnotationAdapter adapter) { - return ConversionDeclarationAnnotationElementAdapter.forStrings(adapter, JPA.QUERY_HINT__NAME); - } - - private DeclarationAnnotationElementAdapter<String> buildValueAdapter(DeclarationAnnotationAdapter adapter) { - return ConversionDeclarationAnnotationElementAdapter.forStrings(adapter, JPA.QUERY_HINT__VALUE); - } - - public void initialize(CompilationUnit astRoot) { - this.name = this.buildName(astRoot); - this.value = this.buildValue(astRoot); - } - - public void synchronizeWith(CompilationUnit astRoot) { - this.syncName(this.buildName(astRoot)); - this.syncValue(this.buildValue(astRoot)); - } - - public IndexedAnnotationAdapter getIndexedAnnotationAdapter() { - return (IndexedAnnotationAdapter) this.annotationAdapter; - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - // ********** QueryHintAnnotation implementation ********** - - // ***** name - public String getName() { - return this.name; - } - - public void setName(String name) { - if (this.attributeValueHasChanged(this.name, name)) { - this.name = name; - this.nameAdapter.setValue(name); - } - } - - private void syncName(String astName) { - String old = this.name; - this.name = astName; - this.firePropertyChanged(NAME_PROPERTY, old, astName); - } - - private String buildName(CompilationUnit astRoot) { - return this.nameAdapter.getValue(astRoot); - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.nameDeclarationAdapter, astRoot); - } - - // ***** value - public String getValue() { - return this.value; - } - - public void setValue(String value) { - if (this.attributeValueHasChanged(this.value, value)) { - this.value = value; - this.valueAdapter.setValue(value); - } - } - - private void syncValue(String astValue) { - String old = this.value; - this.value = astValue; - this.firePropertyChanged(VALUE_PROPERTY, old, astValue); - } - - private String buildValue(CompilationUnit astRoot) { - return this.valueAdapter.getValue(astRoot); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.valueDeclarationAdapter, astRoot); - } - - - // ********** NestableAnnotation implementation ********** - - public void initializeFrom(NestableAnnotation oldAnnotation) { - QueryHintAnnotation oldHint = (QueryHintAnnotation) oldAnnotation; - this.setName(oldHint.getName()); - this.setValue(oldHint.getValue()); - } - - public void moveAnnotation(int newIndex) { - this.getIndexedAnnotationAdapter().moveAnnotation(newIndex); - } - - - // ********** static methods ********** - - static SourceQueryHintAnnotation createNamedQueryQueryHint(JavaResourceNode parent, Type type, DeclarationAnnotationAdapter namedQueryAdapter, int index) { - return new SourceQueryHintAnnotation(parent, type, buildNamedQueryQueryHintAnnotationAdapter(namedQueryAdapter, index)); - } - - private static IndexedDeclarationAnnotationAdapter buildNamedQueryQueryHintAnnotationAdapter(DeclarationAnnotationAdapter namedQueryAdapter, int index) { - return new NestedIndexedDeclarationAnnotationAdapter(namedQueryAdapter, JPA.NAMED_QUERY__HINTS, index, JPA.QUERY_HINT); - } - - static SourceQueryHintAnnotation createNamedNativeQueryQueryHint(JavaResourceNode parent, Type type, DeclarationAnnotationAdapter namedNativeQueryAdapter, int index) { - return new SourceQueryHintAnnotation(parent, type, buildNamedNativeQueryQueryHintAnnotationAdapter(namedNativeQueryAdapter, index)); - } - - private static IndexedDeclarationAnnotationAdapter buildNamedNativeQueryQueryHintAnnotationAdapter(DeclarationAnnotationAdapter namedNativeQueryAdapter, int index) { - return new NestedIndexedDeclarationAnnotationAdapter(namedNativeQueryAdapter, JPA.NAMED_NATIVE_QUERY__HINTS, index, JPA.QUERY_HINT); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceRelationshipMappingAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceRelationshipMappingAnnotation.java deleted file mode 100644 index 099b5e5e60..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceRelationshipMappingAnnotation.java +++ /dev/null @@ -1,336 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.EnumArrayDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ASTTools; -import org.eclipse.jpt.core.internal.utility.jdt.AnnotatedElementAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleTypeStringExpressionConverter; -import org.eclipse.jpt.core.jpa2.resource.java.RelationshipMapping2_0Annotation; -import org.eclipse.jpt.core.resource.java.CascadeType; -import org.eclipse.jpt.core.resource.java.FetchType; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.ExpressionConverter; -import org.eclipse.jpt.utility.internal.ArrayTools; - -/** - * javax.persistence.ManyToMany - * javax.persistence.ManyToOne - * javax.persistence.OneToMany - * javax.persistence.OneToOne - */ -abstract class SourceRelationshipMappingAnnotation - extends SourceAnnotation<Attribute> - implements RelationshipMapping2_0Annotation -{ - final DeclarationAnnotationElementAdapter<String> targetEntityDeclarationAdapter; - final AnnotationElementAdapter<String> targetEntityAdapter; - String targetEntity; - - String fullyQualifiedTargetEntityClassName; - - final DeclarationAnnotationElementAdapter<String> fetchDeclarationAdapter; - final AnnotationElementAdapter<String> fetchAdapter; - FetchType fetch; - - final DeclarationAnnotationElementAdapter<String[]> cascadeDeclarationAdapter; - final AnnotationElementAdapter<String[]> cascadeAdapter; - CascadeType[] cascadeTypes = EMPTY_CASCADE_TYPE_ARRAY; // this should never be null - private static final CascadeType[] EMPTY_CASCADE_TYPE_ARRAY = new CascadeType[0]; - - - SourceRelationshipMappingAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute, DeclarationAnnotationAdapter daa) { - super(parent, attribute, daa); - this.targetEntityDeclarationAdapter = this.getTargetEntityAdapter(); - this.targetEntityAdapter = this.buildAnnotationElementAdapter(this.targetEntityDeclarationAdapter); - this.fetchDeclarationAdapter = this.getFetchAdapter(); - this.fetchAdapter = this.buildAnnotationElementAdapter(this.fetchDeclarationAdapter); - this.cascadeDeclarationAdapter = this.getCascadeAdapter(); - this.cascadeAdapter = new AnnotatedElementAnnotationElementAdapter<String[]>(attribute, this.cascadeDeclarationAdapter); - } - - protected AnnotationElementAdapter<String> buildAnnotationElementAdapter(DeclarationAnnotationElementAdapter<String> daea) { - return new AnnotatedElementAnnotationElementAdapter<String>(this.annotatedElement, daea); - } - - protected AnnotationElementAdapter<Boolean> buildBooleanAnnotationElementAdapter(DeclarationAnnotationElementAdapter<Boolean> daea) { - return new AnnotatedElementAnnotationElementAdapter<Boolean>(this.annotatedElement, daea); - } - - public void initialize(CompilationUnit astRoot) { - this.targetEntity = this.buildTargetEntity(astRoot); - this.fullyQualifiedTargetEntityClassName = this.buildFullyQualifiedTargetEntityClassName(astRoot); - this.fetch = this.buildFetch(astRoot); - this.cascadeTypes = this.buildCascadeTypes(astRoot); - } - - public void synchronizeWith(CompilationUnit astRoot) { - this.syncFetch(this.buildFetch(astRoot)); - this.syncTargetEntity(this.buildTargetEntity(astRoot)); - this.syncFullyQualifiedTargetEntityClassName(this.buildFullyQualifiedTargetEntityClassName(astRoot)); - this.syncCascadeTypes(this.buildCascadeTypes(astRoot)); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.targetEntity); - } - - - // ********** RelationshipMappingAnnotation implementation ********** - - // ***** target entity - public String getTargetEntity() { - return this.targetEntity; - } - - public void setTargetEntity(String targetEntity) { - if (this.attributeValueHasChanged(this.targetEntity, targetEntity)) { - this.targetEntity = targetEntity; - this.targetEntityAdapter.setValue(targetEntity); - } - } - - private void syncTargetEntity(String astTargetEntity) { - String old = this.targetEntity; - this.targetEntity = astTargetEntity; - this.firePropertyChanged(TARGET_ENTITY_PROPERTY, old, astTargetEntity); - } - - private String buildTargetEntity(CompilationUnit astRoot) { - return this.targetEntityAdapter.getValue(astRoot); - } - - public TextRange getTargetEntityTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.targetEntityDeclarationAdapter, astRoot); - } - - /** - * return the Java adapter's 'targetEntity' element adapter config - */ - abstract DeclarationAnnotationElementAdapter<String> getTargetEntityAdapter(); - - // ***** fully-qualified target entity class name - public String getFullyQualifiedTargetEntityClassName() { - return this.fullyQualifiedTargetEntityClassName; - } - - private void syncFullyQualifiedTargetEntityClassName(String name) { - String old = this.fullyQualifiedTargetEntityClassName; - this.fullyQualifiedTargetEntityClassName = name; - this.firePropertyChanged(FULLY_QUALIFIED_TARGET_ENTITY_CLASS_NAME_PROPERTY, old, name); - } - - private String buildFullyQualifiedTargetEntityClassName(CompilationUnit astRoot) { - return (this.targetEntity == null) ? null : ASTTools.resolveFullyQualifiedName(this.targetEntityAdapter.getExpression(astRoot)); - } - - // ***** fetch - public FetchType getFetch() { - return this.fetch; - } - - public void setFetch(FetchType fetch) { - if (this.attributeValueHasChanged(this.fetch, fetch)) { - this.fetch = fetch; - this.fetchAdapter.setValue(FetchType.toJavaAnnotationValue(fetch)); - } - } - - private void syncFetch(FetchType astFetch) { - FetchType old = this.fetch; - this.fetch = astFetch; - this.firePropertyChanged(FETCH_PROPERTY, old, astFetch); - } - - private FetchType buildFetch(CompilationUnit astRoot) { - return FetchType.fromJavaAnnotationValue(this.fetchAdapter.getValue(astRoot)); - } - - public TextRange getFetchTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.fetchDeclarationAdapter, astRoot); - } - - /** - * return the Java adapter's 'fetch' element adapter config - */ - abstract DeclarationAnnotationElementAdapter<String> getFetchAdapter(); - - // ***** cascade types - /** - * pre-condition: state of 'cascadeTypes' is to change - */ - private void setCascadeType(CascadeType cascadeType, boolean set) { - this.setCascadeTypes(set ? - ArrayTools.add(this.cascadeTypes, cascadeType) : - ArrayTools.remove(this.cascadeTypes, cascadeType) - ); - } - - /** - * pre-condition: state of 'cascadeTypes' is to change - */ - private void setCascadeTypes(CascadeType[] cascadeTypes) { - this.cascadeTypes = cascadeTypes; - this.cascadeAdapter.setValue(CascadeType.toJavaAnnotationValues(cascadeTypes)); - } - - private void syncCascadeTypes(CascadeType[] astCascadeTypes) { - CascadeType[] old = this.cascadeTypes; - this.cascadeTypes = astCascadeTypes; - this.syncCascadeAll(old); - this.syncCascadeMerge(old); - this.syncCascadePersist(old); - this.syncCascadeRefresh(old); - this.syncCascadeRemove(old); - this.syncCascadeDetach(old); - } - - private CascadeType[] buildCascadeTypes(CompilationUnit astRoot) { - return CascadeType.fromJavaAnnotationValues(this.cascadeAdapter.getValue(astRoot)); - } - - private boolean cascadeTypeIsTrue(CascadeType cascadeType) { - return ArrayTools.contains(this.cascadeTypes, cascadeType); - } - - public TextRange getCascadeTextRange(CompilationUnit astRoot) { - return getElementTextRange(this.cascadeDeclarationAdapter, astRoot); - } - - /** - * return the Java adapter's 'cascade' element adapter config - */ - abstract DeclarationAnnotationElementAdapter<String[]> getCascadeAdapter(); - - // ***** cascade all - public boolean isCascadeAll() { - return this.cascadeTypeIsTrue(CascadeType.ALL); - } - - public void setCascadeAll(boolean cascadeAll) { - if (this.isCascadeAll() != cascadeAll) { - this.setCascadeType(CascadeType.ALL, cascadeAll); - } - } - - private void syncCascadeAll(CascadeType[] oldCascadeTypes) { - boolean old = ArrayTools.contains(oldCascadeTypes, CascadeType.ALL); - this.firePropertyChanged(CASCADE_ALL_PROPERTY, old, this.isCascadeAll()); - } - - // ***** cascade persist - public boolean isCascadePersist() { - return this.cascadeTypeIsTrue(CascadeType.PERSIST); - } - - public void setCascadePersist(boolean cascadePersist) { - if (this.isCascadePersist() != cascadePersist) { - this.setCascadeType(CascadeType.PERSIST, cascadePersist); - } - } - - private void syncCascadePersist(CascadeType[] oldCascadeTypes) { - boolean old = ArrayTools.contains(oldCascadeTypes, CascadeType.PERSIST); - this.firePropertyChanged(CASCADE_PERSIST_PROPERTY, old, this.isCascadePersist()); - } - - // ***** cascade merge - public boolean isCascadeMerge() { - return this.cascadeTypeIsTrue(CascadeType.MERGE); - } - - public void setCascadeMerge(boolean cascadeMerge) { - if (this.isCascadeMerge() != cascadeMerge) { - this.setCascadeType(CascadeType.MERGE, cascadeMerge); - } - } - - private void syncCascadeMerge(CascadeType[] oldCascadeTypes) { - boolean old = ArrayTools.contains(oldCascadeTypes, CascadeType.MERGE); - this.firePropertyChanged(CASCADE_MERGE_PROPERTY, old, this.isCascadeMerge()); - } - - // ***** cascade remove - public boolean isCascadeRemove() { - return this.cascadeTypeIsTrue(CascadeType.REMOVE); - } - - public void setCascadeRemove(boolean cascadeRemove) { - if (this.isCascadeRemove() != cascadeRemove) { - this.setCascadeType(CascadeType.REMOVE, cascadeRemove); - } - } - - private void syncCascadeRemove(CascadeType[] oldCascadeTypes) { - boolean old = ArrayTools.contains(oldCascadeTypes, CascadeType.REMOVE); - this.firePropertyChanged(CASCADE_REMOVE_PROPERTY, old, this.isCascadeRemove()); - } - - // ***** cascade refresh - public boolean isCascadeRefresh() { - return this.cascadeTypeIsTrue(CascadeType.REFRESH); - } - - public void setCascadeRefresh(boolean cascadeRefresh) { - if (this.isCascadeRefresh() != cascadeRefresh) { - this.setCascadeType(CascadeType.REFRESH, cascadeRefresh); - } - } - - private void syncCascadeRefresh(CascadeType[] oldCascadeTypes) { - boolean old = ArrayTools.contains(oldCascadeTypes, CascadeType.REFRESH); - this.firePropertyChanged(CASCADE_REFRESH_PROPERTY, old, this.isCascadeRefresh()); - } - - // ***** cascade detach - JPA 2.0 - public boolean isCascadeDetach() { - return this.cascadeTypeIsTrue(CascadeType.DETACH); - } - - public void setCascadeDetach(boolean cascadeDetach) { - if (this.isCascadeDetach() != cascadeDetach) { - this.setCascadeType(CascadeType.DETACH, cascadeDetach); - } - } - - private void syncCascadeDetach(CascadeType[] oldCascadeTypes) { - boolean old = ArrayTools.contains(oldCascadeTypes, CascadeType.DETACH); - this.firePropertyChanged(CASCADE_DETACH_PROPERTY, old, this.isCascadeDetach()); - } - - // ********** static methods ********** - - static DeclarationAnnotationElementAdapter<String> buildTargetEntityAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { - // TODO what about QualifiedType? - return buildAnnotationElementAdapter(annotationAdapter, elementName, SimpleTypeStringExpressionConverter.instance()); - } - - static DeclarationAnnotationElementAdapter<String> buildAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, ExpressionConverter<String> converter) { - return new ConversionDeclarationAnnotationElementAdapter<String>(annotationAdapter, elementName, false, converter); - } - - static DeclarationAnnotationElementAdapter<String> buildFetchAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { - return new EnumDeclarationAnnotationElementAdapter(annotationAdapter, elementName, false); - } - - static DeclarationAnnotationElementAdapter<String[]> buildEnumArrayAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { - return new EnumArrayDeclarationAnnotationElementAdapter(annotationAdapter, elementName, false); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceSecondaryTableAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceSecondaryTableAnnotation.java deleted file mode 100644 index 8ffda243dc..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceSecondaryTableAnnotation.java +++ /dev/null @@ -1,265 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.dom.Annotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ElementAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ElementIndexedAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.AnnotationContainer; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.resource.java.NestablePrimaryKeyJoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.NestableSecondaryTableAnnotation; -import org.eclipse.jpt.core.resource.java.PrimaryKeyJoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.SecondaryTableAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.StringTools; -import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.SecondaryTable - */ -public final class SourceSecondaryTableAnnotation - extends SourceBaseTableAnnotation - implements NestableSecondaryTableAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(SecondaryTableAnnotation.ANNOTATION_NAME); - - private final Vector<NestablePrimaryKeyJoinColumnAnnotation> pkJoinColumns = new Vector<NestablePrimaryKeyJoinColumnAnnotation>(); - private final PkJoinColumnsAnnotationContainer pkJoinColumnsContainer = new PkJoinColumnsAnnotationContainer(); - - - public SourceSecondaryTableAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { - super(parent, member, daa, annotationAdapter); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - AnnotationContainerTools.initialize(this.pkJoinColumnsContainer, astRoot); - } - - @Override - public void synchronizeWith(CompilationUnit astRoot) { - super.synchronizeWith(astRoot); - AnnotationContainerTools.synchronize(this.pkJoinColumnsContainer, astRoot); - } - - - // ********** SourceBaseTableAnnotation implementation ********** - - @Override - protected DeclarationAnnotationElementAdapter<String> getNameAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { - return ConversionDeclarationAnnotationElementAdapter.forStrings(declarationAnnotationAdapter, JPA.SECONDARY_TABLE__NAME); - } - - @Override - protected DeclarationAnnotationElementAdapter<String> getSchemaAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { - return ConversionDeclarationAnnotationElementAdapter.forStrings(declarationAnnotationAdapter, JPA.SECONDARY_TABLE__SCHEMA); - } - - @Override - protected DeclarationAnnotationElementAdapter<String> getCatalogAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { - return ConversionDeclarationAnnotationElementAdapter.forStrings(declarationAnnotationAdapter, JPA.SECONDARY_TABLE__CATALOG); - } - - @Override - protected String getUniqueConstraintsElementName() { - return JPA.SECONDARY_TABLE__UNIQUE_CONSTRAINTS; - } - - - // ************* SecondaryTableAnnotation implementation ******************* - - // ***** pk join columns - public ListIterator<PrimaryKeyJoinColumnAnnotation> pkJoinColumns() { - return new CloneListIterator<PrimaryKeyJoinColumnAnnotation>(this.pkJoinColumns); - } - - Iterable<NestablePrimaryKeyJoinColumnAnnotation> getNestablePkJoinColumns() { - return new LiveCloneIterable<NestablePrimaryKeyJoinColumnAnnotation>(this.pkJoinColumns); - } - - public int pkJoinColumnsSize() { - return this.pkJoinColumns.size(); - } - - public NestablePrimaryKeyJoinColumnAnnotation pkJoinColumnAt(int index) { - return this.pkJoinColumns.get(index); - } - - public int indexOfPkJoinColumn(PrimaryKeyJoinColumnAnnotation joinColumn) { - return this.pkJoinColumns.indexOf(joinColumn); - } - - public NestablePrimaryKeyJoinColumnAnnotation addPkJoinColumn(int index) { - return (NestablePrimaryKeyJoinColumnAnnotation) AnnotationContainerTools.addNestedAnnotation(index, this.pkJoinColumnsContainer); - } - - NestablePrimaryKeyJoinColumnAnnotation addPkJoinColumn_() { - return this.addPkJoinColumn_(this.pkJoinColumns.size()); - } - - private NestablePrimaryKeyJoinColumnAnnotation addPkJoinColumn_(int index) { - NestablePrimaryKeyJoinColumnAnnotation pkJoinColumn = this.buildPrimaryKeyJoinColumn(index); - this.pkJoinColumns.add(pkJoinColumn); - return pkJoinColumn; - } - - void syncAddPkJoinColumn(Annotation astAnnotation) { - int index = this.pkJoinColumns.size(); - NestablePrimaryKeyJoinColumnAnnotation pkJoinColumn = this.addPkJoinColumn_(index); - pkJoinColumn.initialize((CompilationUnit) astAnnotation.getRoot()); - this.fireItemAdded(PK_JOIN_COLUMNS_LIST, index, pkJoinColumn); - } - - private NestablePrimaryKeyJoinColumnAnnotation buildPrimaryKeyJoinColumn(int index) { - return SourcePrimaryKeyJoinColumnAnnotation.createSecondaryTablePrimaryKeyJoinColumn(this.daa, this, this.annotatedElement, index); - } - - void pkJoinColumnAdded(int index, NestablePrimaryKeyJoinColumnAnnotation joinColumn) { - this.fireItemAdded(PK_JOIN_COLUMNS_LIST, index, joinColumn); - } - - public void movePkJoinColumn(int targetIndex, int sourceIndex) { - AnnotationContainerTools.moveNestedAnnotation(targetIndex, sourceIndex, this.pkJoinColumnsContainer); - } - - NestablePrimaryKeyJoinColumnAnnotation movePkJoinColumn_(int targetIndex, int sourceIndex) { - return CollectionTools.move(this.pkJoinColumns, targetIndex, sourceIndex).get(targetIndex); - } - - public void removePkJoinColumn(int index) { - AnnotationContainerTools.removeNestedAnnotation(index, this.pkJoinColumnsContainer); - } - - NestablePrimaryKeyJoinColumnAnnotation removePkJoinColumn_(int index) { - return this.pkJoinColumns.remove(index); - } - - void syncRemovePkJoinColumns(int index) { - this.removeItemsFromList(index, this.pkJoinColumns, PK_JOIN_COLUMNS_LIST); - } - - - // ********** NestableAnnotation implementation ********** - - public void moveAnnotation(int newIndex) { - this.getIndexedAnnotationAdapter().moveAnnotation(newIndex); - } - - protected IndexedAnnotationAdapter getIndexedAnnotationAdapter() { - return (IndexedAnnotationAdapter) this.annotationAdapter; - } - - @Override - public void initializeFrom(NestableAnnotation oldAnnotation) { - super.initializeFrom(oldAnnotation); - SecondaryTableAnnotation oldTable = (SecondaryTableAnnotation) oldAnnotation; - for (PrimaryKeyJoinColumnAnnotation oldPkJoinColumn : CollectionTools.iterable(oldTable.pkJoinColumns())) { - NestablePrimaryKeyJoinColumnAnnotation newPkJoinColumn = this.addPkJoinColumn(oldTable.indexOfPkJoinColumn(oldPkJoinColumn)); - newPkJoinColumn.initializeFrom((NestableAnnotation) oldPkJoinColumn); - } - } - - - // ********** static methods ********** - - public static SourceSecondaryTableAnnotation createSecondaryTable(JavaResourceNode parent, Member member) { - return new SourceSecondaryTableAnnotation(parent, member, DECLARATION_ANNOTATION_ADAPTER, new ElementAnnotationAdapter(member, DECLARATION_ANNOTATION_ADAPTER)); - } - - static SourceSecondaryTableAnnotation createNestedSecondaryTable(JavaResourceNode parent, Member member, int index, DeclarationAnnotationAdapter secondaryTablesAdapter) { - IndexedDeclarationAnnotationAdapter idaa = buildNestedDeclarationAnnotationAdapter(index, secondaryTablesAdapter); - IndexedAnnotationAdapter annotationAdapter = new ElementIndexedAnnotationAdapter(member, idaa); - return new SourceSecondaryTableAnnotation(parent, member, idaa, annotationAdapter); - } - - private static IndexedDeclarationAnnotationAdapter buildNestedDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter secondaryTablesAdapter) { - return new NestedIndexedDeclarationAnnotationAdapter(secondaryTablesAdapter, index, JPA.SECONDARY_TABLE); - } - - - // ********** pk join column container ********** - - /** - * adapt the AnnotationContainer interface to the secondary table's - * primary key join columns - */ - class PkJoinColumnsAnnotationContainer - implements AnnotationContainer<NestablePrimaryKeyJoinColumnAnnotation> - { - public org.eclipse.jdt.core.dom.Annotation getAstAnnotation(CompilationUnit astRoot) { - return SourceSecondaryTableAnnotation.this.getAstAnnotation(astRoot); - } - - public String getElementName() { - return JPA.SECONDARY_TABLE__PK_JOIN_COLUMNS; - } - - public String getNestedAnnotationName() { - return PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME; - } - - public Iterable<NestablePrimaryKeyJoinColumnAnnotation> getNestedAnnotations() { - return SourceSecondaryTableAnnotation.this.getNestablePkJoinColumns(); - } - - public int getNestedAnnotationsSize() { - return SourceSecondaryTableAnnotation.this.pkJoinColumnsSize(); - } - - public NestablePrimaryKeyJoinColumnAnnotation addNestedAnnotation() { - return SourceSecondaryTableAnnotation.this.addPkJoinColumn_(); - } - - public void syncAddNestedAnnotation(Annotation astAnnotation) { - SourceSecondaryTableAnnotation.this.syncAddPkJoinColumn(astAnnotation); - } - - public NestablePrimaryKeyJoinColumnAnnotation moveNestedAnnotation(int targetIndex, int sourceIndex) { - return SourceSecondaryTableAnnotation.this.movePkJoinColumn_(targetIndex, sourceIndex); - } - - public NestablePrimaryKeyJoinColumnAnnotation removeNestedAnnotation(int index) { - return SourceSecondaryTableAnnotation.this.removePkJoinColumn_(index); - } - - public void syncRemoveNestedAnnotations(int index) { - SourceSecondaryTableAnnotation.this.syncRemovePkJoinColumns(index); - } - - @Override - public String toString() { - return StringTools.buildToStringFor(this); - } - - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceSecondaryTablesAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceSecondaryTablesAnnotation.java deleted file mode 100644 index 203e3a6cb5..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceSecondaryTablesAnnotation.java +++ /dev/null @@ -1,112 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import java.util.Vector; - -import org.eclipse.jdt.core.dom.Annotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.resource.java.NestableSecondaryTableAnnotation; -import org.eclipse.jpt.core.resource.java.SecondaryTableAnnotation; -import org.eclipse.jpt.core.resource.java.SecondaryTablesAnnotation; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable; - -/** - * javax.persistence.SecondaryTables - */ -public final class SourceSecondaryTablesAnnotation - extends SourceAnnotation<Member> - implements SecondaryTablesAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final Vector<NestableSecondaryTableAnnotation> secondaryTables = new Vector<NestableSecondaryTableAnnotation>(); - - - public SourceSecondaryTablesAnnotation(JavaResourcePersistentType parent, Member member) { - super(parent, member, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - AnnotationContainerTools.initialize(this, astRoot); - } - - public void synchronizeWith(CompilationUnit astRoot) { - AnnotationContainerTools.synchronize(this, astRoot); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.secondaryTables); - } - - - // ********** AnnotationContainer implementation ********** - - public String getElementName() { - return JPA.SECONDARY_TABLES__VALUE; - } - - public String getNestedAnnotationName() { - return SecondaryTableAnnotation.ANNOTATION_NAME; - } - - public Iterable<NestableSecondaryTableAnnotation> getNestedAnnotations() { - return new LiveCloneIterable<NestableSecondaryTableAnnotation>(this.secondaryTables); - } - - public int getNestedAnnotationsSize() { - return this.secondaryTables.size(); - } - - public NestableSecondaryTableAnnotation addNestedAnnotation() { - return this.addNestedAnnotation(this.secondaryTables.size()); - } - - private NestableSecondaryTableAnnotation addNestedAnnotation(int index) { - NestableSecondaryTableAnnotation secondaryTable = this.buildSecondaryTable(index); - this.secondaryTables.add(secondaryTable); - return secondaryTable; - } - - public void syncAddNestedAnnotation(Annotation astAnnotation) { - int index = this.secondaryTables.size(); - NestableSecondaryTableAnnotation secondaryTable = this.addNestedAnnotation(index); - secondaryTable.initialize((CompilationUnit) astAnnotation.getRoot()); - this.fireItemAdded(SECONDARY_TABLES_LIST, index, secondaryTable); - } - - private NestableSecondaryTableAnnotation buildSecondaryTable(int index) { - return SourceSecondaryTableAnnotation.createNestedSecondaryTable(this, this.annotatedElement, index, this.daa); - } - - public NestableSecondaryTableAnnotation moveNestedAnnotation(int targetIndex, int sourceIndex) { - return CollectionTools.move(this.secondaryTables, targetIndex, sourceIndex).get(targetIndex); - } - - public NestableSecondaryTableAnnotation removeNestedAnnotation(int index) { - return this.secondaryTables.remove(index); - } - - public void syncRemoveNestedAnnotations(int index) { - this.removeItemsFromList(index, this.secondaryTables, SECONDARY_TABLES_LIST); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceSequenceGeneratorAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceSequenceGeneratorAnnotation.java deleted file mode 100644 index b1894b7eb9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceSequenceGeneratorAnnotation.java +++ /dev/null @@ -1,126 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.SequenceGeneratorAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.SequenceGenerator - */ -public abstract class SourceSequenceGeneratorAnnotation - extends SourceGeneratorAnnotation - implements SequenceGeneratorAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter<String> NAME_ADAPTER = buildAdapter(JPA.SEQUENCE_GENERATOR__NAME); - - private static final DeclarationAnnotationElementAdapter<Integer> INITIAL_VALUE_ADAPTER = buildIntegerAdapter(JPA.SEQUENCE_GENERATOR__INITIAL_VALUE); - - private static final DeclarationAnnotationElementAdapter<Integer> ALLOCATION_SIZE_ADAPTER = buildIntegerAdapter(JPA.SEQUENCE_GENERATOR__ALLOCATION_SIZE); - - private static final DeclarationAnnotationElementAdapter<String> SEQUENCE_NAME_ADAPTER = buildAdapter(JPA.SEQUENCE_GENERATOR__SEQUENCE_NAME); - private final AnnotationElementAdapter<String> sequenceNameAdapter; - private String sequenceName; - - - protected SourceSequenceGeneratorAnnotation(JavaResourceNode parent, Member member) { - super(parent, member, DECLARATION_ANNOTATION_ADAPTER); - this.sequenceNameAdapter = this.buildAdapter(SEQUENCE_NAME_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.sequenceName = this.buildSequenceName(astRoot); - } - - @Override - public void synchronizeWith(CompilationUnit astRoot) { - super.synchronizeWith(astRoot); - this.syncSequenceName(this.buildSequenceName(astRoot)); - } - - - // ********** AbstractGeneratorAnnotation implementation ********** - - @Override - DeclarationAnnotationElementAdapter<String> getNameAdapter() { - return NAME_ADAPTER; - } - - @Override - DeclarationAnnotationElementAdapter<Integer> getInitialValueAdapter() { - return INITIAL_VALUE_ADAPTER; - } - - @Override - DeclarationAnnotationElementAdapter<Integer> getAllocationSizeAdapter() { - return ALLOCATION_SIZE_ADAPTER; - } - - - // ********** SequenceGeneratorAnnotation implementation ********** - - // ***** sequence name - public String getSequenceName() { - return this.sequenceName; - } - - public void setSequenceName(String sequenceName) { - if (this.attributeValueHasChanged(this.sequenceName, sequenceName)) { - this.sequenceName = sequenceName; - this.sequenceNameAdapter.setValue(sequenceName); - } - } - - public void syncSequenceName(String astSequenceName) { - String old = this.sequenceName; - this.sequenceName = astSequenceName; - this.firePropertyChanged(SEQUENCE_NAME_PROPERTY, old, astSequenceName); - } - - private String buildSequenceName(CompilationUnit astRoot) { - return this.sequenceNameAdapter.getValue(astRoot); - } - - public TextRange getSequenceNameTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(SEQUENCE_NAME_ADAPTER, astRoot); - } - - public boolean sequenceNameTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(SEQUENCE_NAME_ADAPTER, pos, astRoot); - } - - - // ********** static methods ********** - - protected static DeclarationAnnotationElementAdapter<String> buildAdapter(String elementName) { - return buildAdapter(DECLARATION_ANNOTATION_ADAPTER, elementName); - } - - protected static DeclarationAnnotationElementAdapter<Integer> buildIntegerAdapter(String elementName) { - return buildIntegerAdapter(DECLARATION_ANNOTATION_ADAPTER, elementName); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceTableAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceTableAnnotation.java deleted file mode 100644 index a7719dc774..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceTableAnnotation.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.source; - -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.resource.java.TableAnnotation; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.Table - */ -public final class SourceTableAnnotation - extends SourceBaseTableAnnotation - implements TableAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter<String> NAME_ADAPTER = ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.TABLE__NAME); - - private static final DeclarationAnnotationElementAdapter<String> SCHEMA_ADAPTER = ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.TABLE__SCHEMA); - - private static final DeclarationAnnotationElementAdapter<String> CATALOG_ADAPTER = ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.TABLE__CATALOG); - - - public SourceTableAnnotation(JavaResourcePersistentType parent, Type type) { - super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - - // ********** SourceBaseTableAnnotation implementation ********** - - @Override - protected DeclarationAnnotationElementAdapter<String> getNameAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { - // ignore the daa passed in, @Table is never nested - return NAME_ADAPTER; - } - - @Override - protected DeclarationAnnotationElementAdapter<String> getSchemaAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { - // ignore the daa passed in, @Table is never nested - return SCHEMA_ADAPTER; - } - - @Override - protected DeclarationAnnotationElementAdapter<String> getCatalogAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { - // ignore the daa passed in, @Table is never nested - return CATALOG_ADAPTER; - } - - @Override - protected String getUniqueConstraintsElementName() { - return JPA.TABLE__UNIQUE_CONSTRAINTS; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceTableGeneratorAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceTableGeneratorAnnotation.java deleted file mode 100644 index fa90f87b59..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceTableGeneratorAnnotation.java +++ /dev/null @@ -1,459 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.dom.Annotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.AnnotationContainer; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableUniqueConstraintAnnotation; -import org.eclipse.jpt.core.resource.java.TableGeneratorAnnotation; -import org.eclipse.jpt.core.resource.java.UniqueConstraintAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.StringTools; -import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.TableGenerator - */ -public final class SourceTableGeneratorAnnotation - extends SourceGeneratorAnnotation - implements TableGeneratorAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter<String> NAME_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__NAME); - - private static final DeclarationAnnotationElementAdapter<Integer> INITIAL_VALUE_ADAPTER = buildIntegerAdapter(JPA.TABLE_GENERATOR__INITIAL_VALUE); - - private static final DeclarationAnnotationElementAdapter<Integer> ALLOCATION_SIZE_ADAPTER = buildIntegerAdapter(JPA.TABLE_GENERATOR__ALLOCATION_SIZE); - - private static final DeclarationAnnotationElementAdapter<String> TABLE_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__TABLE); - private final AnnotationElementAdapter<String> tableAdapter; - private String table; - - private static final DeclarationAnnotationElementAdapter<String> SCHEMA_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__SCHEMA); - private final AnnotationElementAdapter<String> schemaAdapter; - private String schema; - - private static final DeclarationAnnotationElementAdapter<String> CATALOG_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__CATALOG); - private final AnnotationElementAdapter<String> catalogAdapter; - private String catalog; - - private static final DeclarationAnnotationElementAdapter<String> PK_COLUMN_NAME_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__PK_COLUMN_NAME); - private final AnnotationElementAdapter<String> pkColumnNameAdapter; - private String pkColumnName; - - private static final DeclarationAnnotationElementAdapter<String> VALUE_COLUMN_NAME_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__VALUE_COLUMN_NAME); - private final AnnotationElementAdapter<String> valueColumnNameAdapter; - private String valueColumnName; - - private static final DeclarationAnnotationElementAdapter<String> PK_COLUMN_VALUE_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__PK_COLUMN_VALUE); - private final AnnotationElementAdapter<String> pkColumnValueAdapter; - private String pkColumnValue; - - private final Vector<NestableUniqueConstraintAnnotation> uniqueConstraints = new Vector<NestableUniqueConstraintAnnotation>(); - private final UniqueConstraintsAnnotationContainer uniqueConstraintsContainer = new UniqueConstraintsAnnotationContainer(); - - - public SourceTableGeneratorAnnotation(JavaResourceNode parent, Member member) { - super(parent, member, DECLARATION_ANNOTATION_ADAPTER); - this.tableAdapter = this.buildAdapter(TABLE_ADAPTER); - this.catalogAdapter = this.buildAdapter(CATALOG_ADAPTER); - this.schemaAdapter = this.buildAdapter(SCHEMA_ADAPTER); - this.pkColumnNameAdapter = this.buildAdapter(PK_COLUMN_NAME_ADAPTER); - this.valueColumnNameAdapter = this.buildAdapter(VALUE_COLUMN_NAME_ADAPTER); - this.pkColumnValueAdapter = this.buildAdapter(PK_COLUMN_VALUE_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.table = this.buildTable(astRoot); - this.schema = this.buildSchema(astRoot); - this.catalog = this.buildCatalog(astRoot); - this.pkColumnName = this.buildPkColumnName(astRoot); - this.valueColumnName = this.buildValueColumnName(astRoot); - this.pkColumnValue = this.buildPkColumnValue(astRoot); - AnnotationContainerTools.initialize(this.uniqueConstraintsContainer, astRoot); - } - - @Override - public void synchronizeWith(CompilationUnit astRoot) { - super.synchronizeWith(astRoot); - this.syncTable(this.buildTable(astRoot)); - this.syncSchema(this.buildSchema(astRoot)); - this.syncCatalog(this.buildCatalog(astRoot)); - this.syncPkColumnName(this.buildPkColumnName(astRoot)); - this.syncValueColumnName(this.buildValueColumnName(astRoot)); - this.syncPkColumnValue(this.buildPkColumnValue(astRoot)); - AnnotationContainerTools.synchronize(this.uniqueConstraintsContainer, astRoot); - } - - - // ********** AbstractGeneratorAnnotation implementation ********** - - @Override - DeclarationAnnotationElementAdapter<String> getNameAdapter() { - return NAME_ADAPTER; - } - - @Override - DeclarationAnnotationElementAdapter<Integer> getInitialValueAdapter() { - return INITIAL_VALUE_ADAPTER; - } - - @Override - DeclarationAnnotationElementAdapter<Integer> getAllocationSizeAdapter() { - return ALLOCATION_SIZE_ADAPTER; - } - - - // ********** TableGeneratorAnnotation implementation ********** - - // ***** table - public String getTable() { - return this.table; - } - - public void setTable(String table) { - if (this.attributeValueHasChanged(this.table, table)) { - this.table = table; - this.tableAdapter.setValue(table); - } - } - - private void syncTable(String astTable) { - String old = this.table; - this.table = astTable; - this.firePropertyChanged(TABLE_PROPERTY, old, astTable); - } - - private String buildTable(CompilationUnit astRoot) { - return this.tableAdapter.getValue(astRoot); - } - - public TextRange getTableTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(TABLE_ADAPTER, astRoot); - } - - public boolean tableTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(TABLE_ADAPTER, pos, astRoot); - } - - // ***** schema - public String getSchema() { - return this.schema; - } - - public void setSchema(String schema) { - if (this.attributeValueHasChanged(this.schema, schema)) { - this.schema = schema; - this.schemaAdapter.setValue(schema); - } - } - - private void syncSchema(String astSchema) { - String old = this.schema; - this.schema = astSchema; - this.firePropertyChanged(SCHEMA_PROPERTY, old, astSchema); - } - - private String buildSchema(CompilationUnit astRoot) { - return this.schemaAdapter.getValue(astRoot); - } - - public TextRange getSchemaTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(SCHEMA_ADAPTER, astRoot); - } - - public boolean schemaTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(SCHEMA_ADAPTER, pos, astRoot); - } - - // ***** catalog - public String getCatalog() { - return this.catalog; - } - - public void setCatalog(String catalog) { - if (this.attributeValueHasChanged(this.catalog, catalog)) { - this.catalog = catalog; - this.catalogAdapter.setValue(catalog); - } - } - - private void syncCatalog(String astCatalog) { - String old = this.catalog; - this.catalog = astCatalog; - this.firePropertyChanged(CATALOG_PROPERTY, old, astCatalog); - } - - private String buildCatalog(CompilationUnit astRoot) { - return this.catalogAdapter.getValue(astRoot); - } - - public TextRange getCatalogTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(CATALOG_ADAPTER, astRoot); - } - - public boolean catalogTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(CATALOG_ADAPTER, pos, astRoot); - } - - // ***** pk column name - public String getPkColumnName() { - return this.pkColumnName; - } - - public void setPkColumnName(String pkColumnName) { - if (this.attributeValueHasChanged(this.pkColumnName, pkColumnName)) { - this.pkColumnName = pkColumnName; - this.pkColumnNameAdapter.setValue(pkColumnName); - } - } - - private void syncPkColumnName(String astPkColumnName) { - String old = this.pkColumnName; - this.pkColumnName = astPkColumnName; - this.firePropertyChanged(PK_COLUMN_NAME_PROPERTY, old, astPkColumnName); - } - - private String buildPkColumnName(CompilationUnit astRoot) { - return this.pkColumnNameAdapter.getValue(astRoot); - } - - public TextRange getPkColumnNameTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(PK_COLUMN_NAME_ADAPTER, astRoot); - } - - public boolean pkColumnNameTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(PK_COLUMN_NAME_ADAPTER, pos, astRoot); - } - - // ***** value column name - public String getValueColumnName() { - return this.valueColumnName; - } - - public void setValueColumnName(String valueColumnName) { - if (this.attributeValueHasChanged(this.valueColumnName, valueColumnName)) { - this.valueColumnName = valueColumnName; - this.valueColumnNameAdapter.setValue(valueColumnName); - } - } - - private void syncValueColumnName(String astValueColumnName) { - String old = this.valueColumnName; - this.valueColumnName = astValueColumnName; - this.firePropertyChanged(VALUE_COLUMN_NAME_PROPERTY, old, astValueColumnName); - } - - private String buildValueColumnName(CompilationUnit astRoot) { - return this.valueColumnNameAdapter.getValue(astRoot); - } - - public TextRange getValueColumnNameTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(VALUE_COLUMN_NAME_ADAPTER, astRoot); - } - - public boolean valueColumnNameTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(VALUE_COLUMN_NAME_ADAPTER, pos, astRoot); - } - - // ***** pk column value - public String getPkColumnValue() { - return this.pkColumnValue; - } - - public void setPkColumnValue(String pkColumnValue) { - if (this.attributeValueHasChanged(this.pkColumnValue, pkColumnValue)) { - this.pkColumnValue = pkColumnValue; - this.pkColumnValueAdapter.setValue(pkColumnValue); - } - } - - private void syncPkColumnValue(String astPkColumnValue) { - String old = this.pkColumnValue; - this.pkColumnValue = astPkColumnValue; - this.firePropertyChanged(PK_COLUMN_VALUE_PROPERTY, old, astPkColumnValue); - } - - private String buildPkColumnValue(CompilationUnit astRoot) { - return this.pkColumnValueAdapter.getValue(astRoot); - } - - public TextRange getPkColumnValueTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(PK_COLUMN_VALUE_ADAPTER, astRoot); - } - - public boolean pkColumnValueTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(PK_COLUMN_VALUE_ADAPTER, pos, astRoot); - } - - // ***** unique constraints - public ListIterator<UniqueConstraintAnnotation> uniqueConstraints() { - return new CloneListIterator<UniqueConstraintAnnotation>(this.uniqueConstraints); - } - - Iterable<NestableUniqueConstraintAnnotation> getNestableUniqueConstraints() { - return new LiveCloneIterable<NestableUniqueConstraintAnnotation>(this.uniqueConstraints); - } - - public int uniqueConstraintsSize() { - return this.uniqueConstraints.size(); - } - - public NestableUniqueConstraintAnnotation uniqueConstraintAt(int index) { - return this.uniqueConstraints.get(index); - } - - public int indexOfUniqueConstraint(UniqueConstraintAnnotation uniqueConstraint) { - return this.uniqueConstraints.indexOf(uniqueConstraint); - } - - public NestableUniqueConstraintAnnotation addUniqueConstraint(int index) { - return (NestableUniqueConstraintAnnotation) AnnotationContainerTools.addNestedAnnotation(index, this.uniqueConstraintsContainer); - } - - NestableUniqueConstraintAnnotation addUniqueConstraint_() { - return this.addUniqueConstraint_(this.uniqueConstraints.size()); - } - - private NestableUniqueConstraintAnnotation addUniqueConstraint_(int index) { - NestableUniqueConstraintAnnotation uniqueConstraint = this.buildUniqueConstraint(index); - this.uniqueConstraints.add(uniqueConstraint); - return uniqueConstraint; - } - - void syncAddUniqueConstraint(Annotation astAnnotation) { - int index = this.uniqueConstraints.size(); - NestableUniqueConstraintAnnotation uniqueConstraint = this.addUniqueConstraint_(index); - uniqueConstraint.initialize((CompilationUnit) astAnnotation.getRoot()); - this.fireItemAdded(UNIQUE_CONSTRAINTS_LIST, index, uniqueConstraint); - } - - NestableUniqueConstraintAnnotation buildUniqueConstraint(int index) { - return new SourceUniqueConstraintAnnotation(this, this.annotatedElement, buildUniqueConstraintAnnotationAdapter(index)); - } - - IndexedDeclarationAnnotationAdapter buildUniqueConstraintAnnotationAdapter(int index) { - return new NestedIndexedDeclarationAnnotationAdapter(this.daa, JPA.TABLE_GENERATOR__UNIQUE_CONSTRAINTS, index, JPA.UNIQUE_CONSTRAINT); - } - - void uniqueConstraintAdded(int index, NestableUniqueConstraintAnnotation constraint) { - this.fireItemAdded(UNIQUE_CONSTRAINTS_LIST, index, constraint); - } - - public void moveUniqueConstraint(int targetIndex, int sourceIndex) { - AnnotationContainerTools.moveNestedAnnotation(targetIndex, sourceIndex, this.uniqueConstraintsContainer); - } - - NestableUniqueConstraintAnnotation moveUniqueConstraint_(int targetIndex, int sourceIndex) { - return CollectionTools.move(this.uniqueConstraints, targetIndex, sourceIndex).get(targetIndex); - } - - public void removeUniqueConstraint(int index) { - AnnotationContainerTools.removeNestedAnnotation(index, this.uniqueConstraintsContainer); - } - - NestableUniqueConstraintAnnotation removeUniqueConstraint_(int index) { - return this.uniqueConstraints.remove(index); - } - - void syncRemoveUniqueConstraints(int index) { - this.removeItemsFromList(index, this.uniqueConstraints, UNIQUE_CONSTRAINTS_LIST); - } - - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter<String> buildAdapter(String elementName) { - return buildAdapter(DECLARATION_ANNOTATION_ADAPTER, elementName); - } - - private static DeclarationAnnotationElementAdapter<Integer> buildIntegerAdapter(String elementName) { - return buildIntegerAdapter(DECLARATION_ANNOTATION_ADAPTER, elementName); - } - - - // ********** unique constraint container ********** - - /** - * adapt the AnnotationContainer interface to the table generator's unique constraints - */ - class UniqueConstraintsAnnotationContainer - implements AnnotationContainer<NestableUniqueConstraintAnnotation> - { - public org.eclipse.jdt.core.dom.Annotation getAstAnnotation(CompilationUnit astRoot) { - return SourceTableGeneratorAnnotation.this.getAstAnnotation(astRoot); - } - - public String getElementName() { - return JPA.TABLE_GENERATOR__UNIQUE_CONSTRAINTS; - } - - public String getNestedAnnotationName() { - return UniqueConstraintAnnotation.ANNOTATION_NAME; - } - - public Iterable<NestableUniqueConstraintAnnotation> getNestedAnnotations() { - return SourceTableGeneratorAnnotation.this.getNestableUniqueConstraints(); - } - - public int getNestedAnnotationsSize() { - return SourceTableGeneratorAnnotation.this.uniqueConstraintsSize(); - } - - public NestableUniqueConstraintAnnotation addNestedAnnotation() { - return SourceTableGeneratorAnnotation.this.addUniqueConstraint_(); - } - - public void syncAddNestedAnnotation(Annotation astAnnotation) { - SourceTableGeneratorAnnotation.this.syncAddUniqueConstraint(astAnnotation); - } - - public NestableUniqueConstraintAnnotation moveNestedAnnotation(int targetIndex, int sourceIndex) { - return SourceTableGeneratorAnnotation.this.moveUniqueConstraint_(targetIndex, sourceIndex); - } - - public NestableUniqueConstraintAnnotation removeNestedAnnotation(int index) { - return SourceTableGeneratorAnnotation.this.removeUniqueConstraint_(index); - } - - public void syncRemoveNestedAnnotations(int index) { - SourceTableGeneratorAnnotation.this.syncRemoveUniqueConstraints(index); - } - - @Override - public String toString() { - return StringTools.buildToStringFor(this); - } - - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceTemporalAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceTemporalAnnotation.java deleted file mode 100644 index ca5a5dea25..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceTemporalAnnotation.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.source; - -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; - -/** - * javax.persistence.Temporal - */ -public final class SourceTemporalAnnotation - extends SourceBaseTemporalAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - - public SourceTemporalAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - protected String getValueElementName() { - return JPA.TEMPORAL__VALUE; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceTransientAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceTransientAnnotation.java deleted file mode 100644 index fe3c171d89..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceTransientAnnotation.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.TransientAnnotation; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; - -/** - * javax.persistence.Transient - */ -public final class SourceTransientAnnotation - extends SourceAnnotation<Attribute> - implements TransientAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - - public SourceTransientAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - // nothing to initialize - } - - public void synchronizeWith(CompilationUnit astRoot) { - // nothing to update - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceTypeCompilationUnit.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceTypeCompilationUnit.java deleted file mode 100644 index d6dc5b48fe..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceTypeCompilationUnit.java +++ /dev/null @@ -1,167 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import java.util.Iterator; -import java.util.List; -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.dom.ASTNode; -import org.eclipse.jdt.core.dom.AbstractTypeDeclaration; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jdt.core.dom.TypeDeclaration; -import org.eclipse.jpt.core.JpaAnnotationProvider; -import org.eclipse.jpt.core.JpaResourceType; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.jdt.AnnotationEditFormatter; -import org.eclipse.jpt.utility.CommandExecutor; -import org.eclipse.jpt.utility.internal.iterators.EmptyIterator; - -/** - * Java compilation unit (source file) - * non package-info.java file - */ -public final class SourceTypeCompilationUnit - extends SourceCompilationUnit -{ - - /** - * The primary type of the AST compilation unit. We are not going to handle - * multiple types defined in a single compilation unit. Entities must have - * a public/protected no-arg constructor, and there is no way to access - * the constructor in a package class (which is what all top-level, - * non-primary classes must be). - */ - private JavaResourcePersistentType persistentType; - - - // ********** construction ********** - - public SourceTypeCompilationUnit( - ICompilationUnit compilationUnit, - JpaAnnotationProvider annotationProvider, - AnnotationEditFormatter annotationEditFormatter, - CommandExecutor modifySharedDocumentCommandExecutor) { - super(compilationUnit, annotationProvider, annotationEditFormatter, modifySharedDocumentCommandExecutor); // the JPA compilation unit is the root of its sub-tree - this.persistentType = this.buildPersistentType(); - } - - private JavaResourcePersistentType buildPersistentType() { - this.openCompilationUnit(); - CompilationUnit astRoot = this.buildASTRoot(); - this.closeCompilationUnit(); - return this.buildPersistentType(astRoot); - } - - - // ********** JavaResourceNode implementation ********** - - public void synchronizeWith(CompilationUnit astRoot) { - this.syncPersistentType(astRoot); - } - - - // ********** JavaResourceNode.Root implementation ********** - - /** - * NB: return *all* the persistent types since we build them all - */ - public Iterator<JavaResourcePersistentType> persistentTypes() { - return (this.persistentType == null) ? - EmptyIterator.<JavaResourcePersistentType>instance() : - this.persistentType.allTypes(); - } - - - // ********** JpaResourceModel implementation ********** - - public JpaResourceType getResourceType() { - return JptCorePlugin.JAVA_SOURCE_RESOURCE_TYPE; - } - - - // ********** JavaResourceCompilationUnit implementation ********** - - public void resolveTypes() { - if (this.persistentType != null) { - this.persistentType.resolveTypes(this.buildASTRoot()); - } - } - - - // ********** persistent type ********** - - private JavaResourcePersistentType buildPersistentType(CompilationUnit astRoot) { - TypeDeclaration td = this.getPrimaryTypeDeclaration(astRoot); - return (td == null) ? null : this.buildPersistentType(astRoot, td); - } - - - private void syncPersistentType(CompilationUnit astRoot) { - TypeDeclaration td = this.getPrimaryTypeDeclaration(astRoot); - if (td == null) { - this.syncPersistentType_(null); - } else { - if (this.persistentType == null) { - this.syncPersistentType_(this.buildPersistentType(astRoot, td)); - } else { - this.persistentType.synchronizeWith(astRoot); - } - } - } - - private void syncPersistentType_(JavaResourcePersistentType astPersistentType) { - JavaResourcePersistentType old = this.persistentType; - this.persistentType = astPersistentType; - this.firePropertyChanged(PERSISTENT_TYPES_COLLECTION, old, astPersistentType); - } - - - // ********** internal ********** - - private JavaResourcePersistentType buildPersistentType(CompilationUnit astRoot, TypeDeclaration typeDeclaration) { - return SourcePersistentType.newInstance(this, typeDeclaration, astRoot); - } - - /** - * i.e. the type with the same name as the compilation unit; - * return the first class or interface (ignore annotations and enums) with - * the same name as the compilation unit (file); - * NB: this type could be in error if there is an annotation or enum - * with the same name preceding it in the compilation unit - * - * Return null if the parser did not resolve the type declaration's binding. - * This can occur if the project JRE is removed (bug 225332). - */ - private TypeDeclaration getPrimaryTypeDeclaration(CompilationUnit astRoot) { - String primaryTypeName = this.getPrimaryTypeName(); - for (AbstractTypeDeclaration atd : this.types(astRoot)) { - if (this.nodeIsPrimaryTypeDeclaration(atd, primaryTypeName)) { - return (atd.resolveBinding() == null) ? null : (TypeDeclaration) atd; - } - } - return null; - } - - private boolean nodeIsPrimaryTypeDeclaration(AbstractTypeDeclaration atd, String primaryTypeName) { - return (atd.getNodeType() == ASTNode.TYPE_DECLARATION) && - atd.getName().getFullyQualifiedName().equals(primaryTypeName); - } - - private String getPrimaryTypeName() { - return this.getCompilationUnitName(); - } - - // minimize scope of suppressed warnings - @SuppressWarnings("unchecked") - private List<AbstractTypeDeclaration> types(CompilationUnit astRoot) { - return astRoot.types(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceUniqueConstraintAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceUniqueConstraintAnnotation.java deleted file mode 100644 index af880d551a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceUniqueConstraintAnnotation.java +++ /dev/null @@ -1,156 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import java.util.Arrays; -import java.util.ListIterator; -import java.util.Vector; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.AnnotatedElementAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.AnnotationStringArrayExpressionConverter; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ElementIndexedAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.resource.java.NestableUniqueConstraintAnnotation; -import org.eclipse.jpt.core.resource.java.UniqueConstraintAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.ExpressionConverter; -import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.UniqueConstraint - */ -public final class SourceUniqueConstraintAnnotation - extends SourceAnnotation<Member> - implements NestableUniqueConstraintAnnotation -{ - private final DeclarationAnnotationElementAdapter<String[]> columnNamesDeclarationAdapter; - private final AnnotationElementAdapter<String[]> columnNamesAdapter; - private final Vector<String> columnNames = new Vector<String>(); - - - public SourceUniqueConstraintAnnotation(JavaResourceNode parent, Member member, IndexedDeclarationAnnotationAdapter idaa) { - super(parent, member, idaa, new ElementIndexedAnnotationAdapter(member, idaa)); - this.columnNamesDeclarationAdapter = buildArrayAnnotationElementAdapter(idaa, JPA.UNIQUE_CONSTRAINT__COLUMN_NAMES); - this.columnNamesAdapter = this.buildAnnotationElementAdapter(this.columnNamesDeclarationAdapter); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - private AnnotationElementAdapter<String[]> buildAnnotationElementAdapter(DeclarationAnnotationElementAdapter<String[]> daea) { - return new AnnotatedElementAnnotationElementAdapter<String[]>(this.annotatedElement, daea); - } - - private static DeclarationAnnotationElementAdapter<String[]> buildArrayAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { - return buildArrayAnnotationElementAdapter(annotationAdapter, elementName, AnnotationStringArrayExpressionConverter.forStrings()); - } - - private static DeclarationAnnotationElementAdapter<String[]> buildArrayAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, ExpressionConverter<String[]> converter) { - return new ConversionDeclarationAnnotationElementAdapter<String[]>(annotationAdapter, elementName, false, converter); - } - - public void initialize(CompilationUnit astRoot) { - this.initializeColumnNames(astRoot); - } - - public void synchronizeWith(CompilationUnit astRoot) { - this.syncColumnNames(astRoot); - } - - public IndexedAnnotationAdapter getIndexedAnnotationAdapter() { - return (IndexedAnnotationAdapter) this.annotationAdapter; - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.columnNames); - } - - - // ********** UniqueConstraintAnnotation implementation ********** - - // ***** column names - public ListIterator<String> columnNames() { - return new CloneListIterator<String>(this.columnNames); - } - - public int columnNamesSize() { - return this.columnNames.size(); - } - - public void addColumnName(String columnName) { - this.addColumnName(this.columnNames.size(), columnName); - } - - public void addColumnName(int index, String columnName) { - this.columnNames.add(index, columnName); - this.writeColumnNames(); - } - - public void moveColumnName(int targetIndex, int sourceIndex) { - CollectionTools.move(this.columnNames, targetIndex, sourceIndex); - this.writeColumnNames(); - } - - public void removeColumnName(String columnName) { - this.columnNames.remove(columnName); - this.writeColumnNames(); - } - - public void removeColumnName(int index) { - this.columnNames.remove(index); - this.writeColumnNames(); - } - - private void writeColumnNames() { - this.columnNamesAdapter.setValue(this.columnNames.toArray(new String[this.columnNames.size()])); - } - - private void initializeColumnNames(CompilationUnit astRoot) { - String[] astColumnNames = this.columnNamesAdapter.getValue(astRoot); - for (int i = 0; i < astColumnNames.length; i++) { - this.columnNames.add(astColumnNames[i]); - } - } - - private void syncColumnNames(CompilationUnit astRoot) { - String[] javaColumnNames = this.columnNamesAdapter.getValue(astRoot); - this.synchronizeList(Arrays.asList(javaColumnNames), this.columnNames, COLUMN_NAMES_LIST); - } - - public boolean columnNamesTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(this.columnNamesDeclarationAdapter, pos, astRoot); - } - - - // ********** NestableAnnotation implementation ********** - - public void initializeFrom(NestableAnnotation oldAnnotation) { - UniqueConstraintAnnotation oldConstraint = (UniqueConstraintAnnotation) oldAnnotation; - for (String columnName : CollectionTools.iterable(oldConstraint.columnNames())) { - this.addColumnName(columnName); - } - } - - public void moveAnnotation(int newIndex) { - this.getIndexedAnnotationAdapter().moveAnnotation(newIndex); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceVersionAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceVersionAnnotation.java deleted file mode 100644 index 7e1e448cd7..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceVersionAnnotation.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.VersionAnnotation; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; - -/** - * javax.persistence.Version - */ -public final class SourceVersionAnnotation - extends SourceAnnotation<Attribute> - implements VersionAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - - public SourceVersionAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - // nothing to initialize - } - - public void synchronizeWith(CompilationUnit astRoot) { - // nothing to update - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/orm/OrmXmlResourceProvider.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/orm/OrmXmlResourceProvider.java deleted file mode 100644 index 068c58b3f1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/orm/OrmXmlResourceProvider.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2010 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.orm; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.internal.operations.OrmFileCreationDataModelProperties; -import org.eclipse.jpt.core.resource.AbstractXmlResourceProvider; -import org.eclipse.jpt.core.resource.orm.AccessType; -import org.eclipse.jpt.core.resource.orm.OrmFactory; -import org.eclipse.jpt.core.resource.orm.XmlEntityMappings; -import org.eclipse.jpt.core.resource.orm.XmlPersistenceUnitDefaults; -import org.eclipse.jpt.core.resource.orm.XmlPersistenceUnitMetadata; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -public class OrmXmlResourceProvider - extends AbstractXmlResourceProvider - implements OrmFileCreationDataModelProperties -{ - /** - * (Convenience method) Returns an ORM resource model provider for - * the given file. - */ - public static OrmXmlResourceProvider getXmlResourceProvider(IFile file) { - return getXmlResourceProvider_(file.getProject(), file.getFullPath()); - } - - /** - * (Convenience method) Returns an ORM resource model provider for - * the given project in the specified runtime location - */ - public static OrmXmlResourceProvider getXmlResourceProvider(IProject project, IPath runtimePath) { - return getXmlResourceProvider_(project, runtimePath); - } - - /** - * (Convenience method) Returns an ORM resource model provider for - * the given project in the default runtime location - */ - public static OrmXmlResourceProvider getDefaultXmlResourceProvider(IProject project) { - return getXmlResourceProvider(project, JptCorePlugin.DEFAULT_ORM_XML_RUNTIME_PATH); - } - - private static OrmXmlResourceProvider getXmlResourceProvider_(IProject project, IPath fullPath) { - return new OrmXmlResourceProvider(project, fullPath); - } - - - public OrmXmlResourceProvider(IProject project) { - this(project, JptCorePlugin.DEFAULT_ORM_XML_RUNTIME_PATH); - } - - public OrmXmlResourceProvider(IProject project, IPath filePath) { - super(project, filePath, JptCorePlugin.ORM_XML_CONTENT_TYPE); - } - - @Override - protected void populateRoot(Object config) { - IDataModel dataModel = (IDataModel) config; - XmlEntityMappings entityMappings = OrmFactory.eINSTANCE.createXmlEntityMappings(); - entityMappings.setVersion(dataModel.getStringProperty(VERSION)); - getResourceContents().add(entityMappings); - - AccessType defaultAccess = (AccessType) dataModel.getProperty(DEFAULT_ACCESS); - if (defaultAccess != null) { - XmlPersistenceUnitMetadata puMetadata = OrmFactory.eINSTANCE.createXmlPersistenceUnitMetadata(); - entityMappings.setPersistenceUnitMetadata(puMetadata); - XmlPersistenceUnitDefaults puDefaults = OrmFactory.eINSTANCE.createXmlPersistenceUnitDefaults(); - puMetadata.setPersistenceUnitDefaults(puDefaults); - puDefaults.setAccess(defaultAccess); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/persistence/PersistenceXmlResourceProvider.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/persistence/PersistenceXmlResourceProvider.java deleted file mode 100644 index 42d6d7b3d5..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/persistence/PersistenceXmlResourceProvider.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2010 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.persistence; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.internal.operations.PersistenceFileCreationDataModelProperties; -import org.eclipse.jpt.core.resource.AbstractXmlResourceProvider; -import org.eclipse.jpt.core.resource.persistence.PersistenceFactory; -import org.eclipse.jpt.core.resource.persistence.XmlPersistence; -import org.eclipse.jpt.core.resource.persistence.XmlPersistenceUnit; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -public class PersistenceXmlResourceProvider - extends AbstractXmlResourceProvider - implements PersistenceFileCreationDataModelProperties -{ - /** - * (Convenience method) Returns a persistence resource model provider for - * the given file. - */ - public static PersistenceXmlResourceProvider getXmlResourceProvider(IFile file) { - return getXmlResourceProvider_(file.getProject(), file.getFullPath()); - } - - /** - * (Convenience method) Returns an persistence resource model provider for - * the given project in the specified runtime location - */ - public static PersistenceXmlResourceProvider getXmlResourceProvider(IProject project, IPath runtimePath) { - return getXmlResourceProvider_(project, runtimePath); - } - - /** - * (Convenience method) Returns a persistence resource model provider for - * the given project in the default runtime location - */ - public static PersistenceXmlResourceProvider getDefaultXmlResourceProvider(IProject project) { - return getXmlResourceProvider(project, JptCorePlugin.DEFAULT_PERSISTENCE_XML_RUNTIME_PATH); - } - - private static PersistenceXmlResourceProvider getXmlResourceProvider_(IProject project, IPath fullPath) { - return new PersistenceXmlResourceProvider(project, fullPath); - } - - - public PersistenceXmlResourceProvider(IProject project) { - this(project, JptCorePlugin.DEFAULT_PERSISTENCE_XML_RUNTIME_PATH); - } - - public PersistenceXmlResourceProvider(IProject project, IPath filePath) { - super(project, filePath, JptCorePlugin.PERSISTENCE_XML_CONTENT_TYPE); - } - - - @Override - protected void populateRoot(Object config) { - IDataModel dataModel = (IDataModel) config; - XmlPersistence persistence = PersistenceFactory.eINSTANCE.createXmlPersistence(); - persistence.setVersion(dataModel.getStringProperty(VERSION)); - XmlPersistenceUnit persistenceUnit = PersistenceFactory.eINSTANCE.createXmlPersistenceUnit(); - persistenceUnit.setName(getProject().getName()); - persistence.getPersistenceUnits().add(persistenceUnit); - getResourceContents().add(persistence); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/xml/JpaXmlResourceAdapterFactory.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/xml/JpaXmlResourceAdapterFactory.java deleted file mode 100644 index c03f4b15b8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/xml/JpaXmlResourceAdapterFactory.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * 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.xml; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.jpt.core.JpaFile; -import org.eclipse.jpt.core.JpaResourceModel; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.resource.xml.JpaXmlResource; - -public class JpaXmlResourceAdapterFactory - implements IAdapterFactory -{ - private static final Class<?>[] ADAPTER_LIST = new Class[] { JpaXmlResource.class }; - - public Class<?>[] getAdapterList() { - return ADAPTER_LIST; - } - - public Object getAdapter(Object adaptableObject, @SuppressWarnings("unchecked") Class adapterType) { - if (adaptableObject instanceof IFile) { - return this.getAdapter((IFile) adaptableObject, adapterType); - } - return null; - } - - private Object getAdapter(final IFile file, Class <?>adapterType) { - if (adapterType == JpaXmlResource.class) { - JpaFile jpaFile = JptCorePlugin.getJpaFile(file); - if (jpaFile != null) { - JpaResourceModel resourceModel = jpaFile.getResourceModel(); - if (resourceModel instanceof JpaXmlResource) { - return resourceModel; - } - } - } - return null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/xml/JpaXmlResourcePropertyTester.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/xml/JpaXmlResourcePropertyTester.java deleted file mode 100644 index f1c518dffa..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/xml/JpaXmlResourcePropertyTester.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.xml; - -import org.eclipse.core.expressions.PropertyTester; -import org.eclipse.core.runtime.content.IContentType; -import org.eclipse.jpt.core.JpaProject; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.context.XmlFile; -import org.eclipse.jpt.core.resource.xml.JpaXmlResource; - -// TODO move to o.e.jpt.core.internal(.context)? -// rename to JpaXmlPropertyTester -public class JpaXmlResourcePropertyTester - extends PropertyTester -{ - public static final String IS_LATEST_SUPPORTED_VERSION = "isLatestSupportedVersion"; //$NON-NLS-1$ - - - public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { - JpaXmlResource xmlResource = null; - if (receiver instanceof JpaXmlResource) { - xmlResource = (JpaXmlResource) receiver; - } - else if (receiver instanceof XmlFile) { - xmlResource = ((XmlFile) receiver).getXmlResource(); - } - else { - return false; - } - - if (IS_LATEST_SUPPORTED_VERSION.equals(property)) { - boolean expected = ((Boolean) expectedValue).booleanValue(); - JpaProject jpaProject = JptCorePlugin.getJpaProject(xmlResource.getProject()); - IContentType contentType = xmlResource.getContentType(); - boolean actual = - xmlResource.getVersion() != null - && xmlResource.getVersion().equals( - jpaProject.getJpaPlatform().getMostRecentSupportedResourceType(contentType).getVersion()); - - return actual == expected; - } - - return false; - } -} |