Class CompileTimeConstantExpressionMatcher

java.lang.Object
com.google.errorprone.matchers.CompileTimeConstantExpressionMatcher
All Implemented Interfaces:
Matcher<ExpressionTree>, Serializable

public class CompileTimeConstantExpressionMatcher extends Object implements Matcher<ExpressionTree>
A matcher for compile-time-constant expressions.

For the purposes of this matcher, a compile-time constant expression is one of the following:

  1. Any expression for which the Java compiler can determine a constant value at compile time.
  2. The expression consisting of the literal null.
  3. An expression consisting of a single identifier, where the identifier has the CompileTimeConstant annotation and is either:
    • A class field that is declared final.
    • A formal parameter of a method or constructor, which is declared final or is effectively final.
  4. A String which is formed from the concatenation of other compile-time-constant Strings.
  5. A switch expression where all case bodies are compile-time constants.
  6. A conditional expression (a ? b : c) where both branches are compile-time constants.
  7. The result of an invocation of one of the following immutable collection factory methods, where all arguments are compile-time constants:
    • ImmutableList.of(...)
    • ImmutableSet.of(...)
    • ImmutableMap.of(...)
    • ImmutableMultiset.of(...)
    • ImmutableSortedSet.of(...)
    • ImmutableSortedMap.of(...)
    • List.of(...)
    • Set.of(...)
    • Map.of(...)
See Also:
  • Constructor Details

    • CompileTimeConstantExpressionMatcher

      public CompileTimeConstantExpressionMatcher()
  • Method Details