diff options
author | bvosburgh | 2009-04-06 18:15:04 +0000 |
---|---|---|
committer | bvosburgh | 2009-04-06 18:15:04 +0000 |
commit | 8a8198bd21c086332af305f9766008e0a212ef61 (patch) | |
tree | 28f445b916ecfc9898a402234ce19a262fc30bde | |
parent | 452e55147020a06aa3f6bda36c3c816c034c0790 (diff) | |
download | webtools.dali-8a8198bd21c086332af305f9766008e0a212ef61.tar.gz webtools.dali-8a8198bd21c086332af305f9766008e0a212ef61.tar.xz webtools.dali-8a8198bd21c086332af305f9766008e0a212ef61.zip |
reworked enums
19 files changed, 821 insertions, 764 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/AccessType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/AccessType.java index d815336b4c..6bbc32639e 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/AccessType.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/AccessType.java @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.context; /** - * + * Access Type * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -20,64 +20,73 @@ package org.eclipse.jpt.core.context; */ public enum AccessType { - FIELD, - PROPERTY; + FIELD( + org.eclipse.jpt.core.resource.java.AccessType.FIELD, + org.eclipse.jpt.core.resource.orm.AccessType.FIELD + ), + PROPERTY( + org.eclipse.jpt.core.resource.java.AccessType.PROPERTY, + org.eclipse.jpt.core.resource.orm.AccessType.PROPERTY + ); - public static AccessType fromJavaResourceModel(org.eclipse.jpt.core.resource.java.AccessType javaAccessType) { + private org.eclipse.jpt.core.resource.java.AccessType javaAccessType; + private org.eclipse.jpt.core.resource.orm.AccessType ormAccessType; + + AccessType(org.eclipse.jpt.core.resource.java.AccessType javaAccessType, org.eclipse.jpt.core.resource.orm.AccessType ormAccessType) { if (javaAccessType == null) { - return null; + throw new NullPointerException(); } - switch (javaAccessType) { - case FIELD: - return FIELD; - case PROPERTY: - return PROPERTY; - default: - throw new IllegalArgumentException("unknown access type: " + javaAccessType); //$NON-NLS-1$ + if (ormAccessType == null) { + throw new NullPointerException(); } + this.javaAccessType = javaAccessType; + this.ormAccessType = ormAccessType; } - public static org.eclipse.jpt.core.resource.java.AccessType toJavaResourceModel(AccessType accessType) { - if (accessType == null) { - return null; - } - switch (accessType) { - case FIELD: - return org.eclipse.jpt.core.resource.java.AccessType.FIELD; - case PROPERTY: - return org.eclipse.jpt.core.resource.java.AccessType.PROPERTY; - default: - throw new IllegalArgumentException("unknown access type: " + accessType); //$NON-NLS-1$ + public org.eclipse.jpt.core.resource.java.AccessType getJavaAccessType() { + return this.javaAccessType; + } + + public org.eclipse.jpt.core.resource.orm.AccessType getOrmAccessType() { + return this.ormAccessType; + } + + + // ********** static methods ********** + + public static AccessType fromJavaResourceModel(org.eclipse.jpt.core.resource.java.AccessType javaAccessType) { + return (javaAccessType == null) ? null : fromJavaResourceModel_(javaAccessType); + } + + private static AccessType fromJavaResourceModel_(org.eclipse.jpt.core.resource.java.AccessType javaAccessType) { + for (AccessType accessType : AccessType.values()) { + if (accessType.getJavaAccessType() == javaAccessType) { + return accessType; + } } + return null; } - + + public static org.eclipse.jpt.core.resource.java.AccessType toJavaResourceModel(AccessType accessType) { + return (accessType == null) ? null : accessType.getJavaAccessType(); + } + public static AccessType fromOrmResourceModel(org.eclipse.jpt.core.resource.orm.AccessType ormAccessType) { - if (ormAccessType == null) { - return null; - } - switch (ormAccessType) { - case FIELD: - return FIELD; - case PROPERTY: - return PROPERTY; - default: - throw new IllegalArgumentException("unknown access type: " + ormAccessType); //$NON-NLS-1$ + return (ormAccessType == null) ? null : fromOrmResourceModel_(ormAccessType); + } + + private static AccessType fromOrmResourceModel_(org.eclipse.jpt.core.resource.orm.AccessType ormAccessType) { + for (AccessType accessType : AccessType.values()) { + if (accessType.getOrmAccessType() == ormAccessType) { + return accessType; + } } + return null; } - + public static org.eclipse.jpt.core.resource.orm.AccessType toOrmResourceModel(AccessType accessType) { - if (accessType == null) { - return null; - } - switch (accessType) { - case FIELD: - return org.eclipse.jpt.core.resource.orm.AccessType.FIELD; - case PROPERTY: - return org.eclipse.jpt.core.resource.orm.AccessType.PROPERTY; - default: - throw new IllegalArgumentException("unknown access type: " + accessType); //$NON-NLS-1$ - } + return (accessType == null) ? null : accessType.getOrmAccessType(); } } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/DiscriminatorType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/DiscriminatorType.java index 6ec46a7f08..6815b89025 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/DiscriminatorType.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/DiscriminatorType.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 Oracle. All rights reserved. + * Copyright (c) 2005, 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. @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.context; /** - * + * Discriminator Type * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -20,73 +20,77 @@ package org.eclipse.jpt.core.context; */ public enum DiscriminatorType { - STRING, - CHAR, - INTEGER; - + STRING( + org.eclipse.jpt.core.resource.java.DiscriminatorType.STRING, + org.eclipse.jpt.core.resource.orm.DiscriminatorType.STRING + ), + CHAR( + org.eclipse.jpt.core.resource.java.DiscriminatorType.CHAR, + org.eclipse.jpt.core.resource.orm.DiscriminatorType.CHAR + ), + INTEGER( + org.eclipse.jpt.core.resource.java.DiscriminatorType.INTEGER, + org.eclipse.jpt.core.resource.orm.DiscriminatorType.INTEGER + ); - public static DiscriminatorType fromJavaResourceModel(org.eclipse.jpt.core.resource.java.DiscriminatorType javaDiscriminatorType) { + + private org.eclipse.jpt.core.resource.java.DiscriminatorType javaDiscriminatorType; + private org.eclipse.jpt.core.resource.orm.DiscriminatorType ormDiscriminatorType; + + DiscriminatorType(org.eclipse.jpt.core.resource.java.DiscriminatorType javaDiscriminatorType, org.eclipse.jpt.core.resource.orm.DiscriminatorType ormDiscriminatorType) { if (javaDiscriminatorType == null) { - return null; + throw new NullPointerException(); } - switch (javaDiscriminatorType) { - case STRING: - return STRING; - case CHAR: - return CHAR; - case INTEGER: - return INTEGER; - default: - throw new IllegalArgumentException("unknown discriminator type: " + javaDiscriminatorType); //$NON-NLS-1$ + if (ormDiscriminatorType == null) { + throw new NullPointerException(); } + this.javaDiscriminatorType = javaDiscriminatorType; + this.ormDiscriminatorType = ormDiscriminatorType; } - - public static org.eclipse.jpt.core.resource.java.DiscriminatorType toJavaResourceModel(DiscriminatorType discriminatorType) { - if (discriminatorType == null) { - return null; - } - switch (discriminatorType) { - case STRING: - return org.eclipse.jpt.core.resource.java.DiscriminatorType.STRING; - case CHAR: - return org.eclipse.jpt.core.resource.java.DiscriminatorType.CHAR; - case INTEGER: - return org.eclipse.jpt.core.resource.java.DiscriminatorType.INTEGER; - default: - throw new IllegalArgumentException("unknown discriminator type: " + discriminatorType); //$NON-NLS-1$ + + public org.eclipse.jpt.core.resource.java.DiscriminatorType getJavaDiscriminatorType() { + return this.javaDiscriminatorType; + } + + public org.eclipse.jpt.core.resource.orm.DiscriminatorType getOrmDiscriminatorType() { + return this.ormDiscriminatorType; + } + + + // ********** static methods ********** + + public static DiscriminatorType fromJavaResourceModel(org.eclipse.jpt.core.resource.java.DiscriminatorType javaDiscriminatorType) { + return (javaDiscriminatorType == null) ? null : fromJavaResourceModel_(javaDiscriminatorType); + } + + private static DiscriminatorType fromJavaResourceModel_(org.eclipse.jpt.core.resource.java.DiscriminatorType javaDiscriminatorType) { + for (DiscriminatorType discriminatorType : DiscriminatorType.values()) { + if (discriminatorType.getJavaDiscriminatorType() == javaDiscriminatorType) { + return discriminatorType; + } } + return null; + } + + public static org.eclipse.jpt.core.resource.java.DiscriminatorType toJavaResourceModel(DiscriminatorType discriminatorType) { + return (discriminatorType == null) ? null : discriminatorType.getJavaDiscriminatorType(); } public static DiscriminatorType fromOrmResourceModel(org.eclipse.jpt.core.resource.orm.DiscriminatorType ormDiscriminatorType) { - if (ormDiscriminatorType == null) { - return null; - } - switch (ormDiscriminatorType) { - case STRING: - return STRING; - case CHAR: - return CHAR; - case INTEGER: - return INTEGER; - default: - throw new IllegalArgumentException("unknown discriminator type: " + ormDiscriminatorType); //$NON-NLS-1$ + return (ormDiscriminatorType == null) ? null : fromOrmResourceModel_(ormDiscriminatorType); + } + + private static DiscriminatorType fromOrmResourceModel_(org.eclipse.jpt.core.resource.orm.DiscriminatorType ormDiscriminatorType) { + for (DiscriminatorType discriminatorType : DiscriminatorType.values()) { + if (discriminatorType.getOrmDiscriminatorType() == ormDiscriminatorType) { + return discriminatorType; + } } + return null; } - + public static org.eclipse.jpt.core.resource.orm.DiscriminatorType toOrmResourceModel(DiscriminatorType discriminatorType) { - if (discriminatorType == null) { - return null; - } - switch (discriminatorType) { - case STRING: - return org.eclipse.jpt.core.resource.orm.DiscriminatorType.STRING; - case CHAR: - return org.eclipse.jpt.core.resource.orm.DiscriminatorType.CHAR; - case INTEGER: - return org.eclipse.jpt.core.resource.orm.DiscriminatorType.INTEGER; - default: - throw new IllegalArgumentException("unknown discriminator type: " + discriminatorType); //$NON-NLS-1$ - } + return (discriminatorType == null) ? null : discriminatorType.getOrmDiscriminatorType(); } } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/EnumType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/EnumType.java index 9b09e2b4dd..ec0974d9a5 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/EnumType.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/EnumType.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 Oracle. All rights reserved. + * Copyright (c) 2005, 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. @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.context; /** - * + * Enum Type * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -20,64 +20,73 @@ package org.eclipse.jpt.core.context; */ public enum EnumType { - ORDINAL, - STRING; - + ORDINAL( + org.eclipse.jpt.core.resource.java.EnumType.ORDINAL, + org.eclipse.jpt.core.resource.orm.EnumType.ORDINAL + ), + STRING( + org.eclipse.jpt.core.resource.java.EnumType.STRING, + org.eclipse.jpt.core.resource.orm.EnumType.STRING + ); - public static EnumType fromJavaResourceModel(org.eclipse.jpt.core.resource.java.EnumType javaEnumType) { + + private org.eclipse.jpt.core.resource.java.EnumType javaEnumType; + private org.eclipse.jpt.core.resource.orm.EnumType ormEnumType; + + EnumType(org.eclipse.jpt.core.resource.java.EnumType javaEnumType, org.eclipse.jpt.core.resource.orm.EnumType ormEnumType) { if (javaEnumType == null) { - return null; + throw new NullPointerException(); } - switch (javaEnumType) { - case ORDINAL: - return ORDINAL; - case STRING: - return STRING; - default: - throw new IllegalArgumentException("unknown enum type: " + javaEnumType); //$NON-NLS-1$ + if (ormEnumType == null) { + throw new NullPointerException(); } + this.javaEnumType = javaEnumType; + this.ormEnumType = ormEnumType; } - - public static org.eclipse.jpt.core.resource.java.EnumType toJavaResourceModel(EnumType enumType) { - if (enumType == null) { - return null; - } - switch (enumType) { - case ORDINAL: - return org.eclipse.jpt.core.resource.java.EnumType.ORDINAL; - case STRING: - return org.eclipse.jpt.core.resource.java.EnumType.STRING; - default: - throw new IllegalArgumentException("unknown enum type: " + enumType); //$NON-NLS-1$ + + public org.eclipse.jpt.core.resource.java.EnumType getJavaEnumType() { + return this.javaEnumType; + } + + public org.eclipse.jpt.core.resource.orm.EnumType getOrmEnumType() { + return this.ormEnumType; + } + + + // ********** static methods ********** + + public static EnumType fromJavaResourceModel(org.eclipse.jpt.core.resource.java.EnumType javaEnumType) { + return (javaEnumType == null) ? null : fromJavaResourceModel_(javaEnumType); + } + + private static EnumType fromJavaResourceModel_(org.eclipse.jpt.core.resource.java.EnumType javaEnumType) { + for (EnumType enumType : EnumType.values()) { + if (enumType.getJavaEnumType() == javaEnumType) { + return enumType; + } } + return null; + } + + public static org.eclipse.jpt.core.resource.java.EnumType toJavaResourceModel(EnumType enumType) { + return (enumType == null) ? null : enumType.getJavaEnumType(); } - public static EnumType fromOrmResourceModel(org.eclipse.jpt.core.resource.orm.EnumType ormEnumType) { - if (ormEnumType == null) { - return null; - } - switch (ormEnumType) { - case ORDINAL: - return ORDINAL; - case STRING: - return STRING; - default: - throw new IllegalArgumentException("unknown enum type: " + ormEnumType); //$NON-NLS-1$ + return (ormEnumType == null) ? null : fromOrmResourceModel_(ormEnumType); + } + + private static EnumType fromOrmResourceModel_(org.eclipse.jpt.core.resource.orm.EnumType ormEnumType) { + for (EnumType enumType : EnumType.values()) { + if (enumType.getOrmEnumType() == ormEnumType) { + return enumType; + } } + return null; } - + public static org.eclipse.jpt.core.resource.orm.EnumType toOrmResourceModel(EnumType enumType) { - if (enumType == null) { - return null; - } - switch (enumType) { - case ORDINAL: - return org.eclipse.jpt.core.resource.orm.EnumType.ORDINAL; - case STRING: - return org.eclipse.jpt.core.resource.orm.EnumType.STRING; - default: - throw new IllegalArgumentException("unknown enum type: " + enumType); //$NON-NLS-1$ - } + return (enumType == null) ? null : enumType.getOrmEnumType(); } + } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/FetchType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/FetchType.java index 2bb163d936..cda285bd0d 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/FetchType.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/FetchType.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 Oracle. All rights reserved. + * Copyright (c) 2005, 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. @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.context; /** - * + * Fetch Type * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -20,65 +20,73 @@ package org.eclipse.jpt.core.context; */ public enum FetchType { - EAGER, - LAZY; - + EAGER( + org.eclipse.jpt.core.resource.java.FetchType.EAGER, + org.eclipse.jpt.core.resource.orm.FetchType.EAGER + ), + LAZY( + org.eclipse.jpt.core.resource.java.FetchType.LAZY, + org.eclipse.jpt.core.resource.orm.FetchType.LAZY + ); - public static FetchType fromJavaResourceModel(org.eclipse.jpt.core.resource.java.FetchType javaFetchType) { + + private org.eclipse.jpt.core.resource.java.FetchType javaFetchType; + private org.eclipse.jpt.core.resource.orm.FetchType ormFetchType; + + FetchType(org.eclipse.jpt.core.resource.java.FetchType javaFetchType, org.eclipse.jpt.core.resource.orm.FetchType ormFetchType) { if (javaFetchType == null) { - return null; + throw new NullPointerException(); } - switch (javaFetchType) { - case EAGER: - return EAGER; - case LAZY: - return LAZY; - default: - throw new IllegalArgumentException("unknown fetch type: " + javaFetchType); //$NON-NLS-1$ + if (ormFetchType == null) { + throw new NullPointerException(); } + this.javaFetchType = javaFetchType; + this.ormFetchType = ormFetchType; } - public static org.eclipse.jpt.core.resource.java.FetchType toJavaResourceModel(FetchType fetchType) { - if (fetchType == null) { - return null; - } - switch (fetchType) { - case EAGER: - return org.eclipse.jpt.core.resource.java.FetchType.EAGER; - case LAZY: - return org.eclipse.jpt.core.resource.java.FetchType.LAZY; - default: - throw new IllegalArgumentException("unknown fetch type: " + fetchType); //$NON-NLS-1$ + public org.eclipse.jpt.core.resource.java.FetchType getJavaFetchType() { + return this.javaFetchType; + } + + public org.eclipse.jpt.core.resource.orm.FetchType getOrmFetchType() { + return this.ormFetchType; + } + + + // ********** static methods ********** + + public static FetchType fromJavaResourceModel(org.eclipse.jpt.core.resource.java.FetchType javaFetchType) { + return (javaFetchType == null) ? null : fromJavaResourceModel_(javaFetchType); + } + + private static FetchType fromJavaResourceModel_(org.eclipse.jpt.core.resource.java.FetchType javaFetchType) { + for (FetchType fetchType : FetchType.values()) { + if (fetchType.getJavaFetchType() == javaFetchType) { + return fetchType; + } } + return null; + } + + public static org.eclipse.jpt.core.resource.java.FetchType toJavaResourceModel(FetchType fetchType) { + return (fetchType == null) ? null : fetchType.getJavaFetchType(); } - public static FetchType fromOrmResourceModel(org.eclipse.jpt.core.resource.orm.FetchType ormFetchType) { - if (ormFetchType == null) { - return null; - } - switch (ormFetchType) { - case EAGER: - return EAGER; - case LAZY: - return LAZY; - default: - throw new IllegalArgumentException("unknown fetch type: " + ormFetchType); //$NON-NLS-1$ + return (ormFetchType == null) ? null : fromOrmResourceModel_(ormFetchType); + } + + private static FetchType fromOrmResourceModel_(org.eclipse.jpt.core.resource.orm.FetchType ormFetchType) { + for (FetchType fetchType : FetchType.values()) { + if (fetchType.getOrmFetchType() == ormFetchType) { + return fetchType; + } } + return null; } - + public static org.eclipse.jpt.core.resource.orm.FetchType toOrmResourceModel(FetchType fetchType) { - if (fetchType == null) { - return null; - } - switch (fetchType) { - case EAGER: - return org.eclipse.jpt.core.resource.orm.FetchType.EAGER; - case LAZY: - return org.eclipse.jpt.core.resource.orm.FetchType.LAZY; - default: - throw new IllegalArgumentException("unknown fetch type: " + fetchType); //$NON-NLS-1$ - } + return (fetchType == null) ? null : fetchType.getOrmFetchType(); } } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/GenerationType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/GenerationType.java index 7bc0b18680..7dd63677d0 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/GenerationType.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/GenerationType.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 Oracle. All rights reserved. + * Copyright (c) 2005, 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. @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.context; /** - * + * Generation Type * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -20,81 +20,81 @@ package org.eclipse.jpt.core.context; */ public enum GenerationType { - TABLE, - SEQUENCE, - IDENTITY, - AUTO; - + TABLE( + org.eclipse.jpt.core.resource.java.GenerationType.TABLE, + org.eclipse.jpt.core.resource.orm.GenerationType.TABLE + ), + SEQUENCE( + org.eclipse.jpt.core.resource.java.GenerationType.SEQUENCE, + org.eclipse.jpt.core.resource.orm.GenerationType.SEQUENCE + ), + IDENTITY( + org.eclipse.jpt.core.resource.java.GenerationType.IDENTITY, + org.eclipse.jpt.core.resource.orm.GenerationType.IDENTITY + ), + AUTO( + org.eclipse.jpt.core.resource.java.GenerationType.AUTO, + org.eclipse.jpt.core.resource.orm.GenerationType.AUTO + ); - public static GenerationType fromJavaResourceModel(org.eclipse.jpt.core.resource.java.GenerationType javaGenerationType) { + + private org.eclipse.jpt.core.resource.java.GenerationType javaGenerationType; + private org.eclipse.jpt.core.resource.orm.GenerationType ormGenerationType; + + GenerationType(org.eclipse.jpt.core.resource.java.GenerationType javaGenerationType, org.eclipse.jpt.core.resource.orm.GenerationType ormGenerationType) { if (javaGenerationType == null) { - return null; + throw new NullPointerException(); } - switch (javaGenerationType) { - case TABLE: - return TABLE; - case SEQUENCE: - return SEQUENCE; - case IDENTITY: - return IDENTITY; - case AUTO: - return AUTO; - default: - throw new IllegalArgumentException("unknown generation type: " + javaGenerationType); //$NON-NLS-1$ + if (ormGenerationType == null) { + throw new NullPointerException(); } + this.javaGenerationType = javaGenerationType; + this.ormGenerationType = ormGenerationType; } - - public static org.eclipse.jpt.core.resource.java.GenerationType toJavaResourceModel(GenerationType generationType) { - if (generationType == null) { - return null; - } - switch (generationType) { - case TABLE: - return org.eclipse.jpt.core.resource.java.GenerationType.TABLE; - case SEQUENCE: - return org.eclipse.jpt.core.resource.java.GenerationType.SEQUENCE; - case IDENTITY: - return org.eclipse.jpt.core.resource.java.GenerationType.IDENTITY; - case AUTO: - return org.eclipse.jpt.core.resource.java.GenerationType.AUTO; - default: - throw new IllegalArgumentException("unknown generation type: " + generationType); //$NON-NLS-1$ + + public org.eclipse.jpt.core.resource.java.GenerationType getJavaGenerationType() { + return this.javaGenerationType; + } + + public org.eclipse.jpt.core.resource.orm.GenerationType getOrmGenerationType() { + return this.ormGenerationType; + } + + + // ********** static methods ********** + + public static GenerationType fromJavaResourceModel(org.eclipse.jpt.core.resource.java.GenerationType javaGenerationType) { + return (javaGenerationType == null) ? null : fromJavaResourceModel_(javaGenerationType); + } + + private static GenerationType fromJavaResourceModel_(org.eclipse.jpt.core.resource.java.GenerationType javaGenerationType) { + for (GenerationType generationType : GenerationType.values()) { + if (generationType.getJavaGenerationType() == javaGenerationType) { + return generationType; + } } + return null; + } + + public static org.eclipse.jpt.core.resource.java.GenerationType toJavaResourceModel(GenerationType generationType) { + return (generationType == null) ? null : generationType.getJavaGenerationType(); } public static GenerationType fromOrmResourceModel(org.eclipse.jpt.core.resource.orm.GenerationType ormGenerationType) { - if (ormGenerationType == null) { - return null; - } - switch (ormGenerationType) { - case TABLE: - return TABLE; - case SEQUENCE: - return SEQUENCE; - case IDENTITY: - return IDENTITY; - case AUTO: - return AUTO; - default: - throw new IllegalArgumentException("unknown generation type: " + ormGenerationType); //$NON-NLS-1$ + return (ormGenerationType == null) ? null : fromOrmResourceModel_(ormGenerationType); + } + + private static GenerationType fromOrmResourceModel_(org.eclipse.jpt.core.resource.orm.GenerationType ormGenerationType) { + for (GenerationType generationType : GenerationType.values()) { + if (generationType.getOrmGenerationType() == ormGenerationType) { + return generationType; + } } + return null; } - + public static org.eclipse.jpt.core.resource.orm.GenerationType toOrmResourceModel(GenerationType generationType) { - if (generationType == null) { - return null; - } - switch (generationType) { - case TABLE: - return org.eclipse.jpt.core.resource.orm.GenerationType.TABLE; - case SEQUENCE: - return org.eclipse.jpt.core.resource.orm.GenerationType.SEQUENCE; - case IDENTITY: - return org.eclipse.jpt.core.resource.orm.GenerationType.IDENTITY; - case AUTO: - return org.eclipse.jpt.core.resource.orm.GenerationType.AUTO; - default: - throw new IllegalArgumentException("unknown generation type: " + generationType); //$NON-NLS-1$ - } + return (generationType == null) ? null : generationType.getOrmGenerationType(); } + } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/InheritanceType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/InheritanceType.java index 69bfe0a1b1..f8c8628266 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/InheritanceType.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/InheritanceType.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 Oracle. All rights reserved. + * Copyright (c) 2005, 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. @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.context; /** - * + * Inheritance Type * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -20,74 +20,77 @@ package org.eclipse.jpt.core.context; */ public enum InheritanceType { + SINGLE_TABLE( + org.eclipse.jpt.core.resource.java.InheritanceType.SINGLE_TABLE, + org.eclipse.jpt.core.resource.orm.InheritanceType.SINGLE_TABLE + ), + JOINED( + org.eclipse.jpt.core.resource.java.InheritanceType.JOINED, + org.eclipse.jpt.core.resource.orm.InheritanceType.JOINED + ), + TABLE_PER_CLASS( + org.eclipse.jpt.core.resource.java.InheritanceType.TABLE_PER_CLASS, + org.eclipse.jpt.core.resource.orm.InheritanceType.TABLE_PER_CLASS + ); - SINGLE_TABLE, - JOINED, - TABLE_PER_CLASS; + private org.eclipse.jpt.core.resource.java.InheritanceType javaInheritanceType; + private org.eclipse.jpt.core.resource.orm.InheritanceType ormInheritanceType; - public static InheritanceType fromJavaResourceModel(org.eclipse.jpt.core.resource.java.InheritanceType javaInheritanceType) { + InheritanceType(org.eclipse.jpt.core.resource.java.InheritanceType javaInheritanceType, org.eclipse.jpt.core.resource.orm.InheritanceType ormInheritanceType) { if (javaInheritanceType == null) { - return null; + throw new NullPointerException(); } - switch (javaInheritanceType) { - case SINGLE_TABLE: - return SINGLE_TABLE; - case JOINED: - return JOINED; - case TABLE_PER_CLASS: - return TABLE_PER_CLASS; - default: - throw new IllegalArgumentException("unknown inheritance type: " + javaInheritanceType); //$NON-NLS-1$ + if (ormInheritanceType == null) { + throw new NullPointerException(); } + this.javaInheritanceType = javaInheritanceType; + this.ormInheritanceType = ormInheritanceType; } - - public static org.eclipse.jpt.core.resource.java.InheritanceType toJavaResourceModel(InheritanceType inheritanceType) { - if (inheritanceType == null) { - return null; - } - switch (inheritanceType) { - case SINGLE_TABLE: - return org.eclipse.jpt.core.resource.java.InheritanceType.SINGLE_TABLE; - case JOINED: - return org.eclipse.jpt.core.resource.java.InheritanceType.JOINED; - case TABLE_PER_CLASS: - return org.eclipse.jpt.core.resource.java.InheritanceType.TABLE_PER_CLASS; - default: - throw new IllegalArgumentException("unknown inheritance type: " + inheritanceType); //$NON-NLS-1$ + + public org.eclipse.jpt.core.resource.java.InheritanceType getJavaInheritanceType() { + return this.javaInheritanceType; + } + + public org.eclipse.jpt.core.resource.orm.InheritanceType getOrmInheritanceType() { + return this.ormInheritanceType; + } + + + // ********** static methods ********** + + public static InheritanceType fromJavaResourceModel(org.eclipse.jpt.core.resource.java.InheritanceType javaInheritanceType) { + return (javaInheritanceType == null) ? null : fromJavaResourceModel_(javaInheritanceType); + } + + private static InheritanceType fromJavaResourceModel_(org.eclipse.jpt.core.resource.java.InheritanceType javaInheritanceType) { + for (InheritanceType inheritanceType : InheritanceType.values()) { + if (inheritanceType.getJavaInheritanceType() == javaInheritanceType) { + return inheritanceType; + } } + return null; + } + + public static org.eclipse.jpt.core.resource.java.InheritanceType toJavaResourceModel(InheritanceType inheritanceType) { + return (inheritanceType == null) ? null : inheritanceType.getJavaInheritanceType(); } - public static InheritanceType fromOrmResourceModel(org.eclipse.jpt.core.resource.orm.InheritanceType ormInheritanceType) { - if (ormInheritanceType == null) { - return null; - } - switch (ormInheritanceType) { - case SINGLE_TABLE: - return SINGLE_TABLE; - case JOINED: - return JOINED; - case TABLE_PER_CLASS: - return TABLE_PER_CLASS; - default: - throw new IllegalArgumentException("unknown inheritance type: " + ormInheritanceType); //$NON-NLS-1$ + return (ormInheritanceType == null) ? null : fromOrmResourceModel_(ormInheritanceType); + } + + private static InheritanceType fromOrmResourceModel_(org.eclipse.jpt.core.resource.orm.InheritanceType ormInheritanceType) { + for (InheritanceType inheritanceType : InheritanceType.values()) { + if (inheritanceType.getOrmInheritanceType() == ormInheritanceType) { + return inheritanceType; + } } + return null; } - + public static org.eclipse.jpt.core.resource.orm.InheritanceType toOrmResourceModel(InheritanceType inheritanceType) { - if (inheritanceType == null) { - return null; - } - switch (inheritanceType) { - case SINGLE_TABLE: - return org.eclipse.jpt.core.resource.orm.InheritanceType.SINGLE_TABLE; - case JOINED: - return org.eclipse.jpt.core.resource.orm.InheritanceType.JOINED; - case TABLE_PER_CLASS: - return org.eclipse.jpt.core.resource.orm.InheritanceType.TABLE_PER_CLASS; - default: - throw new IllegalArgumentException("unknown inheritance type: " + inheritanceType); //$NON-NLS-1$ - } + return (inheritanceType == null) ? null : inheritanceType.getOrmInheritanceType(); } + } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/TemporalType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/TemporalType.java index ad9dba57dc..c6eee8d370 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/TemporalType.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/TemporalType.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 Oracle. All rights reserved. + * Copyright (c) 2005, 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. @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.context; /** - * + * Temporal Type * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -20,74 +20,77 @@ package org.eclipse.jpt.core.context; */ public enum TemporalType { - DATE, - TIME, - TIMESTAMP; - + DATE( + org.eclipse.jpt.core.resource.java.TemporalType.DATE, + org.eclipse.jpt.core.resource.orm.TemporalType.DATE + ), + TIME( + org.eclipse.jpt.core.resource.java.TemporalType.TIME, + org.eclipse.jpt.core.resource.orm.TemporalType.TIME + ), + TIMESTAMP( + org.eclipse.jpt.core.resource.java.TemporalType.TIMESTAMP, + org.eclipse.jpt.core.resource.orm.TemporalType.TIMESTAMP + ); - public static TemporalType fromJavaResourceModel(org.eclipse.jpt.core.resource.java.TemporalType javaTemporalType) { + + private org.eclipse.jpt.core.resource.java.TemporalType javaTemporalType; + private org.eclipse.jpt.core.resource.orm.TemporalType ormTemporalType; + + TemporalType(org.eclipse.jpt.core.resource.java.TemporalType javaTemporalType, org.eclipse.jpt.core.resource.orm.TemporalType ormTemporalType) { if (javaTemporalType == null) { - return null; + throw new NullPointerException(); } - switch (javaTemporalType) { - case DATE: - return DATE; - case TIME: - return TIME; - case TIMESTAMP: - return TIMESTAMP; - default: - throw new IllegalArgumentException("unknown temporal type: " + javaTemporalType); //$NON-NLS-1$ + if (ormTemporalType == null) { + throw new NullPointerException(); } + this.javaTemporalType = javaTemporalType; + this.ormTemporalType = ormTemporalType; } - - public static org.eclipse.jpt.core.resource.java.TemporalType toJavaResourceModel(TemporalType temporalType) { - if (temporalType == null) { - return null; - } - switch (temporalType) { - case DATE: - return org.eclipse.jpt.core.resource.java.TemporalType.DATE; - case TIME: - return org.eclipse.jpt.core.resource.java.TemporalType.TIME; - case TIMESTAMP: - return org.eclipse.jpt.core.resource.java.TemporalType.TIMESTAMP; - default: - throw new IllegalArgumentException("unknown temporal type: " + temporalType); //$NON-NLS-1$ + + public org.eclipse.jpt.core.resource.java.TemporalType getJavaTemporalType() { + return this.javaTemporalType; + } + + public org.eclipse.jpt.core.resource.orm.TemporalType getOrmTemporalType() { + return this.ormTemporalType; + } + + + // ********** static methods ********** + + public static TemporalType fromJavaResourceModel(org.eclipse.jpt.core.resource.java.TemporalType javaTemporalType) { + return (javaTemporalType == null) ? null : fromJavaResourceModel_(javaTemporalType); + } + + private static TemporalType fromJavaResourceModel_(org.eclipse.jpt.core.resource.java.TemporalType javaTemporalType) { + for (TemporalType temporalType : TemporalType.values()) { + if (temporalType.getJavaTemporalType() == javaTemporalType) { + return temporalType; + } } + return null; + } + + public static org.eclipse.jpt.core.resource.java.TemporalType toJavaResourceModel(TemporalType temporalType) { + return (temporalType == null) ? null : temporalType.getJavaTemporalType(); } - public static TemporalType fromOrmResourceModel(org.eclipse.jpt.core.resource.orm.TemporalType ormTemporalType) { - if (ormTemporalType == null) { - return null; - } - switch (ormTemporalType) { - case DATE: - return DATE; - case TIME: - return TIME; - case TIMESTAMP: - return TIMESTAMP; - default: - throw new IllegalArgumentException("unknown temporal type: " + ormTemporalType); //$NON-NLS-1$ + return (ormTemporalType == null) ? null : fromOrmResourceModel_(ormTemporalType); + } + + private static TemporalType fromOrmResourceModel_(org.eclipse.jpt.core.resource.orm.TemporalType ormTemporalType) { + for (TemporalType temporalType : TemporalType.values()) { + if (temporalType.getOrmTemporalType() == ormTemporalType) { + return temporalType; + } } + return null; } - + public static org.eclipse.jpt.core.resource.orm.TemporalType toOrmResourceModel(TemporalType temporalType) { - if (temporalType == null) { - return null; - } - switch (temporalType) { - case DATE: - return org.eclipse.jpt.core.resource.orm.TemporalType.DATE; - case TIME: - return org.eclipse.jpt.core.resource.orm.TemporalType.TIME; - case TIMESTAMP: - return org.eclipse.jpt.core.resource.orm.TemporalType.TIMESTAMP; - default: - throw new IllegalArgumentException("unknown temporal type: " + temporalType); //$NON-NLS-1$ - } + return (temporalType == null) ? null : temporalType.getOrmTemporalType(); } } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/AccessType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/AccessType.java index be392455a7..80393e0fd0 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/AccessType.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/AccessType.java @@ -10,7 +10,8 @@ package org.eclipse.jpt.core.resource.java; /** - * + * Corresponds to the JPA 2.0 enum + * javax.persistence.AccessType * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -20,33 +21,41 @@ package org.eclipse.jpt.core.resource.java; */ public enum AccessType { - PROPERTY, - FIELD; - - public static AccessType fromJavaAnnotationValue(Object javaAnnotationValue) { + FIELD(JPA.ACCESS_TYPE__FIELD), + PROPERTY(JPA.ACCESS_TYPE__PROPERTY); + + + private String javaAnnotationValue; + + AccessType(String javaAnnotationValue) { if (javaAnnotationValue == null) { - return null; + throw new NullPointerException(); } - if (javaAnnotationValue.equals(JPA.ACCESS_TYPE__FIELD)) { - return FIELD; - } - if (javaAnnotationValue.equals(JPA.ACCESS_TYPE__PROPERTY)) { - return PROPERTY; + this.javaAnnotationValue = javaAnnotationValue; + } + + public String getJavaAnnotationValue() { + return this.javaAnnotationValue; + } + + + // ********** static methods ********** + + public static AccessType fromJavaAnnotationValue(Object javaAnnotationValue) { + return (javaAnnotationValue == null) ? null : fromJavaAnnotationValue_(javaAnnotationValue); + } + + private static AccessType fromJavaAnnotationValue_(Object javaAnnotationValue) { + for (AccessType accessType : AccessType.values()) { + if (accessType.getJavaAnnotationValue().equals(javaAnnotationValue)) { + return accessType; + } } return null; } public static String toJavaAnnotationValue(AccessType accessType) { - if (accessType == null) { - return null; - } - switch (accessType) { - case FIELD : - return JPA.ACCESS_TYPE__FIELD; - case PROPERTY : - return JPA.ACCESS_TYPE__PROPERTY; - default : - throw new IllegalArgumentException("unknown access type: " + accessType); //$NON-NLS-1$ - } + return (accessType == null) ? null : accessType.getJavaAnnotationValue(); } + } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/DiscriminatorType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/DiscriminatorType.java index 860d684667..20136b2c6a 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/DiscriminatorType.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/DiscriminatorType.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -10,7 +10,8 @@ package org.eclipse.jpt.core.resource.java; /** - * + * Corresponds to the JPA enum + * javax.persistence.DiscriminatorType * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -19,41 +20,43 @@ package org.eclipse.jpt.core.resource.java; * will almost certainly be broken (repeatedly) as the API evolves. */ public enum DiscriminatorType { - - STRING, - CHAR, - INTEGER; - - - public static DiscriminatorType fromJavaAnnotationValue(Object javaAnnotationValue) { + + STRING(JPA.DISCRIMINATOR_TYPE__STRING), + CHAR(JPA.DISCRIMINATOR_TYPE__CHAR), + INTEGER(JPA.DISCRIMINATOR_TYPE__INTEGER); + + + private String javaAnnotationValue; + + DiscriminatorType(String javaAnnotationValue) { if (javaAnnotationValue == null) { - return null; - } - if (javaAnnotationValue.equals(JPA.DISCRIMINATOR_TYPE__STRING)) { - return STRING; - } - if (javaAnnotationValue.equals(JPA.DISCRIMINATOR_TYPE__CHAR)) { - return CHAR; + throw new NullPointerException(); } - if (javaAnnotationValue.equals(JPA.DISCRIMINATOR_TYPE__INTEGER)) { - return INTEGER; + this.javaAnnotationValue = javaAnnotationValue; + } + + public String getJavaAnnotationValue() { + return this.javaAnnotationValue; + } + + + // ********** static methods ********** + + public static DiscriminatorType fromJavaAnnotationValue(Object javaAnnotationValue) { + return (javaAnnotationValue == null) ? null : fromJavaAnnotationValue_(javaAnnotationValue); + } + + private static DiscriminatorType fromJavaAnnotationValue_(Object javaAnnotationValue) { + for (DiscriminatorType discriminatorType : DiscriminatorType.values()) { + if (discriminatorType.getJavaAnnotationValue().equals(javaAnnotationValue)) { + return discriminatorType; + } } return null; } public static String toJavaAnnotationValue(DiscriminatorType discriminatorType) { - if (discriminatorType == null) { - return null; - } - switch (discriminatorType) { - case STRING : - return JPA.DISCRIMINATOR_TYPE__STRING; - case CHAR : - return JPA.DISCRIMINATOR_TYPE__CHAR; - case INTEGER : - return JPA.DISCRIMINATOR_TYPE__INTEGER; - default : - throw new IllegalArgumentException("unknown discriminator type: " + discriminatorType); //$NON-NLS-1$ - } + return (discriminatorType == null) ? null : discriminatorType.getJavaAnnotationValue(); } + } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/EnumType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/EnumType.java index 9d3f5a2def..e99073bd8c 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/EnumType.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/EnumType.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -10,7 +10,8 @@ package org.eclipse.jpt.core.resource.java; /** - * + * Corresponds to the JPA enum + * javax.persistence.EnumType * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -19,35 +20,42 @@ package org.eclipse.jpt.core.resource.java; * will almost certainly be broken (repeatedly) as the API evolves. */ public enum EnumType { - - ORDINAL, - STRING; - - - public static EnumType fromJavaAnnotationValue(Object javaAnnotationValue) { + + ORDINAL(JPA.ENUM_TYPE__ORDINAL), + STRING(JPA.ENUM_TYPE__STRING); + + + private String javaAnnotationValue; + + EnumType(String javaAnnotationValue) { if (javaAnnotationValue == null) { - return null; - } - if (javaAnnotationValue.equals(JPA.ENUM_TYPE__ORDINAL)) { - return ORDINAL; + throw new NullPointerException(); } - if (javaAnnotationValue.equals(JPA.ENUM_TYPE__STRING)) { - return STRING; + this.javaAnnotationValue = javaAnnotationValue; + } + + public String getJavaAnnotationValue() { + return this.javaAnnotationValue; + } + + + // ********** static methods ********** + + public static EnumType fromJavaAnnotationValue(Object javaAnnotationValue) { + return (javaAnnotationValue == null) ? null : fromJavaAnnotationValue_(javaAnnotationValue); + } + + private static EnumType fromJavaAnnotationValue_(Object javaAnnotationValue) { + for (EnumType enumType : EnumType.values()) { + if (enumType.getJavaAnnotationValue().equals(javaAnnotationValue)) { + return enumType; + } } return null; } public static String toJavaAnnotationValue(EnumType enumType) { - if (enumType == null) { - return null; - } - switch (enumType) { - case ORDINAL : - return JPA.ENUM_TYPE__ORDINAL; - case STRING : - return JPA.ENUM_TYPE__STRING; - default : - throw new IllegalArgumentException("unknown enum type: " + enumType); //$NON-NLS-1$ - } + return (enumType == null) ? null : enumType.getJavaAnnotationValue(); } + } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/FetchType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/FetchType.java index c15d50180b..99328a60da 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/FetchType.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/FetchType.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -10,7 +10,8 @@ package org.eclipse.jpt.core.resource.java; /** - * + * Corresponds to the JPA enum + * javax.persistence.FetchType * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -19,35 +20,42 @@ package org.eclipse.jpt.core.resource.java; * will almost certainly be broken (repeatedly) as the API evolves. */ public enum FetchType { - - EAGER, - LAZY; - - - public static FetchType fromJavaAnnotationValue(Object javaAnnotationValue) { + + EAGER(JPA.FETCH_TYPE__EAGER), + LAZY(JPA.FETCH_TYPE__LAZY); + + + private String javaAnnotationValue; + + FetchType(String javaAnnotationValue) { if (javaAnnotationValue == null) { - return null; - } - if (javaAnnotationValue.equals(JPA.FETCH_TYPE__EAGER)) { - return EAGER; + throw new NullPointerException(); } - if (javaAnnotationValue.equals(JPA.FETCH_TYPE__LAZY)) { - return LAZY; + this.javaAnnotationValue = javaAnnotationValue; + } + + public String getJavaAnnotationValue() { + return this.javaAnnotationValue; + } + + + // ********** static methods ********** + + public static FetchType fromJavaAnnotationValue(Object javaAnnotationValue) { + return (javaAnnotationValue == null) ? null : fromJavaAnnotationValue_(javaAnnotationValue); + } + + private static FetchType fromJavaAnnotationValue_(Object javaAnnotationValue) { + for (FetchType fetchType : FetchType.values()) { + if (fetchType.getJavaAnnotationValue().equals(javaAnnotationValue)) { + return fetchType; + } } return null; } public static String toJavaAnnotationValue(FetchType fetchType) { - if (fetchType == null) { - return null; - } - switch (fetchType) { - case EAGER : - return JPA.FETCH_TYPE__EAGER; - case LAZY : - return JPA.FETCH_TYPE__LAZY; - default : - throw new IllegalArgumentException("unknown fetch type: " + fetchType); //$NON-NLS-1$ - } + return (fetchType == null) ? null : fetchType.getJavaAnnotationValue(); } + } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/GenerationType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/GenerationType.java index cea3df9d98..be5ffe6c05 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/GenerationType.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/GenerationType.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -10,7 +10,8 @@ package org.eclipse.jpt.core.resource.java; /** - * + * Corresponds to the JPA enum + * javax.persistence.GenerationType * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -19,47 +20,44 @@ package org.eclipse.jpt.core.resource.java; * will almost certainly be broken (repeatedly) as the API evolves. */ public enum GenerationType { - - TABLE, - SEQUENCE, - IDENTITY, - AUTO; - - - public static GenerationType fromJavaAnnotationValue(Object javaAnnotationValue) { + + TABLE(JPA.GENERATION_TYPE__TABLE), + SEQUENCE(JPA.GENERATION_TYPE__SEQUENCE), + IDENTITY(JPA.GENERATION_TYPE__IDENTITY), + AUTO(JPA.GENERATION_TYPE__AUTO); + + + private String javaAnnotationValue; + + GenerationType(String javaAnnotationValue) { if (javaAnnotationValue == null) { - return null; + throw new NullPointerException(); } - if (javaAnnotationValue.equals(JPA.GENERATION_TYPE__TABLE)) { - return TABLE; - } - if (javaAnnotationValue.equals(JPA.GENERATION_TYPE__SEQUENCE)) { - return SEQUENCE; - } - if (javaAnnotationValue.equals(JPA.GENERATION_TYPE__IDENTITY)) { - return IDENTITY; - } - if (javaAnnotationValue.equals(JPA.GENERATION_TYPE__AUTO)) { - return AUTO; + this.javaAnnotationValue = javaAnnotationValue; + } + + public String getJavaAnnotationValue() { + return this.javaAnnotationValue; + } + + + // ********** static methods ********** + + public static GenerationType fromJavaAnnotationValue(Object javaAnnotationValue) { + return (javaAnnotationValue == null) ? null : fromJavaAnnotationValue_(javaAnnotationValue); + } + + private static GenerationType fromJavaAnnotationValue_(Object javaAnnotationValue) { + for (GenerationType generationType : GenerationType.values()) { + if (generationType.getJavaAnnotationValue().equals(javaAnnotationValue)) { + return generationType; + } } return null; } public static String toJavaAnnotationValue(GenerationType generationType) { - if (generationType == null) { - return null; - } - switch (generationType) { - case TABLE : - return JPA.GENERATION_TYPE__TABLE; - case SEQUENCE : - return JPA.GENERATION_TYPE__SEQUENCE; - case IDENTITY : - return JPA.GENERATION_TYPE__IDENTITY; - case AUTO : - return JPA.GENERATION_TYPE__AUTO; - default : - throw new IllegalArgumentException("unknown generation type: " + generationType); //$NON-NLS-1$ - } + return (generationType == null) ? null : generationType.getJavaAnnotationValue(); } + } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/InheritanceType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/InheritanceType.java index ff7bf095d9..d055388139 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/InheritanceType.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/InheritanceType.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -10,7 +10,8 @@ package org.eclipse.jpt.core.resource.java; /** - * + * Corresponds to the JPA enum + * javax.persistence.InheritanceType * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -19,41 +20,43 @@ package org.eclipse.jpt.core.resource.java; * will almost certainly be broken (repeatedly) as the API evolves. */ public enum InheritanceType { - - SINGLE_TABLE, - JOINED, - TABLE_PER_CLASS; - - - public static InheritanceType fromJavaAnnotationValue(Object javaAnnotationValue) { + + SINGLE_TABLE(JPA.INHERITANCE_TYPE__SINGLE_TABLE), + JOINED(JPA.INHERITANCE_TYPE__JOINED), + TABLE_PER_CLASS(JPA.INHERITANCE_TYPE__TABLE_PER_CLASS); + + + private String javaAnnotationValue; + + InheritanceType(String javaAnnotationValue) { if (javaAnnotationValue == null) { - return null; - } - if (javaAnnotationValue.equals(JPA.INHERITANCE_TYPE__SINGLE_TABLE)) { - return SINGLE_TABLE; - } - if (javaAnnotationValue.equals(JPA.INHERITANCE_TYPE__JOINED)) { - return JOINED; + throw new NullPointerException(); } - if (javaAnnotationValue.equals(JPA.INHERITANCE_TYPE__TABLE_PER_CLASS)) { - return TABLE_PER_CLASS; + this.javaAnnotationValue = javaAnnotationValue; + } + + public String getJavaAnnotationValue() { + return this.javaAnnotationValue; + } + + + // ********** static methods ********** + + public static InheritanceType fromJavaAnnotationValue(Object javaAnnotationValue) { + return (javaAnnotationValue == null) ? null : fromJavaAnnotationValue_(javaAnnotationValue); + } + + private static InheritanceType fromJavaAnnotationValue_(Object javaAnnotationValue) { + for (InheritanceType inheritanceType : InheritanceType.values()) { + if (inheritanceType.getJavaAnnotationValue().equals(javaAnnotationValue)) { + return inheritanceType; + } } return null; } public static String toJavaAnnotationValue(InheritanceType inheritanceType) { - if (inheritanceType == null) { - return null; - } - switch (inheritanceType) { - case SINGLE_TABLE : - return JPA.INHERITANCE_TYPE__SINGLE_TABLE; - case JOINED : - return JPA.INHERITANCE_TYPE__JOINED; - case TABLE_PER_CLASS : - return JPA.INHERITANCE_TYPE__TABLE_PER_CLASS; - default : - throw new IllegalArgumentException("unknown inheritance type: " + inheritanceType); //$NON-NLS-1$ - } + return (inheritanceType == null) ? null : inheritanceType.getJavaAnnotationValue(); } + } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/TemporalType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/TemporalType.java index 9377010fe9..2a85b00d68 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/TemporalType.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/TemporalType.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -10,7 +10,8 @@ package org.eclipse.jpt.core.resource.java; /** - * + * Corresponds to the JPA enum + * javax.persistence.TemporalType * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -19,41 +20,43 @@ package org.eclipse.jpt.core.resource.java; * will almost certainly be broken (repeatedly) as the API evolves. */ public enum TemporalType { - - DATE, - TIME, - TIMESTAMP; - - - public static TemporalType fromJavaAnnotationValue(Object javaAnnotationValue) { + + DATE(JPA.TEMPORAL_TYPE__DATE), + TIME(JPA.TEMPORAL_TYPE__TIME), + TIMESTAMP(JPA.TEMPORAL_TYPE__TIMESTAMP); + + + private String javaAnnotationValue; + + TemporalType(String javaAnnotationValue) { if (javaAnnotationValue == null) { - return null; - } - if (javaAnnotationValue.equals(JPA.TEMPORAL_TYPE__DATE)) { - return DATE; - } - if (javaAnnotationValue.equals(JPA.TEMPORAL_TYPE__TIME)) { - return TIME; + throw new NullPointerException(); } - if (javaAnnotationValue.equals(JPA.TEMPORAL_TYPE__TIMESTAMP)) { - return TIMESTAMP; + this.javaAnnotationValue = javaAnnotationValue; + } + + public String getJavaAnnotationValue() { + return this.javaAnnotationValue; + } + + + // ********** static methods ********** + + public static TemporalType fromJavaAnnotationValue(Object javaAnnotationValue) { + return (javaAnnotationValue == null) ? null : fromJavaAnnotationValue_(javaAnnotationValue); + } + + private static TemporalType fromJavaAnnotationValue_(Object javaAnnotationValue) { + for (TemporalType temporalType : TemporalType.values()) { + if (temporalType.getJavaAnnotationValue().equals(javaAnnotationValue)) { + return temporalType; + } } return null; } public static String toJavaAnnotationValue(TemporalType temporalType) { - if (temporalType == null) { - return null; - } - switch (temporalType) { - case DATE : - return JPA.TEMPORAL_TYPE__DATE; - case TIME : - return JPA.TEMPORAL_TYPE__TIME; - case TIMESTAMP : - return JPA.TEMPORAL_TYPE__TIMESTAMP; - default : - throw new IllegalArgumentException("unknown temporal type: " + temporalType); //$NON-NLS-1$ - } + return (temporalType == null) ? null : temporalType.getJavaAnnotationValue(); } + } diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/CacheCoordinationType.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/CacheCoordinationType.java index 6a3ed5204c..a7a8bdfdb8 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/CacheCoordinationType.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/CacheCoordinationType.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Oracle. All rights reserved. + * 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. @@ -10,6 +10,8 @@ package org.eclipse.jpt.eclipselink.core.resource.java; /** + * Corresponds to the EclipseLink enum + * org.eclipse.persistence.annotations.CacheCoordinationType * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -21,46 +23,44 @@ package org.eclipse.jpt.eclipselink.core.resource.java; * @since 2.1 */ public enum CacheCoordinationType { - - SEND_OBJECT_CHANGES, - INVALIDATE_CHANGED_OBJECTS, - SEND_NEW_OBJECTS_WITH_CHANGES, - NONE; - - public static CacheCoordinationType fromJavaAnnotationValue(Object javaAnnotationValue) { + + SEND_OBJECT_CHANGES(EclipseLinkJPA.CACHE_COORDINATION_TYPE__SEND_OBJECT_CHANGES), + INVALIDATE_CHANGED_OBJECTS(EclipseLinkJPA.CACHE_COORDINATION_TYPE__INVALIDATE_CHANGED_OBJECTS), + SEND_NEW_OBJECTS_WITH_CHANGES(EclipseLinkJPA.CACHE_COORDINATION_TYPE__SEND_NEW_OBJECTS_WITH_CHANGES), + NONE(EclipseLinkJPA.CACHE_COORDINATION_TYPE__NONE); + + + private String javaAnnotationValue; + + CacheCoordinationType(String javaAnnotationValue) { if (javaAnnotationValue == null) { - return null; + throw new NullPointerException(); } - if (javaAnnotationValue.equals(EclipseLinkJPA.CACHE_COORDINATION_TYPE__SEND_OBJECT_CHANGES)) { - return SEND_OBJECT_CHANGES; - } - if (javaAnnotationValue.equals(EclipseLinkJPA.CACHE_COORDINATION_TYPE__INVALIDATE_CHANGED_OBJECTS)) { - return INVALIDATE_CHANGED_OBJECTS; - } - if (javaAnnotationValue.equals(EclipseLinkJPA.CACHE_COORDINATION_TYPE__SEND_NEW_OBJECTS_WITH_CHANGES)) { - return SEND_NEW_OBJECTS_WITH_CHANGES; - } - if (javaAnnotationValue.equals(EclipseLinkJPA.CACHE_COORDINATION_TYPE__NONE)) { - return NONE; + this.javaAnnotationValue = javaAnnotationValue; + } + + public String getJavaAnnotationValue() { + return this.javaAnnotationValue; + } + + + // ********** static methods ********** + + public static CacheCoordinationType fromJavaAnnotationValue(Object javaAnnotationValue) { + return (javaAnnotationValue == null) ? null : fromJavaAnnotationValue_(javaAnnotationValue); + } + + private static CacheCoordinationType fromJavaAnnotationValue_(Object javaAnnotationValue) { + for (CacheCoordinationType cacheCoordinationType : CacheCoordinationType.values()) { + if (cacheCoordinationType.getJavaAnnotationValue().equals(javaAnnotationValue)) { + return cacheCoordinationType; + } } return null; } public static String toJavaAnnotationValue(CacheCoordinationType cacheCoordinationType) { - if (cacheCoordinationType == null) { - return null; - } - switch (cacheCoordinationType) { - case SEND_OBJECT_CHANGES : - return EclipseLinkJPA.CACHE_COORDINATION_TYPE__SEND_OBJECT_CHANGES; - case INVALIDATE_CHANGED_OBJECTS : - return EclipseLinkJPA.CACHE_COORDINATION_TYPE__INVALIDATE_CHANGED_OBJECTS; - case SEND_NEW_OBJECTS_WITH_CHANGES : - return EclipseLinkJPA.CACHE_COORDINATION_TYPE__SEND_NEW_OBJECTS_WITH_CHANGES; - case NONE : - return EclipseLinkJPA.CACHE_COORDINATION_TYPE__NONE; - default : - throw new IllegalArgumentException("unknown cache coordination type: " + cacheCoordinationType); //$NON-NLS-1$ - } + return (cacheCoordinationType == null) ? null : cacheCoordinationType.getJavaAnnotationValue(); } + } diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/CacheType.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/CacheType.java index bf0e43708d..d569be1fc1 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/CacheType.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/CacheType.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Oracle. All rights reserved. + * 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. @@ -10,6 +10,8 @@ package org.eclipse.jpt.eclipselink.core.resource.java; /** + * Corresponds to the EclipseLink enum + * org.eclipse.persistence.annotations.CacheType * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -21,65 +23,47 @@ package org.eclipse.jpt.eclipselink.core.resource.java; * @since 2.1 */ public enum CacheType { - - FULL, - WEAK, - SOFT, - SOFT_WEAK, - HARD_WEAK, - CACHE, - NONE; - - - public static CacheType fromJavaAnnotationValue(Object javaAnnotationValue) { + + FULL(EclipseLinkJPA.CACHE_TYPE__FULL), + WEAK(EclipseLinkJPA.CACHE_TYPE__WEAK), + SOFT(EclipseLinkJPA.CACHE_TYPE__SOFT), + SOFT_WEAK(EclipseLinkJPA.CACHE_TYPE__SOFT_WEAK), + HARD_WEAK(EclipseLinkJPA.CACHE_TYPE__HARD_WEAK), + CACHE(EclipseLinkJPA.CACHE_TYPE__CACHE), + NONE(EclipseLinkJPA.CACHE_TYPE__NONE); + + + private String javaAnnotationValue; + + CacheType(String javaAnnotationValue) { if (javaAnnotationValue == null) { - return null; - } - if (javaAnnotationValue.equals(EclipseLinkJPA.CACHE_TYPE__FULL)) { - return FULL; + throw new NullPointerException(); } - if (javaAnnotationValue.equals(EclipseLinkJPA.CACHE_TYPE__WEAK)) { - return WEAK; - } - if (javaAnnotationValue.equals(EclipseLinkJPA.CACHE_TYPE__SOFT)) { - return SOFT; - } - if (javaAnnotationValue.equals(EclipseLinkJPA.CACHE_TYPE__SOFT_WEAK)) { - return SOFT_WEAK; - } - if (javaAnnotationValue.equals(EclipseLinkJPA.CACHE_TYPE__HARD_WEAK)) { - return HARD_WEAK; - } - if (javaAnnotationValue.equals(EclipseLinkJPA.CACHE_TYPE__CACHE)) { - return CACHE; - } - if (javaAnnotationValue.equals(EclipseLinkJPA.CACHE_TYPE__NONE)) { - return NONE; + this.javaAnnotationValue = javaAnnotationValue; + } + + public String getJavaAnnotationValue() { + return this.javaAnnotationValue; + } + + + // ********** static methods ********** + + public static CacheType fromJavaAnnotationValue(Object javaAnnotationValue) { + return (javaAnnotationValue == null) ? null : fromJavaAnnotationValue_(javaAnnotationValue); + } + + private static CacheType fromJavaAnnotationValue_(Object javaAnnotationValue) { + for (CacheType cacheType : CacheType.values()) { + if (cacheType.getJavaAnnotationValue().equals(javaAnnotationValue)) { + return cacheType; + } } return null; } public static String toJavaAnnotationValue(CacheType cacheType) { - if (cacheType == null) { - return null; - } - switch (cacheType) { - case FULL : - return EclipseLinkJPA.CACHE_TYPE__FULL; - case WEAK : - return EclipseLinkJPA.CACHE_TYPE__WEAK; - case SOFT : - return EclipseLinkJPA.CACHE_TYPE__SOFT; - case SOFT_WEAK : - return EclipseLinkJPA.CACHE_TYPE__SOFT_WEAK; - case HARD_WEAK : - return EclipseLinkJPA.CACHE_TYPE__HARD_WEAK; - case CACHE : - return EclipseLinkJPA.CACHE_TYPE__CACHE; - case NONE : - return EclipseLinkJPA.CACHE_TYPE__NONE; - default : - throw new IllegalArgumentException("unknown cache type: " + cacheType); //$NON-NLS-1$ - } + return (cacheType == null) ? null : cacheType.getJavaAnnotationValue(); } + } diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/ChangeTrackingType.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/ChangeTrackingType.java index 749f7c2499..4fc64883de 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/ChangeTrackingType.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/ChangeTrackingType.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Oracle. All rights reserved. + * 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. @@ -10,6 +10,8 @@ package org.eclipse.jpt.eclipselink.core.resource.java; /** + * Corresponds to the EclipseLink enum + * org.eclipse.persistence.annotations.ChangeTrackingType * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -22,46 +24,43 @@ package org.eclipse.jpt.eclipselink.core.resource.java; */ public enum ChangeTrackingType { + ATTRIBUTE(EclipseLinkJPA.CHANGE_TRACKING_TYPE__ATTRIBUTE), + OBJECT(EclipseLinkJPA.CHANGE_TRACKING_TYPE__OBJECT), + DEFERRED(EclipseLinkJPA.CHANGE_TRACKING_TYPE__DEFERRED), + AUTO(EclipseLinkJPA.CHANGE_TRACKING_TYPE__AUTO); - ATTRIBUTE, - OBJECT, - DEFERRED, - AUTO; - - public static ChangeTrackingType fromJavaAnnotationValue(Object javaAnnotationValue) { + + private String javaAnnotationValue; + + ChangeTrackingType(String javaAnnotationValue) { if (javaAnnotationValue == null) { - return null; - } - if (javaAnnotationValue.equals(EclipseLinkJPA.CHANGE_TRACKING_TYPE__ATTRIBUTE)) { - return ATTRIBUTE; - } - if (javaAnnotationValue.equals(EclipseLinkJPA.CHANGE_TRACKING_TYPE__OBJECT)) { - return OBJECT; + throw new NullPointerException(); } - if (javaAnnotationValue.equals(EclipseLinkJPA.CHANGE_TRACKING_TYPE__DEFERRED)) { - return DEFERRED; - } - if (javaAnnotationValue.equals(EclipseLinkJPA.CHANGE_TRACKING_TYPE__AUTO)) { - return AUTO; + this.javaAnnotationValue = javaAnnotationValue; + } + + public String getJavaAnnotationValue() { + return this.javaAnnotationValue; + } + + + // ********** static methods ********** + + public static ChangeTrackingType fromJavaAnnotationValue(Object javaAnnotationValue) { + return (javaAnnotationValue == null) ? null : fromJavaAnnotationValue_(javaAnnotationValue); + } + + private static ChangeTrackingType fromJavaAnnotationValue_(Object javaAnnotationValue) { + for (ChangeTrackingType changeTrackingType : ChangeTrackingType.values()) { + if (changeTrackingType.getJavaAnnotationValue().equals(javaAnnotationValue)) { + return changeTrackingType; + } } return null; } public static String toJavaAnnotationValue(ChangeTrackingType changeTrackingType) { - if (changeTrackingType == null) { - return null; - } - switch (changeTrackingType) { - case ATTRIBUTE : - return EclipseLinkJPA.CHANGE_TRACKING_TYPE__ATTRIBUTE; - case OBJECT : - return EclipseLinkJPA.CHANGE_TRACKING_TYPE__OBJECT; - case DEFERRED : - return EclipseLinkJPA.CHANGE_TRACKING_TYPE__DEFERRED; - case AUTO : - return EclipseLinkJPA.CHANGE_TRACKING_TYPE__AUTO; - default : - throw new IllegalArgumentException("unknown change tracking type: " + changeTrackingType); //$NON-NLS-1$ - } + return (changeTrackingType == null) ? null : changeTrackingType.getJavaAnnotationValue(); } + } diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/ExistenceType.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/ExistenceType.java index b466c2bf2d..8b80206c8b 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/ExistenceType.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/ExistenceType.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Oracle. All rights reserved. + * 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. @@ -10,6 +10,8 @@ package org.eclipse.jpt.eclipselink.core.resource.java; /** + * Corresponds to the EclipseLink enum + * org.eclipse.persistence.annotations.ExistenceType * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -22,46 +24,43 @@ package org.eclipse.jpt.eclipselink.core.resource.java; */ public enum ExistenceType { + CHECK_CACHE(EclipseLinkJPA.EXISTENCE_TYPE__CHECK_CACHE), + CHECK_DATABASE(EclipseLinkJPA.EXISTENCE_TYPE__CHECK_DATABASE), + ASSUME_EXISTENCE(EclipseLinkJPA.EXISTENCE_TYPE__ASSUME_EXISTENCE), + ASSUME_NON_EXISTENCE(EclipseLinkJPA.EXISTENCE_TYPE__ASSUME_NON_EXISTENCE); - CHECK_CACHE, - CHECK_DATABASE, - ASSUME_EXISTENCE, - ASSUME_NON_EXISTENCE; - - public static ExistenceType fromJavaAnnotationValue(Object javaAnnotationValue) { + + private String javaAnnotationValue; + + ExistenceType(String javaAnnotationValue) { if (javaAnnotationValue == null) { - return null; - } - if (javaAnnotationValue.equals(EclipseLinkJPA.EXISTENCE_TYPE__CHECK_CACHE)) { - return CHECK_CACHE; - } - if (javaAnnotationValue.equals(EclipseLinkJPA.EXISTENCE_TYPE__CHECK_DATABASE)) { - return CHECK_DATABASE; + throw new NullPointerException(); } - if (javaAnnotationValue.equals(EclipseLinkJPA.EXISTENCE_TYPE__ASSUME_EXISTENCE)) { - return ASSUME_EXISTENCE; - } - if (javaAnnotationValue.equals(EclipseLinkJPA.EXISTENCE_TYPE__ASSUME_NON_EXISTENCE)) { - return ASSUME_NON_EXISTENCE; + this.javaAnnotationValue = javaAnnotationValue; + } + + public String getJavaAnnotationValue() { + return this.javaAnnotationValue; + } + + + // ********** static methods ********** + + public static ExistenceType fromJavaAnnotationValue(Object javaAnnotationValue) { + return (javaAnnotationValue == null) ? null : fromJavaAnnotationValue_(javaAnnotationValue); + } + + private static ExistenceType fromJavaAnnotationValue_(Object javaAnnotationValue) { + for (ExistenceType existenceType : ExistenceType.values()) { + if (existenceType.getJavaAnnotationValue().equals(javaAnnotationValue)) { + return existenceType; + } } return null; } public static String toJavaAnnotationValue(ExistenceType existenceType) { - if (existenceType == null) { - return null; - } - switch (existenceType) { - case CHECK_CACHE : - return EclipseLinkJPA.EXISTENCE_TYPE__CHECK_CACHE; - case CHECK_DATABASE : - return EclipseLinkJPA.EXISTENCE_TYPE__CHECK_DATABASE; - case ASSUME_EXISTENCE : - return EclipseLinkJPA.EXISTENCE_TYPE__ASSUME_EXISTENCE; - case ASSUME_NON_EXISTENCE : - return EclipseLinkJPA.EXISTENCE_TYPE__ASSUME_NON_EXISTENCE; - default : - throw new IllegalArgumentException("unknown existence type: " + existenceType); //$NON-NLS-1$ - } + return (existenceType == null) ? null : existenceType.getJavaAnnotationValue(); } + } diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/JoinFetchType.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/JoinFetchType.java index c6d183ab28..40bc6177eb 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/JoinFetchType.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/JoinFetchType.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Oracle. All rights reserved. + * 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. @@ -10,8 +10,8 @@ package org.eclipse.jpt.eclipselink.core.resource.java; /** - * Resource model interface that represents the - * org.eclipse.persistence.annotations.JoinFetchType enum + * Corresponds to the EclipseLink enum + * org.eclipse.persistence.annotations.JoinFetchType * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -24,34 +24,41 @@ package org.eclipse.jpt.eclipselink.core.resource.java; */ public enum JoinFetchType { + INNER(EclipseLinkJPA.JOIN_FETCH_TYPE__INNER), + OUTER(EclipseLinkJPA.JOIN_FETCH_TYPE__OUTER); - INNER, - OUTER; - - public static JoinFetchType fromJavaAnnotationValue(Object javaAnnotationValue) { + + private String javaAnnotationValue; + + JoinFetchType(String javaAnnotationValue) { if (javaAnnotationValue == null) { - return null; - } - if (javaAnnotationValue.equals(EclipseLinkJPA.JOIN_FETCH_TYPE__INNER)) { - return INNER; + throw new NullPointerException(); } - if (javaAnnotationValue.equals(EclipseLinkJPA.JOIN_FETCH_TYPE__OUTER)) { - return OUTER; + this.javaAnnotationValue = javaAnnotationValue; + } + + public String getJavaAnnotationValue() { + return this.javaAnnotationValue; + } + + + // ********** static methods ********** + + public static JoinFetchType fromJavaAnnotationValue(Object javaAnnotationValue) { + return (javaAnnotationValue == null) ? null : fromJavaAnnotationValue_(javaAnnotationValue); + } + + private static JoinFetchType fromJavaAnnotationValue_(Object javaAnnotationValue) { + for (JoinFetchType joinFetchType : JoinFetchType.values()) { + if (joinFetchType.getJavaAnnotationValue().equals(javaAnnotationValue)) { + return joinFetchType; + } } return null; } public static String toJavaAnnotationValue(JoinFetchType joinFetchType) { - if (joinFetchType == null) { - return null; - } - switch (joinFetchType) { - case INNER : - return EclipseLinkJPA.JOIN_FETCH_TYPE__INNER; - case OUTER : - return EclipseLinkJPA.JOIN_FETCH_TYPE__OUTER; - default : - throw new IllegalArgumentException("unknown join fetch type: " + joinFetchType); //$NON-NLS-1$ - } + return (joinFetchType == null) ? null : joinFetchType.getJavaAnnotationValue(); } + } |