Author: tchemit Date: 2009-07-27 22:19:48 +0200 (Mon, 27 Jul 2009) New Revision: 1670 Modified: trunk/src/main/java/org/nuiton/util/ApplicationConfig.java Log: add OptionDef contract to have more infos in ApplicationConfg options, should add more infos (perharps via an annotation ?) Modified: trunk/src/main/java/org/nuiton/util/ApplicationConfig.java =================================================================== --- trunk/src/main/java/org/nuiton/util/ApplicationConfig.java 2009-07-24 14:50:39 UTC (rev 1669) +++ trunk/src/main/java/org/nuiton/util/ApplicationConfig.java 2009-07-27 20:19:48 UTC (rev 1670) @@ -294,6 +294,48 @@ /** suport of config modification */ protected PropertyChangeSupport pcs = new PropertyChangeSupport(this); + /** + * Le contrat de marquage des options, on utilise cette interface pour + * caracteriser une option de configuration. + * + * @since 1.0.0-rc-9 + */ + static public interface OptionDef { + + /** + * @return la clef identifiant l'option + */ + String getKey(); + + /** + * @return le type de l'option + */ + Class<?> getType(); + + /** + * @return la clef i18n de description de l'option + */ + String getDescription(); + + /** + * @return la valeur par defaut de l'option sous forme de chaine de + * caracteres + */ + String getDefaultValue(); + + /** + * @return <code>true</code> si l'option ne peut etre sauvegardee sur + * disque (utile par exemple pour les mots de passe, ...) + */ + boolean isTransient(); + + /** + * @return <code>true</code> si l'option n'est pas modifiable (utilise + * par exemple pour la version de l'application, ...) + */ + boolean isFinal(); + } + static public class Action { @Retention(RetentionPolicy.RUNTIME) @@ -555,6 +597,17 @@ } /** + * get option value from a option definition + * + * @param key the definition of the option + * @return the value for the given option + */ + public Object getOption(OptionDef key) { + Object result = getOption(key.getType(), key.getKey()); + return result; + } + + /** * get option value as typed value * * @param <T> type of the object wanted as return type