/** * Returns whether this rule accepts the given message with the given arguments. */ @Pure public boolean accepts(@Nonnull Level level, @Nonnull String caller, @Nonnull String thread, @Nonnull String message) { return level.getValue() >= threshold.getValue() && (callerPrefix == null || caller.startsWith(callerPrefix)) && (threadPrefix == null || thread.startsWith(threadPrefix)) && (messageRegex == null || message.matches(messageRegex)); }
/** * Logs the given message with the given position at the given level. * Each dollar sign in the message is replaced with the corresponding argument. */ @Impure protected static void log(@Nonnull Level level, @Nonnull CharSequence message, @Nullable SourcePosition position, @NonCaptured @Unmodified @Nonnull @NullableElements Object... arguments) { Logger.log(level, message + (position != null ? " " + position : ""), null, arguments); if (level.getValue() >= Level.INFORMATION.getValue() && StaticProcessingEnvironment.environment.isSet()) { if (position == null) { StaticProcessingEnvironment.environment.get().getMessager().printMessage(levelToKind.get(level), Strings.format(message, arguments)); } else if (position.getAnnotationValue() != null) { StaticProcessingEnvironment.environment.get().getMessager().printMessage(levelToKind.get(level), Strings.format(message, arguments), position.getElement(), position.getAnnotationMirror(), position.getAnnotationValue()); } else if (position.getAnnotationMirror() != null) { StaticProcessingEnvironment.environment.get().getMessager().printMessage(levelToKind.get(level), Strings.format(message, arguments), position.getElement(), position.getAnnotationMirror()); } else { StaticProcessingEnvironment.environment.get().getMessager().printMessage(levelToKind.get(level), Strings.format(message, arguments), position.getElement()); } } }