public class Classes
extends java.lang.Object
Classs.| Modifier and Type | Field and Description |
|---|---|
private ComparisonStrategy |
comparisonStrategy |
private Failures |
failures |
private static Classes |
INSTANCE |
| Constructor and Description |
|---|
Classes() |
| Modifier and Type | Method and Description |
|---|---|
void |
assertContainsAnnotations(AssertionInfo info,
java.lang.Class<?> actual,
java.lang.Class<? extends java.lang.annotation.Annotation>... annotations)
Verifies that the actual
Class contains the given Annotations. |
void |
assertHasDeclaredFields(AssertionInfo info,
java.lang.Class<?> actual,
java.lang.String... fields)
Verifies that the actual
Class has the declared fields. |
void |
assertHasDeclaredMethods(AssertionInfo info,
java.lang.Class<?> actual,
java.lang.String... methods)
Verifies that the actual
Class has the declared methods. |
void |
assertHasMethods(AssertionInfo info,
java.lang.Class<?> actual,
java.lang.String... methods)
Verifies that the actual
Class has the methods. |
void |
assertHasOnlyDeclaredFields(AssertionInfo info,
java.lang.Class<?> actual,
java.lang.String... expectedFields)
Verifies that the actual
Class has the exactly the fields and nothing more. |
void |
assertHasOnlyPublicFields(AssertionInfo info,
java.lang.Class<?> actual,
java.lang.String... expectedFields)
Verifies that the actual
Class has only the fields and nothing more. |
void |
assertHasPublicFields(AssertionInfo info,
java.lang.Class<?> actual,
java.lang.String... fields)
Verifies that the actual
Class has the fields. |
void |
assertHasPublicMethods(AssertionInfo info,
java.lang.Class<?> actual,
java.lang.String... methods)
Verifies that the actual
Class has the public methods. |
void |
assertIsAnnotation(AssertionInfo info,
java.lang.Class<?> actual)
Verifies that the actual
Class is an annotation. |
void |
assertIsAssignableFrom(AssertionInfo info,
java.lang.Class<?> actual,
java.lang.Class<?>... others)
Verifies that the actual
Class is assignable from all the others classes. |
void |
assertIsFinal(AssertionInfo info,
java.lang.Class<?> actual)
Verifies that the actual
Class is final. |
void |
assertIsInterface(AssertionInfo info,
java.lang.Class<?> actual)
Verifies that the actual
Class is an interface. |
void |
assertIsNotAnnotation(AssertionInfo info,
java.lang.Class<?> actual)
Verifies that the actual
Class is not an annotation. |
void |
assertIsNotFinal(AssertionInfo info,
java.lang.Class<?> actual)
Verifies that the actual
Class is not final. |
void |
assertIsNotInterface(AssertionInfo info,
java.lang.Class<?> actual)
Verifies that the actual
Class is not an interface. |
void |
assertIsProtected(AssertionInfo info,
java.lang.Class<?> actual)
Verifies that the actual
Class is protected. |
void |
assertIsPublic(AssertionInfo info,
java.lang.Class<?> actual)
Verifies that the actual
Class is public. |
private static void |
assertNotNull(AssertionInfo info,
java.lang.Class<?> actual) |
private static void |
classParameterIsNotNull(java.lang.Class<?> clazz)
used to check that the class to compare is not null, in that case throws a
NullPointerException with an
explicit message. |
private void |
doAssertHasMethods(AssertionInfo info,
java.lang.Class<?> actual,
java.util.Set<java.lang.reflect.Method> actualMethods,
boolean declared,
java.lang.String... expectedMethods) |
private static java.util.Set<java.lang.String> |
fieldsToName(java.util.Set<java.lang.reflect.Field> fields) |
private static <M extends java.lang.reflect.Member> |
filterSyntheticMembers(M[] members) |
private static java.lang.reflect.Method[] |
getAllMethods(java.lang.Class<?> actual) |
private static java.util.SortedSet<java.lang.String> |
getMethodsWithModifier(java.util.Set<java.lang.reflect.Method> methods,
int modifier) |
private static boolean |
hasPublicMethods(java.lang.reflect.Method[] methods) |
static Classes |
instance()
Returns the singleton instance of this class.
|
private static java.util.SortedSet<java.lang.String> |
methodsToName(java.util.Set<java.lang.reflect.Method> methods) |
private static java.util.Map<java.lang.String,java.lang.Integer> |
methodsToNameAndModifier(java.lang.reflect.Method[] methods) |
private static boolean |
noMissingElement(java.util.Set<java.lang.String> actualNames,
java.util.Set<java.lang.String> expectedNames,
java.util.Set<java.lang.String> missingNames)
Checks that the
expectedNames are part of the actualNames. |
private static boolean |
noNonMatchingModifier(java.util.Set<java.lang.String> expectedMethodNames,
java.util.Map<java.lang.String,java.lang.Integer> methodsModifier,
java.util.Map<java.lang.String,java.lang.String> nonMatchingModifiers,
int modifier) |
private static final Classes INSTANCE
private Failures failures
private ComparisonStrategy comparisonStrategy
public static Classes instance()
public void assertIsAssignableFrom(AssertionInfo info, java.lang.Class<?> actual, java.lang.Class<?>... others)
Class is assignable from all the others classes.info - contains information about the assertion.actual - the "actual" Class.others - the others Class who this actual class must be assignable.java.lang.NullPointerException - if one of the others is null.java.lang.AssertionError - if actual is null.java.lang.AssertionError - if the actual Class is not assignable from all of the others classes.public void assertIsNotInterface(AssertionInfo info, java.lang.Class<?> actual)
Class is not an interface.info - contains information about the assertion.actual - the "actual" Class.java.lang.AssertionError - if actual is null.java.lang.AssertionError - if the actual Class is an interface.public void assertIsInterface(AssertionInfo info, java.lang.Class<?> actual)
Class is an interface.info - contains information about the assertion.actual - the "actual" Class.java.lang.AssertionError - if actual is null.java.lang.AssertionError - if the actual Class is not an interface.public void assertIsNotAnnotation(AssertionInfo info, java.lang.Class<?> actual)
Class is not an annotation.info - contains information about the assertion.actual - the "actual" Class.java.lang.AssertionError - if actual is null.java.lang.AssertionError - if the actual Class is an annotation.public void assertIsAnnotation(AssertionInfo info, java.lang.Class<?> actual)
Class is an annotation.info - contains information about the assertion.actual - the "actual" Class.java.lang.AssertionError - if actual is null.java.lang.AssertionError - if the actual Class is not an annotation.public void assertIsFinal(AssertionInfo info, java.lang.Class<?> actual)
Class is final.info - contains information about the assertion.actual - the "actual" Class.java.lang.AssertionError - if actual is null.java.lang.AssertionError - if the actual Class is not final.public void assertIsPublic(AssertionInfo info, java.lang.Class<?> actual)
Class is public.info - contains information about the assertion.actual - the "actual" Class.java.lang.AssertionError - if actual is null.java.lang.AssertionError - if the actual Class is not public.public void assertIsProtected(AssertionInfo info, java.lang.Class<?> actual)
Class is protected.info - contains information about the assertion.actual - the "actual" Class.java.lang.AssertionError - if actual is null.java.lang.AssertionError - if the actual Class is not protected.public void assertIsNotFinal(AssertionInfo info, java.lang.Class<?> actual)
Class is not final.info - contains information about the assertion.actual - the "actual" Class.java.lang.AssertionError - if actual is null.java.lang.AssertionError - if the actual Class is final.public void assertContainsAnnotations(AssertionInfo info, java.lang.Class<?> actual, java.lang.Class<? extends java.lang.annotation.Annotation>... annotations)
Class contains the given Annotations.info - contains information about the assertion.actual - the "actual" Class.annotations - annotations who must be attached to the classjava.lang.AssertionError - if actual is null.java.lang.AssertionError - if the actual Class doesn't contains all of these annotations.public void assertHasPublicFields(AssertionInfo info, java.lang.Class<?> actual, java.lang.String... fields)
Class has the fields.info - contains information about the assertion.actual - the "actual" Class.fields - the fields who must be present in the class.java.lang.AssertionError - if actual is null.java.lang.AssertionError - if the actual Class doesn't contains all of the field.public void assertHasOnlyPublicFields(AssertionInfo info, java.lang.Class<?> actual, java.lang.String... expectedFields)
Class has only the fields and nothing more. in any order.info - contains information about the assertion.actual - the "actual" Class.expectedFields - all the fields that are expected to be in the class.java.lang.AssertionError - if actual is null.java.lang.AssertionError - if fields are not all the fields of the actual Class.private static boolean noMissingElement(java.util.Set<java.lang.String> actualNames,
java.util.Set<java.lang.String> expectedNames,
java.util.Set<java.lang.String> missingNames)
expectedNames are part of the actualNames. If an expectedName is not
contained in the actualNames, the this method will return true. THe missingNames will
contain all the expectedNames that are not part of the actualNames.actualNames - the names that should be used to checkexpectedNames - the names that should be contained in actualNamesmissingNames - the names that were not part of expectedNamestrue if all expectedNames are part of the actualNames, false otherwisepublic void assertHasDeclaredFields(AssertionInfo info, java.lang.Class<?> actual, java.lang.String... fields)
Class has the declared fields.info - contains information about the assertion.actual - the "actual" Class.fields - the fields who must be declared in the class.java.lang.AssertionError - if actual is null.java.lang.AssertionError - if the actual Class doesn't contains all of the field.public void assertHasOnlyDeclaredFields(AssertionInfo info, java.lang.Class<?> actual, java.lang.String... expectedFields)
Class has the exactly the fields and nothing more. in any order.info - contains information about the assertion.actual - the "actual" Class.expectedFields - all the fields that are expected to be in the class.java.lang.AssertionError - if actual is null.java.lang.AssertionError - if fields are not all the fields of the actual Class.private static java.util.Set<java.lang.String> fieldsToName(java.util.Set<java.lang.reflect.Field> fields)
public void assertHasMethods(AssertionInfo info, java.lang.Class<?> actual, java.lang.String... methods)
Class has the methods.info - contains information about the assertion.actual - the "actual" Class.methods - the methods who must be present in the class.java.lang.AssertionError - if actual is null.java.lang.AssertionError - if the actual Class doesn't contains all of the methods.public void assertHasDeclaredMethods(AssertionInfo info, java.lang.Class<?> actual, java.lang.String... methods)
Class has the declared methods.info - contains information about the assertion.actual - the "actual" Class.methods - the methods who must be declared in the class.java.lang.AssertionError - if actual is null.java.lang.AssertionError - if the actual Class doesn't contains all of the methods.private void doAssertHasMethods(AssertionInfo info, java.lang.Class<?> actual, java.util.Set<java.lang.reflect.Method> actualMethods, boolean declared, java.lang.String... expectedMethods)
public void assertHasPublicMethods(AssertionInfo info, java.lang.Class<?> actual, java.lang.String... methods)
Class has the public methods.info - contains information about the assertion.actual - the "actual" Class.methods - the public methods who must be present in the class.java.lang.AssertionError - if actual is null.java.lang.AssertionError - if the actual Class doesn't contains all of the public methods.private static java.util.SortedSet<java.lang.String> getMethodsWithModifier(java.util.Set<java.lang.reflect.Method> methods,
int modifier)
private static boolean noNonMatchingModifier(java.util.Set<java.lang.String> expectedMethodNames,
java.util.Map<java.lang.String,java.lang.Integer> methodsModifier,
java.util.Map<java.lang.String,java.lang.String> nonMatchingModifiers,
int modifier)
private static boolean hasPublicMethods(java.lang.reflect.Method[] methods)
private static java.util.SortedSet<java.lang.String> methodsToName(java.util.Set<java.lang.reflect.Method> methods)
private static java.util.Map<java.lang.String,java.lang.Integer> methodsToNameAndModifier(java.lang.reflect.Method[] methods)
private static java.lang.reflect.Method[] getAllMethods(java.lang.Class<?> actual)
private static <M extends java.lang.reflect.Member> java.util.Set<M> filterSyntheticMembers(M[] members)
private static void assertNotNull(AssertionInfo info, java.lang.Class<?> actual)
private static void classParameterIsNotNull(java.lang.Class<?> clazz)
NullPointerException with an
explicit message.clazz - the date to checkjava.lang.NullPointerException - with an explicit message if the given class is null