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


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

Transparent is a Restriction that applies to methods that are referentially transparent - their invocations can be replaced by its return value. In other words, are SideEffectFree and return always equal results for equals arguments.

When applied to types, it means that all its methods are Transparent. As a consequence, statefull classes that are annotated this way must be immutable, as otherwise, changes of state would eventually impact on changes in results. Thus there is no reason no annotate Transparent classes as Immutable, as it is implicit.

Being SideEffectFree necessary for being Transparent, there is no reason no annotate Transparent classes or methods as SideEffectFree, as it is implicit. As a consequence of being Immutable, Transparent classes are thread safe.

Author:
flbulgarelli
See Also:
Referential transparency, SideEffectFree, Immutable



Copyright © 2010-2012 StaccatoCommons. All Rights Reserved.