Record Class Restriction
java.lang.Object
java.lang.Record
com.google.errorprone.bugpatterns.restrictedapi.Restriction
public record Restriction(String explanation, String link, com.google.common.collect.ImmutableList<String> allowedPaths, String allowedOnPath, com.google.common.collect.ImmutableList<TypeMirror> allowlistAnnotations, Optional<TypeMirror> suggestedAllowlistAnnotation, boolean allowedInTestonlyTargets, boolean warningOnlyForRefactoring)
extends Record
Details of a restriction declared via an annotation like
@RestrictedApi.-
Constructor Summary
ConstructorsConstructorDescriptionRestriction(String explanation, String link, com.google.common.collect.ImmutableList<String> allowedPaths, String allowedOnPath, com.google.common.collect.ImmutableList<TypeMirror> allowlistAnnotations, Optional<TypeMirror> suggestedAllowlistAnnotation, boolean allowedInTestonlyTargets, boolean warningOnlyForRefactoring) Creates an instance of aRestrictionrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the value of theallowedInTestonlyTargetsrecord component.Returns the value of theallowedOnPathrecord component.com.google.common.collect.ImmutableList<String> Returns the value of theallowedPathsrecord component.com.google.common.collect.ImmutableList<TypeMirror> Returns the value of theallowlistAnnotationsrecord component.final booleanIndicates whether some other object is "equal to" this one.Returns the value of theexplanationrecord component.static Optional<Restriction> from(AnnotationMirror attribute) Parses aRestrictionfrom anAnnotationMirror.final inthashCode()Returns a hash code value for this object.booleanisAllowed(Tree where, VisitorState state) Returns true if usage atwhereis exempt by path, test-only target, or allowlist.booleanisAllowlisted(Tree where, VisitorState state) Returns true if usage atwhereis permitted by an allowlist annotation.booleanisPathOrTestonlyExempt(Tree where, VisitorState state) Returns true if usage atwhereis exempt by path or test-only target rules.link()Returns the value of thelinkrecord component.Returns the value of thesuggestedAllowlistAnnotationrecord component.final StringtoString()Returns a string representation of this record class.validateAnnotation(AnnotationMirror attribute, com.sun.tools.javac.code.Symbol annotationSymbol) Validates path restrictions on an annotation, returning an error message if bothallowedPathsandallowedOnPathare specified.booleanReturns the value of thewarningOnlyForRefactoringrecord component.
-
Constructor Details
-
Restriction
public Restriction(String explanation, String link, com.google.common.collect.ImmutableList<String> allowedPaths, String allowedOnPath, com.google.common.collect.ImmutableList<TypeMirror> allowlistAnnotations, Optional<TypeMirror> suggestedAllowlistAnnotation, boolean allowedInTestonlyTargets, boolean warningOnlyForRefactoring) Creates an instance of aRestrictionrecord class.- Parameters:
explanation- the value for theexplanationrecord componentlink- the value for thelinkrecord componentallowedPaths- the value for theallowedPathsrecord componentallowedOnPath- the value for theallowedOnPathrecord componentallowlistAnnotations- the value for theallowlistAnnotationsrecord componentsuggestedAllowlistAnnotation- the value for thesuggestedAllowlistAnnotationrecord componentallowedInTestonlyTargets- the value for theallowedInTestonlyTargetsrecord componentwarningOnlyForRefactoring- the value for thewarningOnlyForRefactoringrecord component
-
-
Method Details
-
validateAnnotation
public static Optional<String> validateAnnotation(AnnotationMirror attribute, com.sun.tools.javac.code.Symbol annotationSymbol) Validates path restrictions on an annotation, returning an error message if bothallowedPathsandallowedOnPathare specified. -
from
Parses aRestrictionfrom anAnnotationMirror. -
isPathOrTestonlyExempt
Returns true if usage atwhereis exempt by path or test-only target rules. -
isAllowlisted
Returns true if usage atwhereis permitted by an allowlist annotation. -
isAllowed
Returns true if usage atwhereis exempt by path, test-only target, or allowlist. -
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
explanation
Returns the value of theexplanationrecord component.- Returns:
- the value of the
explanationrecord component
-
link
Returns the value of thelinkrecord component.- Returns:
- the value of the
linkrecord component
-
allowedPaths
Returns the value of theallowedPathsrecord component.- Returns:
- the value of the
allowedPathsrecord component
-
allowedOnPath
Returns the value of theallowedOnPathrecord component.- Returns:
- the value of the
allowedOnPathrecord component
-
allowlistAnnotations
Returns the value of theallowlistAnnotationsrecord component.- Returns:
- the value of the
allowlistAnnotationsrecord component
-
suggestedAllowlistAnnotation
Returns the value of thesuggestedAllowlistAnnotationrecord component.- Returns:
- the value of the
suggestedAllowlistAnnotationrecord component
-
allowedInTestonlyTargets
public boolean allowedInTestonlyTargets()Returns the value of theallowedInTestonlyTargetsrecord component.- Returns:
- the value of the
allowedInTestonlyTargetsrecord component
-
warningOnlyForRefactoring
public boolean warningOnlyForRefactoring()Returns the value of thewarningOnlyForRefactoringrecord component.- Returns:
- the value of the
warningOnlyForRefactoringrecord component
-