Search in sources :

Example 6 with ModifierKeywordTree

use of org.sonar.plugins.java.api.tree.ModifierKeywordTree in project sonar-java by SonarSource.

the class BadConstantNameCheck method isStaticFinal.

private static boolean isStaticFinal(VariableTree variableTree) {
    boolean isStatic = false;
    boolean isFinal = false;
    for (ModifierKeywordTree modifierKeywordTree : variableTree.modifiers().modifiers()) {
        Modifier modifier = modifierKeywordTree.modifier();
        if (modifier == Modifier.STATIC) {
            isStatic = true;
        }
        if (modifier == Modifier.FINAL) {
            isFinal = true;
        }
    }
    return isStatic && isFinal;
}
Also used : ModifierKeywordTree(org.sonar.plugins.java.api.tree.ModifierKeywordTree) Modifier(org.sonar.plugins.java.api.tree.Modifier)

Aggregations

ModifierKeywordTree (org.sonar.plugins.java.api.tree.ModifierKeywordTree)6 ClassTree (org.sonar.plugins.java.api.tree.ClassTree)3 Modifier (org.sonar.plugins.java.api.tree.Modifier)3 Test (org.junit.Test)1 JavaFileScannerContext (org.sonar.plugins.java.api.JavaFileScannerContext)1 BlockTree (org.sonar.plugins.java.api.tree.BlockTree)1 MethodTree (org.sonar.plugins.java.api.tree.MethodTree)1 ModifierTree (org.sonar.plugins.java.api.tree.ModifierTree)1 ModifiersTree (org.sonar.plugins.java.api.tree.ModifiersTree)1 NewClassTree (org.sonar.plugins.java.api.tree.NewClassTree)1 PrimitiveTypeTree (org.sonar.plugins.java.api.tree.PrimitiveTypeTree)1 Tree (org.sonar.plugins.java.api.tree.Tree)1 TypeParameters (org.sonar.plugins.java.api.tree.TypeParameters)1 TypeTree (org.sonar.plugins.java.api.tree.TypeTree)1 VariableTree (org.sonar.plugins.java.api.tree.VariableTree)1