Package org.codehaus.mojo.animal_sniffer
Class SignatureChecker
- java.lang.Object
-
- org.codehaus.mojo.animal_sniffer.ClassFileVisitor
-
- org.codehaus.mojo.animal_sniffer.SignatureChecker
-
public class SignatureChecker extends ClassFileVisitor
Checks the signature against classes in this list.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
SignatureChecker.CheckingVisitor
private static class
SignatureChecker.ExactMatchRule
private static interface
SignatureChecker.MatchRule
private static class
SignatureChecker.PrefixMatchRule
private static class
SignatureChecker.RegexMatchRule
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ANNOTATION_FQN
The fully qualified name of the annotation to use to annotate methods/fields/classes that are to be ignored by animal sniffer.private java.util.Collection<java.lang.String>
annotationDescriptors
private java.util.Map<java.lang.String,Clazz>
classes
private boolean
hadError
private java.util.Set<java.lang.String>
ignoredOuterClassesOrMethods
private java.util.List<SignatureChecker.MatchRule>
ignoredPackageRules
Classes in this packages are considered to be resolved elsewhere and thus not a subject of the error checking when referenced.private java.util.Set<java.lang.String>
ignoredPackages
private Logger
logger
static java.lang.String
PREVIOUS_ANNOTATION_FQN
Similar toANNOTATION_FQN
.private java.util.List<java.io.File>
sourcePath
-
Constructor Summary
Constructors Constructor Description SignatureChecker(java.io.InputStream in, java.util.Set<java.lang.String> ignoredPackages, Logger logger)
SignatureChecker(java.util.Map<java.lang.String,Clazz> classes, java.util.Set<java.lang.String> ignoredPackages, Logger logger)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static java.lang.String
fromSourceType(java.lang.String text)
boolean
isSignatureBroken()
static java.util.Map<java.lang.String,Clazz>
loadClasses(java.io.InputStream in)
static void
main(java.lang.String[] args)
private SignatureChecker.MatchRule
newMatchRule(java.lang.String matcher)
protected void
process(java.lang.String name, java.io.InputStream image)
void
setAnnotationTypes(java.util.Collection<java.lang.String> annotationTypes)
Sets the annotation type(s) that this checker should consider to ignore annotated methods, classes or fields.void
setSourcePath(java.util.List<java.io.File> sourcePath)
(package private) static java.lang.String
toAnnotationDescriptor(java.lang.String classFqn)
(package private) static java.lang.String
toSourceForm(java.lang.String type, java.lang.String sig)
private static java.lang.String
toSourceType(java.lang.String text)
private static java.lang.String
toSourceType(java.nio.CharBuffer type)
-
Methods inherited from class org.codehaus.mojo.animal_sniffer.ClassFileVisitor
isCheckJars, process, process, process, processClassFile, processDirectory, processJarFile, setCheckJars
-
-
-
-
Field Detail
-
ANNOTATION_FQN
public static final java.lang.String ANNOTATION_FQN
The fully qualified name of the annotation to use to annotate methods/fields/classes that are to be ignored by animal sniffer.- See Also:
- Constant Field Values
-
PREVIOUS_ANNOTATION_FQN
public static final java.lang.String PREVIOUS_ANNOTATION_FQN
Similar toANNOTATION_FQN
. Kept for backward compatibility reasons- See Also:
- Constant Field Values
-
classes
private final java.util.Map<java.lang.String,Clazz> classes
-
logger
private final Logger logger
-
ignoredPackageRules
private final java.util.List<SignatureChecker.MatchRule> ignoredPackageRules
Classes in this packages are considered to be resolved elsewhere and thus not a subject of the error checking when referenced.
-
ignoredPackages
private final java.util.Set<java.lang.String> ignoredPackages
-
ignoredOuterClassesOrMethods
private final java.util.Set<java.lang.String> ignoredOuterClassesOrMethods
-
hadError
private boolean hadError
-
sourcePath
private java.util.List<java.io.File> sourcePath
-
annotationDescriptors
private java.util.Collection<java.lang.String> annotationDescriptors
-
-
Constructor Detail
-
SignatureChecker
public SignatureChecker(java.io.InputStream in, java.util.Set<java.lang.String> ignoredPackages, Logger logger) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
main
public static void main(java.lang.String[] args) throws java.lang.Exception
- Throws:
java.lang.Exception
-
loadClasses
public static java.util.Map<java.lang.String,Clazz> loadClasses(java.io.InputStream in) throws java.io.IOException
- Throws:
java.io.IOException
-
setSourcePath
public void setSourcePath(java.util.List<java.io.File> sourcePath)
- Since:
- 1.9
-
setAnnotationTypes
public void setAnnotationTypes(java.util.Collection<java.lang.String> annotationTypes)
Sets the annotation type(s) that this checker should consider to ignore annotated methods, classes or fields.By default, the
ANNOTATION_FQN
andPREVIOUS_ANNOTATION_FQN
are used.If you want to add an extra annotation types, make sure to add the standard one to the specified lists.
- Parameters:
annotationTypes
- a list of the fully qualified name of the annotation types to consider for ignoring annotated method, class and field- Since:
- 1.11
-
process
protected void process(java.lang.String name, java.io.InputStream image) throws java.io.IOException
- Specified by:
process
in classClassFileVisitor
- Parameters:
name
- Displayable name to identify what class file we are processingimage
- Class file image.- Throws:
java.io.IOException
-
newMatchRule
private SignatureChecker.MatchRule newMatchRule(java.lang.String matcher)
-
isSignatureBroken
public boolean isSignatureBroken()
-
toSourceForm
static java.lang.String toSourceForm(java.lang.String type, java.lang.String sig)
-
toAnnotationDescriptor
static java.lang.String toAnnotationDescriptor(java.lang.String classFqn)
-
toSourceType
private static java.lang.String toSourceType(java.nio.CharBuffer type)
-
toSourceType
private static java.lang.String toSourceType(java.lang.String text)
-
fromSourceType
private static java.lang.String fromSourceType(java.lang.String text)
-
-