18
18
19
19
/**
20
20
* Base class for all implementations of assertions for {@link Class}es.
21
- *
21
+ *
22
22
* @param <SELF> the "self" type of this assertion class. Please read "<a href="http://bit.ly/1IZIRcY"
23
23
* target="_blank">Emulating 'self types' using Java Generics to simplify fluent API implementation</a>"
24
24
* for more details.
25
- *
25
+ *
26
26
* @author William Delanoue
27
27
* @author Mikhail Mazursky
28
28
*/
@@ -41,13 +41,13 @@ public AbstractClassAssert(Class<?> actual, Class<?> selfType) {
41
41
* Example:
42
42
* <pre><code class='java'> class Jedi {}
43
43
* class HumanJedi extends Jedi {}
44
- *
44
+ *
45
45
* // this assertion succeeds:
46
46
* assertThat(Jedi.class).isAssignableFrom(HumanJedi.class);
47
- *
47
+ *
48
48
* // this assertion fails:
49
49
* assertThat(HumanJedi.class).isAssignableFrom(Jedi.class);</code></pre>
50
- *
50
+ *
51
51
* @see Class#isAssignableFrom(Class)
52
52
* @param others {@code Class} who can be assignable from.
53
53
* @return {@code this} assertions object
@@ -66,13 +66,13 @@ public SELF isAssignableFrom(Class<?>... others) {
66
66
* Example:
67
67
* <pre><code class='java'> interface Jedi {}
68
68
* class HumanJedi implements Jedi {}
69
- *
69
+ *
70
70
* // this assertion succeeds:
71
71
* assertThat(HumanJedi.class).isNotInterface();
72
- *
72
+ *
73
73
* // this assertion fails:
74
74
* assertThat(Jedi.class).isNotInterface();</code></pre>
75
- *
75
+ *
76
76
* @return {@code this} assertions object
77
77
* @throws AssertionError if {@code actual} is {@code null}.
78
78
* @throws AssertionError if the actual {@code Class} is not an interface.
@@ -88,13 +88,13 @@ public SELF isNotInterface() {
88
88
* Example:
89
89
* <pre><code class='java'> interface Jedi {}
90
90
* class HumanJedi implements Jedi {}
91
- *
91
+ *
92
92
* // this assertion succeeds:
93
93
* assertThat(Jedi.class).isInterface();
94
- *
94
+ *
95
95
* // this assertion fails:
96
96
* assertThat(HumanJedi.class).isInterface();</code></pre>
97
- *
97
+ *
98
98
* @return {@code this} assertions object
99
99
* @throws AssertionError if {@code actual} is {@code null}.
100
100
* @throws AssertionError if the actual {@code Class} is not an interface.
@@ -132,15 +132,15 @@ public SELF isAbstract() {
132
132
* <p>
133
133
* Example:
134
134
* <pre><code class='java'> public @interface Jedi {}
135
- *
135
+ *
136
136
* // these assertions succeed:
137
137
* assertThat(Jedi.class).isAnnotation();
138
138
* assertThat(Override.class).isAnnotation();
139
139
* assertThat(Deprecated.class).isAnnotation();
140
- *
140
+ *
141
141
* // this assertion fails:
142
142
* assertThat(String.class).isAnnotation();</code></pre>
143
- *
143
+ *
144
144
* @return {@code this} assertions object
145
145
* @throws AssertionError if {@code actual} is {@code null}.
146
146
* @throws AssertionError if the actual {@code Class} is not an annotation.
@@ -155,15 +155,15 @@ public SELF isAnnotation() {
155
155
* <p>
156
156
* Example:
157
157
* <pre><code class='java'> public @interface Jedi {}
158
- *
158
+ *
159
159
* // this assertion succeeds:
160
160
* assertThat(String.class).isNotAnnotation();
161
- *
161
+ *
162
162
* // these assertions fail:
163
163
* assertThat(Jedi.class).isNotAnnotation();
164
164
* assertThat(Override.class).isNotAnnotation();
165
165
* assertThat(Deprecated.class).isNotAnnotation();</code></pre>
166
- *
166
+ *
167
167
* @return {@code this} assertions object
168
168
* @throws AssertionError if {@code actual} is {@code null}.
169
169
* @throws AssertionError if the actual {@code Class} is an annotation.
@@ -294,24 +294,24 @@ public SELF isPackagePrivate() {
294
294
* <pre><code class='java'> @Target(ElementType.TYPE)
295
295
* @Retention(RetentionPolicy.RUNTIME)
296
296
* private static @interface Force { }
297
- *
297
+ *
298
298
* @Target(ElementType.TYPE)
299
299
* @Retention(RetentionPolicy.RUNTIME)
300
300
* private static @interface Hero { }
301
- *
301
+ *
302
302
* @Target(ElementType.TYPE)
303
303
* @Retention(RetentionPolicy.RUNTIME)
304
304
* private static @interface DarkSide { }
305
- *
305
+ *
306
306
* @Hero @Force
307
307
* class Jedi implements Jedi {}
308
- *
308
+ *
309
309
* // this assertion succeeds:
310
310
* assertThat(Jedi.class).containsAnnotations(Force.class, Hero.class);
311
- *
311
+ *
312
312
* // this assertion fails:
313
313
* assertThat(Jedi.class).containsAnnotations(Force.class, DarkSide.class);</code></pre>
314
- *
314
+ *
315
315
* @param annotations annotations who must be attached to the class
316
316
* @return {@code this} assertions object
317
317
* @throws AssertionError if {@code actual} is {@code null}.
@@ -331,13 +331,13 @@ public SELF hasAnnotations(@SuppressWarnings("unchecked") Class<? extends Annota
331
331
* private static @interface Force { }
332
332
* @Force
333
333
* class Jedi implements Jedi {}
334
- *
334
+ *
335
335
* // this assertion succeeds:
336
336
* assertThat(Jedi.class).containsAnnotation(Force.class);
337
- *
337
+ *
338
338
* // this assertion fails:
339
339
* assertThat(Jedi.class).containsAnnotation(DarkSide.class);</code></pre>
340
- *
340
+ *
341
341
* @param annotation annotations who must be attached to the class
342
342
* @return {@code this} assertions object
343
343
* @throws AssertionError if {@code actual} is {@code null}.
@@ -402,7 +402,7 @@ public SELF hasSuperclass(Class<?> superclass) {
402
402
* assertThat(Void.TYPE).hasNoSuperclass();
403
403
*
404
404
* // this assertion fails as Integer has Number as superclass:
405
- * assertThat(Integer.class).hasSuperclass (Number.class);</code></pre>
405
+ * assertThat(Integer.class).hasNoSuperclass (Number.class);</code></pre>
406
406
*
407
407
* @return {@code this} assertions object
408
408
* @throws AssertionError if {@code actual} is {@code null}.
@@ -435,18 +435,18 @@ public SELF hasFields(String... fields) {
435
435
* String fieldThree;
436
436
* private String fieldFour;
437
437
* }
438
- *
438
+ *
439
439
* // this assertion succeeds:
440
440
* assertThat(MyClass.class).hasPublicFields("fieldOne");
441
- *
441
+ *
442
442
* // these assertions fail:
443
443
* assertThat(MyClass.class).hasPublicFields("fieldTwo");
444
444
* assertThat(MyClass.class).hasPublicFields("fieldThree");
445
445
* assertThat(MyClass.class).hasPublicFields("fieldFour");
446
446
* assertThat(MyClass.class).hasPublicFields("unknownField");</code></pre>
447
447
* <p>
448
448
* The assertion succeeds if no given fields are passed and the actual {@code Class} has no accessible public fields.
449
- *
449
+ *
450
450
* @see Class#getField(String)
451
451
* @param fields the fields who must be in the class.
452
452
* @return {@code this} assertions object
@@ -459,7 +459,7 @@ public SELF hasPublicFields(String... fields) {
459
459
}
460
460
461
461
/**
462
- * Verifies that the actual {@code Class} <b>only</b> has the given accessible public
462
+ * Verifies that the actual {@code Class} <b>only</b> has the given accessible public
463
463
* fields (as in {@link Class#getFields()}) and nothing more <b>in any order</b>.
464
464
* <p>
465
465
* Example:
@@ -499,15 +499,15 @@ public SELF hasOnlyPublicFields(String... fields) {
499
499
* public String fieldOne;
500
500
* private String fieldTwo;
501
501
* }
502
- *
502
+ *
503
503
* // this assertion succeeds:
504
504
* assertThat(MyClass.class).hasDeclaredFields("fieldOne", "fieldTwo");
505
- *
505
+ *
506
506
* // this assertion fails:
507
507
* assertThat(MyClass.class).hasDeclaredFields("fieldThree");</code></pre>
508
508
* <p>
509
509
* The assertion succeeds if no given fields are passed and the actual {@code Class} has no declared fields.
510
- *
510
+ *
511
511
* @see Class#getDeclaredField(String)
512
512
* @param fields the fields who must be declared in the class.
513
513
* @return {@code this} assertions object
@@ -520,7 +520,7 @@ public SELF hasDeclaredFields(String... fields) {
520
520
}
521
521
522
522
/**
523
- * Verifies that the actual {@code Class} <b>only</b> has the given declared {@code fields} and nothing more <b>in any order</b>
523
+ * Verifies that the actual {@code Class} <b>only</b> has the given declared {@code fields} and nothing more <b>in any order</b>
524
524
* (as in {@link Class#getDeclaredFields()}).
525
525
* <p>
526
526
* Example:
0 commit comments