1 package android.signature.cts;
2 
3 /**
4  * Define the type of the signature check failures.
5  */
6 public enum FailureType {
7     MISSING_ANNOTATION,
8     MISSING_CLASS,
9     MISSING_INTERFACE,
10     MISSING_CONSTRUCTOR,
11     MISSING_METHOD,
12     MISSING_FIELD,
13     MISMATCH_CLASS,
14     MISMATCH_INTERFACE,
15     MISMATCH_INTERFACE_METHOD,
16     MISMATCH_METHOD,
17     MISMATCH_FIELD,
18     UNEXPECTED_CLASS,
19     EXTRA_CLASS,
20     EXTRA_INTERFACE,
21     EXTRA_CONSTRUCTOR,
22     EXTRA_METHOD,
23     EXTRA_FIELD,
24     CAUGHT_EXCEPTION;
25 
mismatch(JDiffClassDescription description)26     static FailureType mismatch(JDiffClassDescription description) {
27         return JDiffClassDescription.JDiffType.INTERFACE.equals(description.getClassType())
28                 ? FailureType.MISMATCH_INTERFACE : FailureType.MISMATCH_CLASS;
29     }
30 
missing(JDiffClassDescription description)31     static FailureType missing(JDiffClassDescription description) {
32         return JDiffClassDescription.JDiffType.INTERFACE.equals(description.getClassType())
33                 ? FailureType.MISSING_INTERFACE : FailureType.MISSING_CLASS;
34     }
35 
extra(Class<?> clazz)36     static FailureType extra(Class<?> clazz) {
37         return clazz.isInterface() ? FailureType.EXTRA_INTERFACE : FailureType.EXTRA_CLASS;
38     }
39 }
40