本文整理汇总了Java中com.google.errorprone.annotations.DoNotCall类的典型用法代码示例。如果您正苦于以下问题:Java DoNotCall类的具体用法?Java DoNotCall怎么用?Java DoNotCall使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DoNotCall类属于com.google.errorprone.annotations包,在下文中一共展示了DoNotCall类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: matchMethodInvocation
import com.google.errorprone.annotations.DoNotCall; //导入依赖的package包/类
@Override
public Description matchMethodInvocation(MethodInvocationTree tree, VisitorState state) {
DoNotCall doNotCall = ASTHelpers.getAnnotation(tree, DoNotCall.class);
if (doNotCall == null) {
return NO_MATCH;
}
StringBuilder message = new StringBuilder("This method should not be called");
if (doNotCall.value().isEmpty()) {
message.append(", see its documentation for details.");
} else {
message.append(": ").append(doNotCall.value());
}
return buildDescription(tree).setMessage(message.toString()).build();
}
示例2: matchMethod
import com.google.errorprone.annotations.DoNotCall; //导入依赖的package包/类
@Override
public Description matchMethod(MethodTree tree, VisitorState state) {
MethodSymbol symbol = ASTHelpers.getSymbol(tree);
if (symbol == null) {
return NO_MATCH;
}
if (hasAnnotation(tree, DoNotCall.class, state)) {
if (symbol.getModifiers().contains(Modifier.ABSTRACT)) {
return NO_MATCH;
}
if (symbol.getModifiers().contains(Modifier.FINAL)) {
return NO_MATCH;
}
if (symbol.owner.enclClass().getModifiers().contains(Modifier.FINAL)) {
return NO_MATCH;
}
return buildDescription(tree)
.setMessage("Methods annotated with @DoNotCall should be final.")
.addFix(SuggestedFixes.addModifiers(tree, state, Modifier.FINAL))
.build();
}
return findSuperMethods(symbol, state.getTypes())
.stream()
.filter(s -> hasAnnotation(s, DoNotCall.class, state))
.findAny()
.map(
s -> {
String message =
String.format(
"Method overrides %s in %s which is annotated @DoNotCall,"
+ " it should also be annotated.",
s.getSimpleName(), s.owner.getSimpleName());
return buildDescription(tree)
.setMessage(message)
.addFix(
SuggestedFix.builder()
.addImport(DoNotCall.class.getName())
.prefixWith(tree, "@DoNotCall ")
.build())
.build();
})
.orElse(NO_MATCH);
}
示例3: addAll
import com.google.errorprone.annotations.DoNotCall; //导入依赖的package包/类
/** @deprecated Use {@link #addTransitive} to avoid excessive memory use. */
@Deprecated
@DoNotCall
public NestedSetBuilder<E> addAll(NestedSet<? extends E> elements) {
throw new UnsupportedOperationException();
}