-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
introduce @EnumeratedValue and actually specify what ORDINAL and STRI…
…NG mean see #47
- Loading branch information
Showing
5 changed files
with
180 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
api/src/main/java/jakarta/persistence/EnumeratedValue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright (c) 2008, 2020 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0, | ||
* or the Eclipse Distribution License v. 1.0 which is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause | ||
*/ | ||
|
||
// Contributors: | ||
// Gavin King - 3.2 | ||
|
||
|
||
package jakarta.persistence; | ||
|
||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
import static jakarta.persistence.EnumType.ORDINAL; | ||
import static java.lang.annotation.ElementType.FIELD; | ||
import static java.lang.annotation.ElementType.METHOD; | ||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
/** | ||
* Specifies that an annotated field of a Java {@code enum} | ||
* type is the source of database column values for an | ||
* {@linkplain Enumerated enumerated} mapping. The annotated | ||
* field must be declared {@code final}, and must be of type: | ||
* <ul> | ||
* <li>{@code byte}, {@code short}, or {@code int} for | ||
* {@link EnumType#ORDINAL}, or | ||
* <li>{@link String} for {@link EnumType#STRING}. | ||
* </ul> | ||
* The annotated field must not be null, and must hold a | ||
* distinct value for each value of the enum type. | ||
* | ||
* <pre> | ||
* Example: | ||
* | ||
* enum Status { | ||
* OPEN(0), CLOSED(1), CANCELLED(-1); | ||
* | ||
* @EnumeratedValue | ||
* final int intValue; | ||
* | ||
* Status(int intValue) { | ||
* this.intValue = intValue; | ||
* } | ||
* } | ||
* </pre> | ||
* | ||
* @see Enumerated | ||
* @see EnumType | ||
* | ||
* @since 3.2 | ||
*/ | ||
@Target({FIELD}) | ||
@Retention(RUNTIME) | ||
public @interface EnumeratedValue { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters