001    package org.nakedobjects.applib.annotation;
002    
003    import java.lang.annotation.ElementType;
004    import java.lang.annotation.Inherited;
005    import java.lang.annotation.Retention;
006    import java.lang.annotation.RetentionPolicy;
007    import java.lang.annotation.Target;
008    
009    import org.nakedobjects.applib.adapters.Parser;
010    
011    
012    /**
013     * Indicates that the class can be parsed either by delegating to an {@link Parser} or through some
014     * externally-configured mechanism.
015     */
016    @Inherited
017    @Target( { ElementType.TYPE })
018    @Retention(RetentionPolicy.RUNTIME)
019    public @interface Parseable {
020    
021        /**
022         * The fully qualified name of a class that implements the {@link Parser} interface.
023         * 
024         * <p>
025         * This is optional because some implementations may pick up parseability via a configuration file either
026         * for the framework itself, or through a viewer-specific configuration of a widget (eg a calendar view
027         * for a date), or indeed through the equivalent {@link #parserClass()}.
028         * 
029         * <p>
030         * It is common for value classes to act as their own parsers. Note that the framework requires that the
031         * nominated class provides a <tt>public</tt> no-arg constructor on the class. It instantiates an
032         * instance in order to do the parsing, uses the result and discards the instantiated object.
033         * 
034         * <p>
035         * Implementation note: the default value provided here is simply the empty string because <tt>null</tt>
036         * is not a valid default.
037         */
038        String parserName() default "";
039    
040        /**
041         * As per {@link #parserName()}, but specifying a class literal rather than a fully qualified class name.
042         * 
043         * <p>
044         * Implementation note: the default value provided here is simply the {@link Parseable}'s own class,
045         * because <tt>null</tt> is not a valid default.
046         */
047        Class<?> parserClass() default Parseable.class;
048    }