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