diff options
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/mappings/GenerationType.java')
-rw-r--r-- | jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/mappings/GenerationType.java | 331 |
1 files changed, 331 insertions, 0 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/mappings/GenerationType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/mappings/GenerationType.java new file mode 100644 index 0000000000..f3156c7b79 --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/mappings/GenerationType.java @@ -0,0 +1,331 @@ +/******************************************************************************* + * Copyright (c) 2007 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.mappings; + +import static org.eclipse.jpt.core.internal.mappings.GenerationType.AUTO_VALUE; +import static org.eclipse.jpt.core.internal.mappings.GenerationType.DEFAULT_VALUE; +import static org.eclipse.jpt.core.internal.mappings.GenerationType.IDENTITY_VALUE; +import static org.eclipse.jpt.core.internal.mappings.GenerationType.SEQUENCE_VALUE; +import static org.eclipse.jpt.core.internal.mappings.GenerationType.TABLE_VALUE; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import org.eclipse.emf.common.util.Enumerator; +import org.eclipse.jpt.core.internal.content.java.mappings.JPA; + +/** + * <!-- begin-user-doc --> + * A representation of the literals of the enumeration '<em><b>Generation Type</b></em>', + * and utility methods for working with them. + * <!-- end-user-doc --> + * @see org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage#getGenerationType() + * @model + * @generated + */ +public enum GenerationType implements Enumerator { + /** + * The '<em><b>Default</b></em>' literal object. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #DEFAULT_VALUE + * @generated + * @ordered + */ + DEFAULT(0, "Default", "Default (Auto)"), + /** + * The '<em><b>Auto</b></em>' literal object. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #AUTO_VALUE + * @generated + * @ordered + */ + AUTO(1, "Auto", "Auto"), + /** + * The '<em><b>Identity</b></em>' literal object. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #IDENTITY_VALUE + * @generated + * @ordered + */ + IDENTITY(2, "Identity", "Identity"), + /** + * The '<em><b>Sequence</b></em>' literal object. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #SEQUENCE_VALUE + * @generated + * @ordered + */ + SEQUENCE(3, "Sequence", "Sequence"), + /** + * The '<em><b>Table</b></em>' literal object. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #TABLE_VALUE + * @generated + * @ordered + */ + TABLE(4, "Table", "Table"); + /** + * The '<em><b>Default</b></em>' literal value. + * <!-- begin-user-doc --> + * <p> + * If the meaning of '<em><b>Default</b></em>' literal object isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @see #DEFAULT + * @model name="Default" literal="Default (Auto)" + * @generated + * @ordered + */ + public static final int DEFAULT_VALUE = 0; + + /** + * The '<em><b>Auto</b></em>' literal value. + * <!-- begin-user-doc --> + * <p> + * If the meaning of '<em><b>Auto</b></em>' literal object isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @see #AUTO + * @model name="Auto" + * @generated + * @ordered + */ + public static final int AUTO_VALUE = 1; + + /** + * The '<em><b>Identity</b></em>' literal value. + * <!-- begin-user-doc --> + * <p> + * If the meaning of '<em><b>Identity</b></em>' literal object isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @see #IDENTITY + * @model name="Identity" + * @generated + * @ordered + */ + public static final int IDENTITY_VALUE = 2; + + /** + * The '<em><b>Sequence</b></em>' literal value. + * <!-- begin-user-doc --> + * <p> + * If the meaning of '<em><b>Sequence</b></em>' literal object isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @see #SEQUENCE + * @model name="Sequence" + * @generated + * @ordered + */ + public static final int SEQUENCE_VALUE = 3; + + /** + * The '<em><b>Table</b></em>' literal value. + * <!-- begin-user-doc --> + * <p> + * If the meaning of '<em><b>Table</b></em>' literal object isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @see #TABLE + * @model name="Table" + * @generated + * @ordered + */ + public static final int TABLE_VALUE = 4; + + /** + * An array of all the '<em><b>Generation Type</b></em>' enumerators. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private static final GenerationType[] VALUES_ARRAY = new GenerationType[] { + DEFAULT, AUTO, IDENTITY, SEQUENCE, TABLE, + }; + + /** + * A public read-only list of all the '<em><b>Generation Type</b></em>' enumerators. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final List<GenerationType> VALUES = Collections.unmodifiableList(Arrays.asList(VALUES_ARRAY)); + + /** + * Returns the '<em><b>Generation Type</b></em>' literal with the specified literal value. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static GenerationType get(String literal) { + for (int i = 0; i < VALUES_ARRAY.length; ++i) { + GenerationType result = VALUES_ARRAY[i]; + if (result.toString().equals(literal)) { + return result; + } + } + return null; + } + + /** + * Returns the '<em><b>Generation Type</b></em>' literal with the specified name. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static GenerationType getByName(String name) { + for (int i = 0; i < VALUES_ARRAY.length; ++i) { + GenerationType result = VALUES_ARRAY[i]; + if (result.getName().equals(name)) { + return result; + } + } + return null; + } + + /** + * Returns the '<em><b>Generation Type</b></em>' literal with the specified integer value. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static GenerationType get(int value) { + switch (value) { + case DEFAULT_VALUE : + return DEFAULT; + case AUTO_VALUE : + return AUTO; + case IDENTITY_VALUE : + return IDENTITY; + case SEQUENCE_VALUE : + return SEQUENCE; + case TABLE_VALUE : + return TABLE; + } + return null; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private final int value; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private final String name; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private final String literal; + + /** + * Only this class can construct instances. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private GenerationType(int value, String name, String literal) { + this.value = value; + this.name = name; + this.literal = literal; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public int getValue() { + return value; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getName() { + return name; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getLiteral() { + return literal; + } + + /** + * Returns the literal value of the enumerator, which is its string representation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public String toString() { + return literal; + } + + public static GenerationType fromJavaAnnotationValue(Object javaAnnotationValue) { + if (javaAnnotationValue == null) { + return DEFAULT; + } + if (javaAnnotationValue.equals(JPA.GENERATION_TYPE__AUTO)) { + return AUTO; + } + if (javaAnnotationValue.equals(JPA.GENERATION_TYPE__IDENTITY)) { + return IDENTITY; + } + if (javaAnnotationValue.equals(JPA.GENERATION_TYPE__SEQUENCE)) { + return SEQUENCE; + } + if (javaAnnotationValue.equals(JPA.GENERATION_TYPE__TABLE)) { + return TABLE; + } + return DEFAULT; + } + + public String convertToJavaAnnotationValue() { + switch (this.getValue()) { + case DEFAULT_VALUE : + return null; + case AUTO_VALUE : + return JPA.GENERATION_TYPE__AUTO; + case IDENTITY_VALUE : + return JPA.GENERATION_TYPE__IDENTITY; + case SEQUENCE_VALUE : + return JPA.GENERATION_TYPE__SEQUENCE; + case TABLE_VALUE : + return JPA.GENERATION_TYPE__TABLE; + default : + throw new IllegalArgumentException("unknown generation type: " + this); + } + } +} //GenerationType |