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 * Specify a method on an Enum that returns the value that should be stored in the DB. 010 * <p> 011 * This is the preferred option for mapping Enum's to DB values (preferred over the JPA 012 * standard @Enumerated and Ebean's @EnumValue annotations). 013 * </p> 014 * <h3>Example:</h3> 015 * <pre>{@code 016 * 017 * public enum Status { 018 * NEW("N"), 019 * ACTIVE("A"), 020 * INACTIVE("I"); 021 * 022 * String dbValue; 023 * Status(String dbValue) { 024 * this.dbValue = dbValue; 025 * } 026 * 027 * @DbEnumValue 028 * public String getValue() { 029 * return dbValue; 030 * } 031 * } 032 * 033 * }</pre> 034 */ 035@Retention(RetentionPolicy.RUNTIME) 036@Target(ElementType.METHOD) 037public @interface DbEnumValue { 038 039 /** 040 * Specify the database type used to store the values (VARCHAR or INTEGER). 041 */ 042 DbEnumType storage() default DbEnumType.VARCHAR; 043 044}