001package io.ebean.annotation;
002
003import java.lang.annotation.ElementType;
004import java.lang.annotation.Retention;
005import java.lang.annotation.RetentionPolicy;
006import java.lang.annotation.Target;
007
008/**
009 * Enables you to specify a value to use to persist for an enum value.
010 * <pre>{@code
011 *
012 * public enum Status {
013 *
014 *   @EnumValue("N")
015 *   NEW,
016 *
017 *   @EnumValue("A")
018 *   ACTIVE,
019 *
020 *   @EnumValue("I")
021 *   INACTIVE,
022 * }
023 *
024 * }</pre>
025 * <p>
026 * This is an alternative to using the JPA standard approach or Ebean's
027 * {@link DbEnumValue} annotation.
028 * </p>
029 * <p>
030 * Note that if all the EnumValue values are parsable as Integers then Ebean
031 * will persist and fetch them as integers - otherwise they will be persisted
032 * and fetched as strings.
033 * </p>
034 */
035@Target({ElementType.FIELD})
036@Retention(RetentionPolicy.RUNTIME)
037public @interface EnumValue {
038
039  /**
040   * Specify the value to persist for a specific enum value.
041   * <p>
042   * If all the values are parsable as Integers then Ebean will persist and
043   * fetch them as integers rather than strings.
044   * </p>
045   */
046  String value();
047}