net.sf.staccatocommons.restrictions.effect
Annotation Type SideEffectFree


@Restriction
@Documented
@Retention(value=SOURCE)
@Target(value={METHOD,TYPE})
public @interface SideEffectFree

Side effect free is a Restriction that applies to methods that have no side effects. As a consequence, such methods must not modify the state of its arguments, if any, nor the this reference, if non-static, nor any attribute in scope.

When applied to types, it means that all its methods are SideEffectFree. As a consequence, statefull classes that are annotated this way must be ummodifiable, as mutators are inheritely non-side-effect free. Thus there is no reason no annotate SideEffectFree classes as Unmodifiable, as it is implicit.

Being SideEffectFree is necessary but not sufficient for being referential transparent, thus methods annotated this way may return different results for the same arguments, if any. Such methods should be annotated with Transparent instead.

Author:
flbulgarelli
See Also:
Side effect, Transparent



Copyright © 2010-2012 StaccatoCommons. All Rights Reserved.