Java Code Examples for javax.annotation.meta.When#ALWAYS

The following examples show how to use javax.annotation.meta.When#ALWAYS . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FlowValue.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Determine whether given backwards FlowValue conflicts with given source.
 *
 * @param backwardsFlowValue
 *            a backwards FlowValue
 * @param source
 *            SourceSinkInfo object representing a source reached by the
 *            backwards flow value
 * @param typeQualifierValue
 *            TypeQualifierValue being checked
 * @param isIdentity TODO
 * @return true if backwards value conflicts with source, false if not
 */
public static boolean backwardsValueConflictsWithSource(FlowValue backwardsFlowValue, SourceSinkInfo source,
        TypeQualifierValue typeQualifierValue, boolean isIdentity) {

    When sourceWhen = source.getWhen();


    if (typeQualifierValue.isStrictQualifier() && !isIdentity) {
        // strict checking
        return (backwardsFlowValue == ALWAYS && sourceWhen != When.ALWAYS)
                || (backwardsFlowValue == NEVER && sourceWhen != When.NEVER);
    } else {
        // NOT strict checking
        return (backwardsFlowValue == ALWAYS && (sourceWhen == When.NEVER || sourceWhen == When.MAYBE))
                || (backwardsFlowValue == NEVER && (sourceWhen == When.ALWAYS || sourceWhen == When.MAYBE));
    }
}
 
Example 2
Source File: TypeQualifierNullnessAnnotationDatabase.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public boolean parameterMustBeNonNull(XMethod m, int param) {
    if (DEBUG) {
        System.out.print("Checking " + m + " param " + param + " for @Nonnull...");
    }
    TypeQualifierAnnotation tqa = TypeQualifierApplications.getEffectiveTypeQualifierAnnotation(m, param,
            nonnullTypeQualifierValue);

    if (tqa == null && param == 0) {
        String name = m.getName();
        String signature = m.getSignature();
        if ("main".equals(name) && "([Ljava/lang/String;)V".equals(signature) && m.isStatic() && m.isPublic()) {
            return true;
        } else if (assertsFirstParameterIsNonnull(m)) {
            return true;
        } else if ("compareTo".equals(name) && ")Z".equals(signature.substring(signature.indexOf(';') + 1)) && !m.isStatic()) {
            return true;
        }
    }
    boolean answer = (tqa != null) && tqa.when == When.ALWAYS;

    if (DEBUG) {
        System.out.println(answer ? "yes" : "no");
    }

    return answer;
}
 
Example 3
Source File: TestFooSimpleControlFlow.java    From spotbugs with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void requiresFoo(@Foo(when = When.ALWAYS) Object x) {
}
 
Example 4
Source File: MockNullableTestCorrect.java    From ph-commons with Apache License 2.0 4 votes vote down vote up
public void paramNonnullAlways (@Nonnull (when = When.ALWAYS) final String s)
{}
 
Example 5
Source File: TestFooGuaranteedControlFlow.java    From spotbugs with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void requiresFoo(@Foo(when = When.ALWAYS) Object x) {
}
 
Example 6
Source File: TestFooGuaranteedControlFlow.java    From spotbugs with GNU Lesser General Public License v2.1 4 votes vote down vote up
public @Foo(when = When.ALWAYS)
Object returnsFoo() {
    return null;
}
 
Example 7
Source File: TestFooNoControlFlow.java    From spotbugs with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void requiresFoo(@Foo(when = When.ALWAYS) Object x) {
}
 
Example 8
Source File: TestFooNoControlFlow.java    From spotbugs with GNU Lesser General Public License v2.1 4 votes vote down vote up
public @Foo(when = When.ALWAYS)
Object returnsFoo() {
    return null;
}
 
Example 9
Source File: I1.java    From spotbugs with GNU Lesser General Public License v2.1 4 votes vote down vote up
public @Foo(when = When.ALWAYS)
Object alwaysReturnFooParams1(@Foo(when = When.ALWAYS) Object alwaysParam, @Foo(when = When.NEVER) Object neverParam);
 
Example 10
Source File: I1.java    From spotbugs with GNU Lesser General Public License v2.1 4 votes vote down vote up
public @Foo(when = When.ALWAYS)
Object alwaysReturnFoo1();
 
Example 11
Source File: TestExhaustiveQualifier.java    From spotbugs with GNU Lesser General Public License v2.1 4 votes vote down vote up
@ExpectWarning("TQ")
public void report1(@ExhaustiveQualifier(value = ExhaustiveQualifier.Color.BLUE, when = When.ALWAYS) Object v) {
    // always BLUE should imply never RED
    redField = v;
}
 
Example 12
Source File: TestFooSimpleControlFlow.java    From spotbugs with GNU Lesser General Public License v2.1 4 votes vote down vote up
public @Foo(when = When.ALWAYS)
Object returnsFoo() {
    return null;
}
 
Example 13
Source File: TestFooGuaranteedControlFlow2.java    From spotbugs with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void requiresFoo(@Foo(when = When.ALWAYS) Object x) {
}
 
Example 14
Source File: TestFooGuaranteedControlFlow2.java    From spotbugs with GNU Lesser General Public License v2.1 4 votes vote down vote up
public @Foo(when = When.ALWAYS)
Object returnsFoo() {
    return null;
}
 
Example 15
Source File: TestExclusiveQualifier.java    From spotbugs with GNU Lesser General Public License v2.1 4 votes vote down vote up
@ExpectWarning("TQ")
public void report1(@ExclusiveQualifier(value = ExclusiveQualifier.Color.BLUE, when = When.ALWAYS) Object v) {
    // always BLUE should imply never RED
    redField = v;
}
 
Example 16
Source File: TestExclusiveQualifier.java    From spotbugs with GNU Lesser General Public License v2.1 4 votes vote down vote up
void setRed(@ExclusiveQualifier(value = ExclusiveQualifier.Color.RED, when = When.ALWAYS) Object redField) {
    this.redField = redField;
}
 
Example 17
Source File: TestExclusiveQualifier.java    From spotbugs with GNU Lesser General Public License v2.1 4 votes vote down vote up
@ExclusiveQualifier(value = ExclusiveQualifier.Color.RED, when = When.ALWAYS)
Object getRed() {
    return redField;
}
 
Example 18
Source File: TestFooNoControlFlow2.java    From spotbugs with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void requiresFoo(@Foo(when = When.ALWAYS) Object x) {
}
 
Example 19
Source File: TestFooNoControlFlow2.java    From spotbugs with GNU Lesser General Public License v2.1 4 votes vote down vote up
public @Foo(when = When.ALWAYS)
Object returnsFoo() {
    return null;
}
 
Example 20
Source File: IMockNullableTest.java    From ph-commons with Apache License 2.0 votes vote down vote up
void paramNonnullAlways (@Nonnull (when = When.ALWAYS) String s);