Use IllegalArgumentException since those are basically illegal arguments. Also

use @exception because it's a nice way to let humans and tools know what's
going on.
This commit is contained in:
Michael Bayne
2007-08-14 18:47:21 +00:00
parent f9757c3633
commit 0b91f0f6a7
@@ -102,13 +102,12 @@ public class DepotTypes
* Return the current abbreviation by which we refer to the table associated with the given * Return the current abbreviation by which we refer to the table associated with the given
* persistent record -- which must have been previously registered with this object. If the * persistent record -- which must have been previously registered with this object. If the
* useTableAbbreviations flag is false, we return the full table name instead. * useTableAbbreviations flag is false, we return the full table name instead.
*
* @exception IllegalArgumentException thrown if the specified class is not known.
*/ */
public String getTableAbbreviation (Class<? extends PersistentRecord> cl) public String getTableAbbreviation (Class<? extends PersistentRecord> cl)
{ {
if (_useTableAbbreviations) { if (_useTableAbbreviations) {
if (!_classIx.containsKey(cl)) {
throw new RuntimeException("Persistent class not known: " + cl);
}
Integer ix = _classIx.get(cl); Integer ix = _classIx.get(cl);
if (ix == null) { if (ix == null) {
throw new IllegalArgumentException("Unknown persistence class: " + cl); throw new IllegalArgumentException("Unknown persistence class: " + cl);
@@ -122,26 +121,31 @@ public class DepotTypes
* Return the associated database column of the given field of the given persistent class, * Return the associated database column of the given field of the given persistent class,
* throwing an exception if the record has not been registered with this object, or if the * throwing an exception if the record has not been registered with this object, or if the
* field is unknown on the record. * field is unknown on the record.
*
* @exception IllegalArgumentException thrown if the specified field is not part of the
* specified persistent class.
*/ */
public String getColumnName (Class<? extends PersistentRecord> cl, String field) public String getColumnName (Class<? extends PersistentRecord> cl, String field)
{ {
FieldMarshaller<?> fm = getMarshaller(cl).getFieldMarshaller(field); FieldMarshaller<?> fm = getMarshaller(cl).getFieldMarshaller(field);
if (fm == null) { if (fm == null) {
throw new RuntimeException( throw new IllegalArgumentException(
"Field not known on class [field=" + field + ", class=" + cl + "]"); "Field not known on class [field=" + field + ", class=" + cl + "]");
} }
return fm.getColumnName(); return fm.getColumnName();
} }
/** /**
* Return the {@link DepotMarshaller} associated with the given persistent class, if it's * Return the {@link DepotMarshaller} associated with the given persistent class, if it's been
* been registered with this object, otherwise throw an exception. * registered with this object.
*
* @exception IllegalArgumentException thrown if the specified class is not known.
*/ */
public DepotMarshaller getMarshaller (Class<? extends PersistentRecord> cl) public DepotMarshaller getMarshaller (Class<? extends PersistentRecord> cl)
{ {
DepotMarshaller marsh = _classMap.get(cl); DepotMarshaller marsh = _classMap.get(cl);
if (marsh == null) { if (marsh == null) {
throw new RuntimeException("Persistent class not known: " + cl); throw new IllegalArgumentException("Persistent class not known: " + cl);
} }
return marsh; return marsh;
} }