org.nakedobjects.applib.annotation
Annotation Type Value


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

Indicates that the class has value semantics.

By "value semantics" all we actually mean that the class is Aggregated and so therefore (conceptually) is not shared between instances of classes. However, values very often have other semantics, and so this annotation allows these to also be specified:

  • it may be parseable (as per Parseable)
  • it may be encodeable (as per Encodable)
  • it may be immutable (as per Immutable), and by default is presumed that it is
  • it may follow the equal-by-content contract (as per EqualByContent), and by default is presumed that it does.

    Note also that though a value is conceptually not shared, if it is also immutable then it is in fact safe to share objects (as in the flyweight pattern). In addition, the EqualByContent semantic means that we needn't care whether value types are being shared or not.

    See Also:
    Aggregated, Parseable, Encodable, Immutable, EqualByContent

    Optional Element Summary
     java.lang.Class<?> semanticsProviderClass
              As per semanticsProviderName(), but specifying a class literal rather than a fully qualified class name.
     java.lang.String semanticsProviderName
              The fully qualified name of a class that implements the ValueSemanticsProvider interface.
     

    semanticsProviderName

    public abstract java.lang.String semanticsProviderName
    The fully qualified name of a class that implements the ValueSemanticsProvider interface.

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

    It is possible for value classes to act as their own semantics providers, and may in particular implement the EncoderDecoder interface. The framework requires that the nominated class provides a public no-arg constructor on the class, and will instantiates an instance of the class to interact with it. In the case of encoding, the framework uses the result of discards the instantiated object. What that means in particular is that a self-encoding class shouldn't encode its own state, it should encode the state of the object passed to it.

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

    Default:
    ""

    semanticsProviderClass

    public abstract java.lang.Class<?> semanticsProviderClass
    As per semanticsProviderName(), but specifying a class literal rather than a fully qualified class name.

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

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


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