org.nakedobjects.applib.annotation
Annotation Type Defaulted


@Inherited
@Target(value=TYPE)
@Retention(value=RUNTIME)
public @interface Defaulted

Indicates that the class should have a default, by providing a link to a DefaultsProvider, or some externally-configured mechanism.

This possibly seems a little tortuous. The more obvious means to provide a default would seem to be a simple @DefaultsTo(new SomeObject()). However, Java only allows primitives, strings and class literals to be used in annotations. We therefore need delegate to an external implementation. (This more complex design is also more flexible of course; the implementation of DefaultsProvider could adjust the default it provides according to circumstance, for example).

See Also:
Encodable, Parseable, Value

Optional Element Summary
 Class<?> defaultsProviderClass
          As per defaultsProviderName(), but specifying a class literal rather than a fully qualified class name.
 String defaultsProviderName
          The fully qualified name of a class that implements the DefaultsProvider interface.
 

defaultsProviderName

public abstract String defaultsProviderName
The fully qualified name of a class that implements the DefaultsProvider interface.

This is optional because some implementations may pick up the defaults provider via a configuration file, or via the equivalent defaultsProviderClass().

Implementation note: the default value provided here is simply an empty string because null is not a valid default.

Default:
""

defaultsProviderClass

public abstract Class<?> defaultsProviderClass
As per defaultsProviderName(), but specifying a class literal rather than a fully qualified class name.

Implementation note: the default value provided here is simply the Defaulted's own class, because null is not a valid default.

Default:
org.nakedobjects.applib.annotation.Defaulted.class


Copyright © 2001-2009 Naked Objects Group Ltd.. All Rights Reserved.