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    
010    /**
011     * Indicates that an instance cannot be changed.
012     * 
013     * <p>
014     * To make something always immutable used the form <tt>@Immutable</tt>. To make something immutable only once persisted use the form
015     *            <tt>@Immutable(Immutable.ONCE_PERSISTED)</tt>.
016     * 
017     * <p>
018     * By default any {@link Value value} types are assumed to be immutable, though this can be overridden if
019     * required. Immutable objects that are acting as a value type should almost certainly also follow the
020     * {@link EqualByContent equal-by-content} contract.
021     * 
022     * @see Value
023     * @see EqualByContent
024     */
025    @Inherited
026    @Target( { ElementType.TYPE })
027    @Retention(RetentionPolicy.RUNTIME)
028    public @interface Immutable {
029        When value() default When.ALWAYS;
030    }
031    
032    // Copyright (c) Naked Objects Group Ltd.