A BasicClassIdentity is a ClassIdentity designed to wrap a Class. This has no further information designed to be considered or loaded into the object at construction. @param The Format (Class) of the object represented by this ClassIdentity.
| 27 | * The Format (Class) of the object represented by this ClassIdentity. |
| 28 | */ |
| 29 | public class BasicClassIdentity<T> implements ClassIdentity<T> |
| 30 | { |
| 31 | |
| 32 | /** |
| 33 | * The underlying Class for this BasicClassIdentity. This is what the |
| 34 | * BasicClassIdentity represents. |
| 35 | */ |
| 36 | private final Class<T> underlyingClass; |
| 37 | |
| 38 | /** |
| 39 | * Constructs a new BasicClassIdentity for the given Class. |
| 40 | * |
| 41 | * @param cl |
| 42 | * The Class for which a BasicClassIdentity should be constructed |
| 43 | */ |
| 44 | public BasicClassIdentity(Class<T> cl) |
| 45 | { |
| 46 | /* |
| 47 | * CONSIDER In theory, a Categorized object isn't great if it lands here, but we |
| 48 | * have the challenge of an initial load where the CATEGORY is a separate token. |
| 49 | * So that will now happen and can't be an error condition. |
| 50 | * |
| 51 | * It might be best if a specific file can't have more than one CATEGORY (and thus |
| 52 | * CATEGORY can't be reassigned), although that could also be annoying to the data |
| 53 | * team. Needs further evaluation after Dynamic is fully used in new data and we |
| 54 | * see just how many abilities there really are... |
| 55 | * |
| 56 | * An alternative is to have a prefix on the line in an ABILITY file that has the |
| 57 | * Category (much like Dynamic objects) rather than having it as a separate token. |
| 58 | * Either way, both this situation as well as the whole "can reassign a CATEGORY" |
| 59 | * are unique exceptions that it would be nice to get rid of someday. |
| 60 | */ |
| 61 | underlyingClass = Objects.requireNonNull(cl); |
| 62 | try |
| 63 | { |
| 64 | underlyingClass.newInstance(); |
| 65 | } |
| 66 | catch (InstantiationException | IllegalAccessException e) |
| 67 | { |
| 68 | throw new IllegalArgumentException( |
| 69 | "Class " + cl.getCanonicalName() + " for BasicClassIdentity must have public zero argument constructor", |
| 70 | e); |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | @Override |
| 75 | public String getName() |
| 76 | { |
| 77 | return underlyingClass.getSimpleName(); |
| 78 | } |
| 79 | |
| 80 | @Override |
| 81 | public Class<T> getReferenceClass() |
| 82 | { |
| 83 | return underlyingClass; |
| 84 | } |
| 85 | |
| 86 | @Override |
nothing calls this directly
no outgoing calls
no test coverage detected