net.yadaframework.core.YadaLocalEnum Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of yadaweb Show documentation
Show all versions of yadaweb Show documentation
Some useful tasks for the Yada Framework
package net.yadaframework.core;
import java.util.Locale;
import org.springframework.context.MessageSource;
import net.yadaframework.persistence.entity.YadaJobState;
import net.yadaframework.persistence.entity.YadaPersistentEnum;
/**
* This interface must be applied to a normal enum that needs to be localized in order to perform sort and search operations
* on the localized text.
* Example:
*
* public enum YadaJobState implements YadaLocalEnum {
* }
*
* @param the enum
* @see YadaPersistentEnum
* @see YadaJobState
*/
public interface YadaLocalEnum> {
/**
* Return the associated YadaPersistentEnum to be used in entities
* @return
*/
YadaPersistentEnum toYadaPersistentEnum();
/**
* Used internally
* @param yadaPersistentEnum
*/
void setYadaPersistentEnum(YadaPersistentEnum yadaPersistentEnum);
/**
* @return the database id for this enum value
*/
default public long toId() {
return toYadaPersistentEnum().getId();
}
/**
* Convert the current enum to a localized string
* @param messageSource
* @param locale
* @return
*/
String toString(MessageSource messageSource, Locale locale);
// The following methods are implemented by enum: there's no need to implement them
/**
* Already implemented by enum
* @return
*/
String name();
/**
* Already implemented by enum
* @return
*/
int ordinal();
/**
* Already implemented by enum
* @return
*/
Class getDeclaringClass();
}