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.framework; |
12 | |
13 | final class FixtureNameFactory |
14 | { |
15 | private FixtureNameFactory() |
16 | { |
17 | |
18 | } |
19 | |
20 | static FixtureName newFixtureName() |
21 | { |
22 | return new FixtureNameImpl(); |
23 | } |
24 | |
25 | private static final class FixtureNameImpl implements FixtureName |
26 | { |
27 | FixtureNameImpl() |
28 | { |
29 | |
30 | } |
31 | |
32 | public String getFixtureName(final Class<?> c) throws NullPointerException |
33 | { |
34 | if(c == null) |
35 | { |
36 | throw new NullPointerException(); |
37 | } |
38 | |
39 | final Fixture f = c.getAnnotation(Fixture.class); |
40 | |
41 | if(f == null) |
42 | { |
43 | return c.getCanonicalName(); |
44 | } |
45 | |
46 | final String value = f.value(); |
47 | |
48 | if(value.length() == 0) |
49 | { |
50 | return c.getCanonicalName(); |
51 | } |
52 | else |
53 | { |
54 | return value; |
55 | } |
56 | } |
57 | } |
58 | } |