Annotation { public static Annotation of(@Nonnull final Class<?> annotationType) { Check.notNull(annotationType, "annotationType"); Check.stateIsTrue(annotationType.isAnnotation(), "requires an annotation"); return new Annotation(Type.of(annotationType)); } Annotation(final Type annotationType); static Annotation of(@Nonnull final Class<?> annotationType); static Annotation of(@Nonnull final java.lang.annotation.Annotation annotation); static Annotation of(@Nonnull final String annotationType); @Override boolean equals(final Object obj); Type getType(); @Override int hashCode(); boolean isImmutable(); boolean isNonnegative(); boolean isNonnull(); boolean isNotThreadSafe(); boolean isNullable(); @Override String toString(); static final Annotation IMMUTABLE; static final Annotation NONNEGATIVE; static final Annotation NONNULL; static final Annotation NOT_THREAD_SAFE; static final Annotation NULLABLE; }
@Test public void construct_isAnnotation() { assertNotNull(Annotation.of(Immutable.class)); }
@Test(expected = IllegalStateOfArgumentException.class) public void construct_isNotAnnotation() { assertNotNull(Annotation.of(String.class)); }
@Test public void construct_withAnnotation() throws SecurityException, NoSuchMethodException { assertEquals(Annotation.of(TestAnnotation.class), Annotation.of(TestClass.class.getAnnotation(TestAnnotation.class))); }
@Test public void construct_withQualifiedName() { assertNotNull(Annotation.of(Immutable.class.getName())); }
@Test public void equals_identical() { final Annotation immutable1 = Annotation.of(Immutable.class); final Annotation immutable2 = Annotation.of(Immutable.class); assertEquals(immutable1, immutable2); assertEquals(Annotation.IMMUTABLE, immutable2); }
@Test public void equals_same() { final Annotation immutable = Annotation.of(Immutable.class); assertEquals(immutable, immutable); assertSame(immutable, immutable); }