1 /*
2  * JTiger Unit Testing Framework for J2SE 1.5
3  * Copyright (C) 2005 Tony Morris
4  *
5  * This software is licenced under the
6  * Common Public Licence version 1.0
7  * http://www.opensource.org/licenses/cpl1.0.php
8  *
9  * You received a copy of this licence with this software.
10  */
11 package org.jtiger.assertion;
12 
13 import java.lang.reflect.Constructor;
14 import java.lang.reflect.Field;
15 import java.lang.reflect.Method;
16 import static org.jtiger.assertion.ModifierTesterFactory.newModifierTester;
17 
18 /**
19  * Provides the ability make assertions that modifiers appear or do not appear on various language constructs, such as
20  * types (i.e. classes, interfaces, enums and annotations), constructors, methods and fields.
21  *
22  * @see java.lang.reflect.Modifier
23  * @author Tony Morris
24  * @version 2.1<br/>
25  *          <i>Build Number 0376</i><br/>
26  *          <i>Build Time 2006-07-28 01:50.16.218 CET (GMT + 1)</i>
27  */
28 public final class Modifier
29 {
Modifier()30     private Modifier()
31     {
32 
33     }
34 
35     /**
36      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> has the
37      * <code>abstract</code> modifier (implicitly or explicitly).
38      * The Java Language Specification defines that interface methods are implicitly abstract.
39      *
40      * @param m The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> to assert has the
41      * <code>abstract</code> modifier (implicitly or explicitly).
42      * @param message The assertion message.
43      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> does not
44      * have the <code>abstract</code> modifier (implicitly or explicitly).
45      */
assertAbstract(final Method m, final Object... message)46     public static void assertAbstract(final Method m, final Object... message) throws AssertionException
47     {
48         final ModifierTester tester = newModifierTester();
49 
50         if(!tester.isAbstract(m))
51         {
52             throw new AssertionException(message);
53         }
54     }
55 
56     /**
57      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> does not have the
58      * <code>abstract</code> modifier (implicitly or explicitly).
59      * The Java Language Specification defines that interface methods are implicitly abstract.
60      *
61      * @param m The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> to assert does not have the
62      * <code>abstract</code> modifier (implicitly or explicitly).
63      * @param message The assertion message.
64      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> has the
65      * <code>abstract</code> modifier (implicitly or explicitly).
66      */
assertNotAbstract(final Method m, final Object... message)67     public static void assertNotAbstract(final Method m, final Object... message) throws AssertionException
68     {
69         final ModifierTester tester = newModifierTester();
70 
71         if(tester.isAbstract(m))
72         {
73             throw new AssertionException(message);
74         }
75     }
76 
77     /**
78      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> has the
79      * <code>abstract</code> modifier (implicitly or explicitly).
80      * The Java Language Specification defines that interfaces are implicitly abstract.
81      *
82      * @param c The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> to assert has the
83      * <code>abstract</code> modifier (implicitly or explicitly).
84      * @param message The assertion message.
85      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> does not have the
86      * <code>abstract</code> modifier (implicitly or explicitly).
87      */
assertAbstract(final Class<?> c, final Object... message)88     public static void assertAbstract(final Class<?> c, final Object... message) throws AssertionException
89     {
90         final ModifierTester tester = newModifierTester();
91 
92         if(!tester.isAbstract(c))
93         {
94             throw new AssertionException(message);
95         }
96     }
97 
98     /**
99      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> does not have the
100      * <code>abstract</code> modifier (implicitly or explicitly).
101      * The Java Language Specification defines that interfaces are implicitly abstract.
102      *
103      * @param c The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> to assert does not have the
104      * <code>abstract</code> modifier (implicitly or explicitly).
105      * @param message The assertion message.
106      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> has the
107      * <code>abstract</code> modifier (implicitly or explicitly).
108      */
assertNotAbstract(final Class<?> c, final Object... message)109     public static void assertNotAbstract(final Class<?> c, final Object... message) throws AssertionException
110     {
111         final ModifierTester tester = newModifierTester();
112 
113         if(tester.isAbstract(c))
114         {
115             throw new AssertionException(message);
116         }
117     }
118 
119     /**
120      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> has the
121      * <code>final</code> modifier.
122      *
123      * @param m The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> to assert has the
124      * <code>final</code> modifier.
125      * @param message The assertion message.
126      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> does not
127      * have the <code>final</code> modifier.
128      */
assertFinal(final Method m, final Object... message)129     public static void assertFinal(final Method m, final Object... message) throws AssertionException
130     {
131         final ModifierTester tester = newModifierTester();
132 
133         if(!tester.isFinal(m))
134         {
135             throw new AssertionException(message);
136         }
137     }
138 
139     /**
140      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> does not have the
141      * <code>final</code> modifier.
142      *
143      * @param m The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> to assert does not have the
144      * <code>final</code> modifier.
145      * @param message The assertion message.
146      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> has the
147      * <code>final</code> modifier.
148      */
assertNotFinal(final Method m, final Object... message)149     public static void assertNotFinal(final Method m, final Object... message) throws AssertionException
150     {
151         final ModifierTester tester = newModifierTester();
152 
153         if(tester.isFinal(m))
154         {
155             throw new AssertionException(message);
156         }
157     }
158 
159     /**
160      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> has the
161      * <code>final</code> modifier (implicitly or explicitly).
162      * The Java Language Specification defines that inner classes of interfaces, and enums are
163      * implicitly final.
164      *
165      * @param c The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> to assert has the
166      * <code>final</code> modifier (implicitly or explicitly).
167      * @param message The assertion message.
168      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> does not have the
169      * <code>final</code> modifier (implicitly or explicitly).
170      */
assertFinal(final Class<?> c, final Object... message)171     public static void assertFinal(final Class<?> c, final Object... message) throws AssertionException
172     {
173         final ModifierTester tester = newModifierTester();
174 
175         if(!tester.isFinal(c))
176         {
177             throw new AssertionException(message);
178         }
179     }
180 
181     /**
182      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> does not have the
183      * <code>final</code> modifier (implicitly or explicitly).
184      * The Java Language Specification defines that inner classes of interfaces, and enums are
185      * implicitly final.
186      *
187      * @param c The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> to assert does not have the
188      * <code>final</code> modifier (implicitly or explicitly).
189      * @param message The assertion message.
190      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> has the
191      * <code>final</code> modifier (implicitly or explicitly).
192      */
assertNotFinal(final Class<?> c, final Object... message)193     public static void assertNotFinal(final Class<?> c, final Object... message) throws AssertionException
194     {
195         final ModifierTester tester = newModifierTester();
196 
197         if(tester.isFinal(c))
198         {
199             throw new AssertionException(message);
200         }
201     }
202 
203     /**
204      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> has the
205      * <code>final</code> modifier (implicitly or explicitly).
206      * The Java Language Specification defines that interface fields are implicitly final.
207      *
208      * @param f The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> to assert has the
209      * <code>final</code> modifier.
210      * @param message The assertion message.
211      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> does not
212      * have the <code>final</code> modifier (implicitly or explicitly).
213      */
assertFinal(final Field f, final Object... message)214     public static void assertFinal(final Field f, final Object... message) throws AssertionException
215     {
216         final ModifierTester tester = newModifierTester();
217 
218         if(!tester.isFinal(f))
219         {
220             throw new AssertionException(message);
221         }
222     }
223 
224     /**
225      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> does not have the
226      * <code>final</code> modifier (implicitly or explicitly).
227      * The Java Language Specification defines that interface fields are implicitly final.
228      *
229      * @param f The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> to assert does not have the
230      * <code>final</code> modifier.
231      * @param message The assertion message.
232      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> has the
233      * <code>final</code> modifier (implicitly or explicitly).
234      */
assertNotFinal(final Field f, final Object... message)235     public static void assertNotFinal(final Field f, final Object... message) throws AssertionException
236     {
237         final ModifierTester tester = newModifierTester();
238 
239         if(tester.isFinal(f))
240         {
241             throw new AssertionException(message);
242         }
243     }
244 
245     /**
246      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> has the
247      * <code>native</code> modifier.
248      *
249      * @param m The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> to assert has the
250      * <code>native</code> modifier.
251      * @param message The assertion message.
252      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> does not
253      * have the <code>native</code> modifier.
254      */
assertNative(final Method m, final Object... message)255     public static void assertNative(final Method m, final Object... message) throws AssertionException
256     {
257         final ModifierTester tester = newModifierTester();
258 
259         if(!tester.isNative(m))
260         {
261             throw new AssertionException(message);
262         }
263     }
264 
265     /**
266      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> does not have the
267      * <code>native</code> modifier.
268      *
269      * @param m The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> to assert does not have the
270      * <code>native</code> modifier.
271      * @param message The assertion message.
272      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> has the
273      * <code>native</code> modifier.
274      */
assertNotNative(final Method m, final Object... message)275     public static void assertNotNative(final Method m, final Object... message) throws AssertionException
276     {
277         final ModifierTester tester = newModifierTester();
278 
279         if(tester.isNative(m))
280         {
281             throw new AssertionException(message);
282         }
283     }
284 
285     /**
286      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> has the
287      * <code>private</code> modifier.
288      *
289      * @param m The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> to assert has the
290      * <code>private</code> modifier.
291      * @param message The assertion message.
292      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> does not
293      * have the <code>private</code> modifier.
294      */
assertPrivate(final Method m, final Object... message)295     public static void assertPrivate(final Method m, final Object... message) throws AssertionException
296     {
297         final ModifierTester tester = newModifierTester();
298 
299         if(!tester.isPrivate(m))
300         {
301             throw new AssertionException(message);
302         }
303     }
304 
305     /**
306      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> does not have the
307      * <code>private</code> modifier.
308      *
309      * @param m The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> to assert does not have the
310      * <code>private</code> modifier.
311      * @param message The assertion message.
312      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> has the
313      * <code>private</code> modifier.
314      */
assertNotPrivate(final Method m, final Object... message)315     public static void assertNotPrivate(final Method m, final Object... message) throws AssertionException
316     {
317         final ModifierTester tester = newModifierTester();
318 
319         if(tester.isPrivate(m))
320         {
321             throw new AssertionException(message);
322         }
323     }
324 
325     /**
326      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Constructor.html">Constructor</a> has the
327      * <code>private</code> modifier (implicitly or explicitly).
328      * The Java Language Specification defines that enum constructors are implicitly private.
329      *
330      * @param c The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Constructor.html">Constructor</a> to assert has the
331      * <code>private</code> modifier.
332      * @param message The assertion message.
333      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Constructor.html">Constructor</a>
334      * does not have the <code>private</code> modifier (implicitly or explicitly).
335      */
assertPrivate(final Constructor<?> c, final Object... message)336     public static void assertPrivate(final Constructor<?> c, final Object... message) throws AssertionException
337     {
338         final ModifierTester tester = newModifierTester();
339 
340         if(!tester.isPrivate(c))
341         {
342             throw new AssertionException(message);
343         }
344     }
345 
346     /**
347      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Constructor.html">Constructor</a> does not have
348      * the <code>private</code> modifier (implicitly or explicitly).
349      * The Java Language Specification defines that enum constructors are implicitly private.
350      *
351      * @param c The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Constructor.html">Constructor</a> to assert does not have
352      * the <code>private</code> modifier.
353      * @param message The assertion message.
354      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Constructor.html">Constructor</a>
355      * has the <code>private</code> modifier (implicitly or explicitly).
356      */
assertNotPrivate(final Constructor<?> c, final Object... message)357     public static void assertNotPrivate(final Constructor<?> c, final Object... message) throws AssertionException
358     {
359         final ModifierTester tester = newModifierTester();
360 
361         if(tester.isPrivate(c))
362         {
363             throw new AssertionException(message);
364         }
365     }
366 
367     /**
368      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> has the
369      * <code>private</code> modifier.
370      *
371      * @param c The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> to assert has the
372      * <code>private</code> modifier.
373      * @param message The assertion message.
374      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> does not have the
375      * <code>private</code> modifier.
376      */
assertPrivate(final Class<?> c, final Object... message)377     public static void assertPrivate(final Class<?> c, final Object... message) throws AssertionException
378     {
379         final ModifierTester tester = newModifierTester();
380 
381         if(!tester.isPrivate(c))
382         {
383             throw new AssertionException(message);
384         }
385     }
386 
387     /**
388      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> does not have the
389      * <code>private</code> modifier.
390      *
391      * @param c The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> to assert does not have the
392      * <code>private</code> modifier.
393      * @param message The assertion message.
394      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> has the
395      * <code>private</code> modifier.
396      */
assertNotPrivate(final Class<?> c, final Object... message)397     public static void assertNotPrivate(final Class<?> c, final Object... message) throws AssertionException
398     {
399         final ModifierTester tester = newModifierTester();
400 
401         if(tester.isPrivate(c))
402         {
403             throw new AssertionException(message);
404         }
405     }
406 
407     /**
408      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> has the
409      * <code>private</code> modifier (implicitly or explicitly).
410      * The Java Language Specification defines that interface fields are implicitly private.
411      *
412      * @param f The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> to assert has the
413      * <code>private</code> modifier.
414      * @param message The assertion message.
415      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> does not
416      * have the <code>private</code> modifier (implicitly or explicitly).
417      */
assertPrivate(final Field f, final Object... message)418     public static void assertPrivate(final Field f, final Object... message) throws AssertionException
419     {
420         final ModifierTester tester = newModifierTester();
421 
422         if(!tester.isPrivate(f))
423         {
424             throw new AssertionException(message);
425         }
426     }
427 
428     /**
429      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> does not have the
430      * <code>private</code> modifier (implicitly or explicitly).
431      * The Java Language Specification defines that interface fields are implicitly private.
432      *
433      * @param f The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> to assert does not have the
434      * <code>private</code> modifier.
435      * @param message The assertion message.
436      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> has the
437      * <code>private</code> modifier (implicitly or explicitly).
438      */
assertNotPrivate(final Field f, final Object... message)439     public static void assertNotPrivate(final Field f, final Object... message) throws AssertionException
440     {
441         final ModifierTester tester = newModifierTester();
442 
443         if(tester.isPrivate(f))
444         {
445             throw new AssertionException(message);
446         }
447     }
448 
449     /**
450      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> has the
451      * <code>protected</code> modifier.
452      *
453      * @param m The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> to assert has the
454      * <code>protected</code> modifier.
455      * @param message The assertion message.
456      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> does not
457      * have the <code>protected</code> modifier.
458      */
assertProtected(final Method m, final Object... message)459     public static void assertProtected(final Method m, final Object... message) throws AssertionException
460     {
461         final ModifierTester tester = newModifierTester();
462 
463         if(!tester.isProtected(m))
464         {
465             throw new AssertionException(message);
466         }
467     }
468 
469     /**
470      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> does not have the
471      * <code>protected</code> modifier.
472      *
473      * @param m The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> to assert does not have the
474      * <code>protected</code> modifier.
475      * @param message The assertion message.
476      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> has the
477      * <code>protected</code> modifier.
478      */
assertNotProtected(final Method m, final Object... message)479     public static void assertNotProtected(final Method m, final Object... message) throws AssertionException
480     {
481         final ModifierTester tester = newModifierTester();
482 
483         if(tester.isProtected(m))
484         {
485             throw new AssertionException(message);
486         }
487     }
488 
489     /**
490      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Constructor.html">Constructor</a> has the
491      * <code>protected</code> modifier.
492      *
493      * @param c The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Constructor.html">Constructor</a> to assert has the
494      * <code>protected</code> modifier.
495      * @param message The assertion message.
496      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Constructor.html">Constructor</a>
497      * does not have the <code>protected</code> modifier.
498      */
assertProtected(final Constructor<?> c, final Object... message)499     public static void assertProtected(final Constructor<?> c, final Object... message) throws AssertionException
500     {
501         final ModifierTester tester = newModifierTester();
502 
503         if(!tester.isProtected(c))
504         {
505             throw new AssertionException(message);
506         }
507     }
508 
509     /**
510      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Constructor.html">Constructor</a> does not have
511      * the <code>protected</code> modifier.
512      *
513      * @param c The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Constructor.html">Constructor</a> to assert does not have
514      * the <code>protected</code> modifier.
515      * @param message The assertion message.
516      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Constructor.html">Constructor</a>
517      * has the <code>protected</code> modifier.
518      */
assertNotProtected(final Constructor<?> c, final Object... message)519     public static void assertNotProtected(final Constructor<?> c, final Object... message) throws AssertionException
520     {
521         final ModifierTester tester = newModifierTester();
522 
523         if(tester.isProtected(c))
524         {
525             throw new AssertionException(message);
526         }
527     }
528 
529     /**
530      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> has the
531      * <code>protected</code> modifier.
532      *
533      * @param c The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> to assert has the
534      * <code>protected</code> modifier.
535      * @param message The assertion message.
536      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> does not have the
537      * <code>protected</code> modifier.
538      */
assertProtected(final Class<?> c, final Object... message)539     public static void assertProtected(final Class<?> c, final Object... message) throws AssertionException
540     {
541         final ModifierTester tester = newModifierTester();
542 
543         if(!tester.isProtected(c))
544         {
545             throw new AssertionException(message);
546         }
547     }
548 
549     /**
550      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> does not have the
551      * <code>protected</code> modifier.
552      *
553      * @param c The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> to assert does not have the
554      * <code>protected</code> modifier.
555      * @param message The assertion message.
556      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> has the
557      * <code>protected</code> modifier.
558      */
assertNotProtected(final Class<?> c, final Object... message)559     public static void assertNotProtected(final Class<?> c, final Object... message) throws AssertionException
560     {
561         final ModifierTester tester = newModifierTester();
562 
563         if(tester.isProtected(c))
564         {
565             throw new AssertionException(message);
566         }
567     }
568 
569     /**
570      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> has the
571      * <code>protected</code> modifier.
572      *
573      * @param f The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> to assert has the
574      * <code>protected</code> modifier.
575      * @param message The assertion message.
576      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> does not
577      * have the <code>protected</code> modifier.
578      */
assertProtected(final Field f, final Object... message)579     public static void assertProtected(final Field f, final Object... message) throws AssertionException
580     {
581         final ModifierTester tester = newModifierTester();
582 
583         if(!tester.isProtected(f))
584         {
585             throw new AssertionException(message);
586         }
587     }
588 
589     /**
590      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> does not have the
591      * <code>protected</code> modifier.
592      *
593      * @param f The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> to assert does not have the
594      * <code>protected</code> modifier.
595      * @param message The assertion message.
596      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> has the
597      * <code>protected</code> modifier.
598      */
assertNotProtected(final Field f, final Object... message)599     public static void assertNotProtected(final Field f, final Object... message) throws AssertionException
600     {
601         final ModifierTester tester = newModifierTester();
602 
603         if(tester.isProtected(f))
604         {
605             throw new AssertionException(message);
606         }
607     }
608 
609     /**
610      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> has the
611      * <code>public</code> modifier (implicitly or explicitly).
612      * The Java Language Specification defines that interface methods are implicitly public.
613      *
614      * @param m The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> to assert has the
615      * <code>public</code> modifier.
616      * @param message The assertion message.
617      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> does not
618      * have the <code>public</code> modifier (implicitly or explicitly).
619      */
assertPublic(final Method m, final Object... message)620     public static void assertPublic(final Method m, final Object... message) throws AssertionException
621     {
622         final ModifierTester tester = newModifierTester();
623 
624         if(!tester.isPublic(m))
625         {
626             throw new AssertionException(message);
627         }
628     }
629 
630     /**
631      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> does not have the
632      * <code>public</code> modifier (implicitly or explicitly).
633      * The Java Language Specification defines that interface methods are implicitly public.
634      *
635      * @param m The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> to assert does not have the
636      * <code>public</code> modifier.
637      * @param message The assertion message.
638      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> has the
639      * <code>public</code> modifier (implicitly or explicitly).
640      */
assertNotPublic(final Method m, final Object... message)641     public static void assertNotPublic(final Method m, final Object... message) throws AssertionException
642     {
643         final ModifierTester tester = newModifierTester();
644 
645         if(tester.isPublic(m))
646         {
647             throw new AssertionException(message);
648         }
649     }
650 
651     /**
652      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Constructor.html">Constructor</a> has the
653      * <code>public</code> modifier.
654      *
655      * @param c The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Constructor.html">Constructor</a> to assert has the
656      * <code>public</code> modifier.
657      * @param message The assertion message.
658      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Constructor.html">Constructor</a>
659      * does not have the <code>public</code> modifier.
660      */
assertPublic(final Constructor<?> c, final Object... message)661     public static void assertPublic(final Constructor<?> c, final Object... message) throws AssertionException
662     {
663         final ModifierTester tester = newModifierTester();
664 
665         if(!tester.isPublic(c))
666         {
667             throw new AssertionException(message);
668         }
669     }
670 
671     /**
672      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Constructor.html">Constructor</a> does not have
673      * the <code>public</code> modifier.
674      *
675      * @param c The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Constructor.html">Constructor</a> to assert does not have
676      * the <code>public</code> modifier.
677      * @param message The assertion message.
678      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Constructor.html">Constructor</a>
679      * has the <code>public</code> modifier.
680      */
assertNotPublic(final Constructor<?> c, final Object... message)681     public static void assertNotPublic(final Constructor<?> c, final Object... message) throws AssertionException
682     {
683         final ModifierTester tester = newModifierTester();
684 
685         if(tester.isPublic(c))
686         {
687             throw new AssertionException(message);
688         }
689     }
690 
691     /**
692      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> has the
693      * <code>public</code> modifier (implicitly or explicitly).
694      * The Java Language Specification defines that inner classes of interfaces are implicitly public.
695      *
696      * @param c The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> to assert has the
697      * <code>public</code> modifier.
698      * @param message The assertion message.
699      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> does not have the
700      * <code>public</code> modifier (implicitly or explicitly).
701      */
assertPublic(final Class<?> c, final Object... message)702     public static void assertPublic(final Class<?> c, final Object... message) throws AssertionException
703     {
704         final ModifierTester tester = newModifierTester();
705 
706         if(!tester.isPublic(c))
707         {
708             throw new AssertionException(message);
709         }
710     }
711 
712     /**
713      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> does not have the
714      * <code>public</code> modifier (implicitly or explicitly).
715      * The Java Language Specification defines that inner classes of interfaces are implicitly public.
716      *
717      * @param c The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> to assert does not have the
718      * <code>public</code> modifier.
719      * @param message The assertion message.
720      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> has the
721      * <code>public</code> modifier (implicitly or explicitly).
722      */
assertNotPublic(final Class<?> c, final Object... message)723     public static void assertNotPublic(final Class<?> c, final Object... message) throws AssertionException
724     {
725         final ModifierTester tester = newModifierTester();
726 
727         if(tester.isPublic(c))
728         {
729             throw new AssertionException(message);
730         }
731     }
732 
733     /**
734      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> has the
735      * <code>public</code> modifier (implicitly or explicitly).
736      * The Java Language Specification defines that interface fields are implicitly public.
737      *
738      * @param f The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> to assert has the
739      * <code>public</code> modifier.
740      * @param message The assertion message.
741      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> does not
742      * have the <code>public</code> modifier (implicitly or explicitly).
743      */
assertPublic(final Field f, final Object... message)744     public static void assertPublic(final Field f, final Object... message) throws AssertionException
745     {
746         final ModifierTester tester = newModifierTester();
747 
748         if(!tester.isPublic(f))
749         {
750             throw new AssertionException(message);
751         }
752     }
753 
754     /**
755      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> does not have the
756      * <code>public</code> modifier (implicitly or explicitly).
757      * The Java Language Specification defines that interface fields are implicitly public.
758      *
759      * @param f The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> to assert does not have the
760      * <code>public</code> modifier.
761      * @param message The assertion message.
762      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> has the
763      * <code>public</code> modifier (implicitly or explicitly).
764      */
assertNotPublic(final Field f, final Object... message)765     public static void assertNotPublic(final Field f, final Object... message) throws AssertionException
766     {
767         final ModifierTester tester = newModifierTester();
768 
769         if(tester.isPublic(f))
770         {
771             throw new AssertionException(message);
772         }
773     }
774 
775     /**
776      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> has the default
777      * (none specified) access modifier.
778      *
779      * @param m The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> to assert has the default
780      * (none specified) access modifier.
781      * @param message The assertion message.
782      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> has an
783      * explicit access modifier (<code>private</code>, <code>protected</code>, or <code>public</code>).
784      */
assertDefaultAccess(final Method m, final Object... message)785     public static void assertDefaultAccess(final Method m, final Object... message) throws AssertionException
786     {
787         final ModifierTester tester = newModifierTester();
788 
789         if(!tester.isDefaultAccess(m))
790         {
791             throw new AssertionException(message);
792         }
793     }
794 
795     /**
796      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> does not have the
797      * default (none specified) access modifier.
798      *
799      * @param m The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> to assert does not have the
800      * default (none specified) access modifier.
801      * @param message The assertion message.
802      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> does not
803      * have an explicit access modifier (<code>private</code>, <code>protected</code>, or <code>public</code>).
804      */
assertNotDefaultAccess(final Method m, final Object... message)805     public static void assertNotDefaultAccess(final Method m, final Object... message) throws AssertionException
806     {
807         final ModifierTester tester = newModifierTester();
808 
809         if(tester.isDefaultAccess(m))
810         {
811             throw new AssertionException(message);
812         }
813     }
814 
815     /**
816      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Constructor.html">Constructor</a> has the
817      * default (none specified) access modifier.
818      *
819      * @param c The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Constructor.html">Constructor</a> to assert has
820      * the default (none specified) access modifier.
821      * @param message The assertion message.
822      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Constructor.html">Constructor</a>
823      * has an explicit access modifier (<code>private</code>, <code>protected</code>, or <code>public</code>).
824      */
assertDefaultAccess(final Constructor<?> c, final Object... message)825     public static void assertDefaultAccess(final Constructor<?> c, final Object... message) throws AssertionException
826     {
827         final ModifierTester tester = newModifierTester();
828 
829         if(!tester.isDefaultAccess(c))
830         {
831             throw new AssertionException(message);
832         }
833     }
834 
835     /**
836      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Constructor.html">Constructor</a> does not have
837      * the default (none specified) access modifier.
838      *
839      * @param c The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Constructor.html">Constructor</a> to assert does not have
840      * the default (none specified) access modifier.
841      * @param message The assertion message.
842      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Constructor.html">Constructor</a>
843      * does not have an explicit access modifier (<code>private</code>, <code>protected</code>, or <code>public</code>).
844      */
assertNotDefaultAccess(final Constructor<?> c, final Object... message)845     public static void assertNotDefaultAccess(final Constructor<?> c, final Object... message) throws AssertionException
846     {
847         final ModifierTester tester = newModifierTester();
848 
849         if(tester.isDefaultAccess(c))
850         {
851             throw new AssertionException(message);
852         }
853     }
854 
855     /**
856      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> has the default
857      * (none specified) access modifier.
858      *
859      * @param c The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> to assert has the default
860      * (none specified) access modifier.
861      * @param message The assertion message.
862      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> has an
863      * explicit access modifier (<code>private</code>, <code>protected</code>, or <code>public</code>).
864      */
assertDefaultAccess(final Class<?> c, final Object... message)865     public static void assertDefaultAccess(final Class<?> c, final Object... message) throws AssertionException
866     {
867         final ModifierTester tester = newModifierTester();
868 
869         if(!tester.isDefaultAccess(c))
870         {
871             throw new AssertionException(message);
872         }
873     }
874 
875     /**
876      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> does not have the default
877      * (none specified) access modifier.
878      *
879      * @param c The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> to assert does not have the default
880      * (none specified) access modifier.
881      * @param message The assertion message.
882      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> does not have an
883      * explicit access modifier (<code>private</code>, <code>protected</code>, or <code>public</code>).
884      */
assertNotDefaultAccess(final Class<?> c, final Object... message)885     public static void assertNotDefaultAccess(final Class<?> c, final Object... message) throws AssertionException
886     {
887         final ModifierTester tester = newModifierTester();
888 
889         if(tester.isDefaultAccess(c))
890         {
891             throw new AssertionException(message);
892         }
893     }
894 
895     /**
896      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> has the default
897      * (none specified) access modifier.
898      *
899      * @param f The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> to assert has the default
900      * (none specified) access modifier.
901      * @param message The assertion message.
902      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> has an
903      * explicit access modifier (<code>private</code>, <code>protected</code>, or <code>public</code>).
904      */
assertDefaultAccess(final Field f, final Object... message)905     public static void assertDefaultAccess(final Field f, final Object... message) throws AssertionException
906     {
907         final ModifierTester tester = newModifierTester();
908 
909         if(!tester.isDefaultAccess(f))
910         {
911             throw new AssertionException(message);
912         }
913     }
914 
915     /**
916      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> does not have the default
917      * (none specified) access modifier.
918      *
919      * @param f The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> to assert does not have the default
920      * (none specified) access modifier.
921      * @param message The assertion message.
922      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> does not have
923      * an explicit access modifier (<code>private</code>, <code>protected</code>, or <code>public</code>).
924      */
assertNotDefaultAccess(final Field f, final Object... message)925     public static void assertNotDefaultAccess(final Field f, final Object... message) throws AssertionException
926     {
927         final ModifierTester tester = newModifierTester();
928 
929         if(tester.isDefaultAccess(f))
930         {
931             throw new AssertionException(message);
932         }
933     }
934 
935     /**
936      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> has the
937      * <code>static</code> modifier.
938      *
939      * @param m The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> to assert has the
940      * <code>static</code> modifier.
941      * @param message The assertion message.
942      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> does not
943      * have the <code>static</code> modifier.
944      */
assertStatic(final Method m, final Object... message)945     public static void assertStatic(final Method m, final Object... message) throws AssertionException
946     {
947         final ModifierTester tester = newModifierTester();
948 
949         if(!tester.isStatic(m))
950         {
951             throw new AssertionException(message);
952         }
953     }
954 
955     /**
956      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> does not have the
957      * <code>static</code> modifier.
958      *
959      * @param m The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> to assert does not have the
960      * <code>static</code> modifier.
961      * @param message The assertion message.
962      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> has the
963      * <code>static</code> modifier.
964      */
assertNotStatic(final Method m, final Object... message)965     public static void assertNotStatic(final Method m, final Object... message) throws AssertionException
966     {
967         final ModifierTester tester = newModifierTester();
968 
969         if(tester.isStatic(m))
970         {
971             throw new AssertionException(message);
972         }
973     }
974 
975     /**
976      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> has the
977      * <code>static</code> modifier (implicitly or explicitly).
978      * The Java Language Specification defines that inner classes of interfaces are implicitly static.
979      *
980      * @param c The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> to assert has the
981      * <code>static</code> modifier.
982      * @param message The assertion message.
983      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> does not have the
984      * <code>static</code> modifier (implicitly or explicitly).
985      */
assertStatic(final Class<?> c, final Object... message)986     public static void assertStatic(final Class<?> c, final Object... message) throws AssertionException
987     {
988         final ModifierTester tester = newModifierTester();
989 
990         if(!tester.isStatic(c))
991         {
992             throw new AssertionException(message);
993         }
994     }
995 
996     /**
997      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> does not have the
998      * <code>static</code> modifier (implicitly or explicitly).
999      * The Java Language Specification defines that inner classes of interfaces are implicitly static.
1000      *
1001      * @param c The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> to assert does not have the
1002      * <code>static</code> modifier.
1003      * @param message The assertion message.
1004      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> has the
1005      * <code>static</code> modifier (implicitly or explicitly).
1006      */
assertNotStatic(final Class<?> c, final Object... message)1007     public static void assertNotStatic(final Class<?> c, final Object... message) throws AssertionException
1008     {
1009         final ModifierTester tester = newModifierTester();
1010 
1011         if(tester.isStatic(c))
1012         {
1013             throw new AssertionException(message);
1014         }
1015     }
1016 
1017     /**
1018      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> has the
1019      * <code>static</code> modifier (implicitly or explicitly).
1020      * The Java Language Specification defines that interface fields are implicitly static.
1021      *
1022      * @param f The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> to assert has the
1023      * <code>static</code> modifier.
1024      * @param message The assertion message.
1025      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> does not have
1026      * the <code>static</code> modifier (implicitly or explicitly).
1027      */
assertStatic(final Field f, final Object... message)1028     public static void assertStatic(final Field f, final Object... message) throws AssertionException
1029     {
1030         final ModifierTester tester = newModifierTester();
1031 
1032         if(!tester.isStatic(f))
1033         {
1034             throw new AssertionException(message);
1035         }
1036     }
1037 
1038     /**
1039      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> does not have the
1040      * <code>static</code> modifier (implicitly or explicitly).
1041      * The Java Language Specification defines that interface fields are implicitly static.
1042      *
1043      * @param f The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> to assert does not have the
1044      * <code>static</code> modifier.
1045      * @param message The assertion message.
1046      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> has the
1047      * <code>static</code> modifier (implicitly or explicitly).
1048      */
assertNotStatic(final Field f, final Object... message)1049     public static void assertNotStatic(final Field f, final Object... message) throws AssertionException
1050     {
1051         final ModifierTester tester = newModifierTester();
1052 
1053         if(tester.isStatic(f))
1054         {
1055             throw new AssertionException(message);
1056         }
1057     }
1058 
1059     /**
1060      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> has the
1061      * <code>strictfp</code> modifier (implicitly or explicitly).
1062      * The Java Language Specification defines that methods and all nested types of a strictfp class are implicitly
1063      * strictfp.
1064      *
1065      * @param c The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> to assert has the
1066      * <code>strictfp</code> modifier.
1067      * @param message The assertion message.
1068      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> does not have the
1069      * <code>strictfp</code> modifier (implicitly or explicitly).
1070      */
assertStrictfp(final Class<?> c, final Object... message)1071     public static void assertStrictfp(final Class<?> c, final Object... message) throws AssertionException
1072     {
1073         final ModifierTester tester = newModifierTester();
1074 
1075         if(!tester.isStrictfp(c))
1076         {
1077             throw new AssertionException(message);
1078         }
1079     }
1080 
1081     /**
1082      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> does not have the
1083      * <code>strictfp</code> modifier (implicitly or explicitly).
1084      * The Java Language Specification defines that methods and all nested types of a strictfp class are implicitly
1085      * strictfp.
1086      *
1087      * @param c The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> to assert does not have the
1088      * <code>strictfp</code> modifier.
1089      * @param message The assertion message.
1090      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html">Class</a> has the
1091      * <code>strictfp</code> modifier (implicitly or explicitly).
1092      */
assertNotStrictfp(final Class<?> c, final Object... message)1093     public static void assertNotStrictfp(final Class<?> c, final Object... message) throws AssertionException
1094     {
1095         final ModifierTester tester = newModifierTester();
1096 
1097         if(tester.isStrictfp(c))
1098         {
1099             throw new AssertionException(message);
1100         }
1101     }
1102 
1103     /**
1104      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> has the
1105      * <code>synchronized</code> modifier.
1106      *
1107      * @param m The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> to assert has the
1108      * <code>synchronized</code> modifier.
1109      * @param message The assertion message.
1110      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> does not
1111      * have the <code>synchronized</code> modifier.
1112      */
assertSynchronized(final Method m, final Object... message)1113     public static void assertSynchronized(final Method m, final Object... message) throws AssertionException
1114     {
1115         final ModifierTester tester = newModifierTester();
1116 
1117         if(!tester.isSynchronized(m))
1118         {
1119             throw new AssertionException(message);
1120         }
1121     }
1122 
1123     /**
1124      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> does not have the
1125      * <code>synchronized</code> modifier.
1126      *
1127      * @param m The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> to assert does not have the
1128      * <code>synchronized</code> modifier.
1129      * @param message The assertion message.
1130      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html">Method</a> has the
1131      * <code>synchronized</code> modifier.
1132      */
assertNotSynchronized(final Method m, final Object... message)1133     public static void assertNotSynchronized(final Method m, final Object... message) throws AssertionException
1134     {
1135         final ModifierTester tester = newModifierTester();
1136 
1137         if(tester.isSynchronized(m))
1138         {
1139             throw new AssertionException(message);
1140         }
1141     }
1142 
1143     /**
1144      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> has the
1145      * <code>transient</code> modifier.
1146      *
1147      * @param f The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> to assert has the
1148      * <code>transient</code> modifier.
1149      * @param message The assertion message.
1150      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> does not have
1151      * the <code>transient</code> modifier.
1152      */
assertTransient(final Field f, final Object... message)1153     public static void assertTransient(final Field f, final Object... message) throws AssertionException
1154     {
1155         final ModifierTester tester = newModifierTester();
1156 
1157         if(!tester.isTransient(f))
1158         {
1159             throw new AssertionException(message);
1160         }
1161     }
1162 
1163     /**
1164      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> does not have the
1165      * <code>transient</code> modifier.
1166      *
1167      * @param f The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> to assert does not have the
1168      * <code>transient</code> modifier.
1169      * @param message The assertion message.
1170      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> has the
1171      * <code>transient</code> modifier.
1172      */
assertNotTransient(final Field f, final Object... message)1173     public static void assertNotTransient(final Field f, final Object... message) throws AssertionException
1174     {
1175         final ModifierTester tester = newModifierTester();
1176 
1177         if(tester.isTransient(f))
1178         {
1179             throw new AssertionException(message);
1180         }
1181     }
1182 
1183     /**
1184      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> has the
1185      * <code>volatile</code> modifier.
1186      *
1187      * @param f The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> to assert has the
1188      * <code>volatile</code> modifier.
1189      * @param message The assertion message.
1190      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> does not have
1191      * the <code>volatile</code> modifier.
1192      */
assertVolatile(final Field f, final Object... message)1193     public static void assertVolatile(final Field f, final Object... message) throws AssertionException
1194     {
1195         final ModifierTester tester = newModifierTester();
1196 
1197         if(!tester.isVolatile(f))
1198         {
1199             throw new AssertionException(message);
1200         }
1201     }
1202 
1203     /**
1204      * Asserts that the given <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> does not have the
1205      * <code>volatile</code> modifier.
1206      *
1207      * @param f The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> to assert does not have the
1208      * <code>volatile</code> modifier.
1209      * @param message The assertion message.
1210      * @throws AssertionException If the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html">Field</a> has the
1211      * <code>volatile</code> modifier.
1212      */
assertNotVolatile(final Field f, final Object... message)1213     public static void assertNotVolatile(final Field f, final Object... message) throws AssertionException
1214     {
1215         final ModifierTester tester = newModifierTester();
1216 
1217         if(tester.isVolatile(f))
1218         {
1219             throw new AssertionException(message);
1220         }
1221     }
1222 }
1223