
net.sf.staccatocommons.restrictions.effect.SideEffectFree Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of staccatissimo-restrictions Show documentation
Show all versions of staccatissimo-restrictions Show documentation
Library of annotations that express restrictions, that can be used to indicate preconditions,
postconditions and invariants over objects and messages, focused on documentation reuse.
The newest version!
/**
* Copyright (c) 2010-2012, The StaccatoCommons Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*/
package net.sf.staccatocommons.restrictions.effect;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import net.sf.staccatocommons.restrictions.Restriction;
import net.sf.staccatocommons.restrictions.value.Unmodifiable;
/**
* Side effect free is a {@link 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
* {@link 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
* {@link SideEffectFree} classes as {@link Unmodifiable}, as it is implicit.
*
*
* Being {@link 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 {@link Transparent} instead.
*
*
* @author flbulgarelli
* @see Side
* effect
* @see Transparent
*/
@Restriction
@Documented
@Retention(RetentionPolicy.SOURCE)
@Target({ ElementType.METHOD, ElementType.TYPE })
public @interface SideEffectFree {
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy