Use Spring Assert for cleaner code.

This commit is contained in:
Ben Alex 2005-11-26 04:18:21 +00:00
parent e53a00371c
commit f4c3e2ff8c
1 changed files with 24 additions and 33 deletions

View File

@ -29,9 +29,6 @@ import java.lang.reflect.Method;
* instance. Also offers a constructor that uses reflection to build the * instance. Also offers a constructor that uses reflection to build the
* identity information. * identity information.
* </p> * </p>
*
* @author Ben Alex
* @version $Id$
*/ */
public class NamedEntityObjectIdentity implements AclObjectIdentity { public class NamedEntityObjectIdentity implements AclObjectIdentity {
//~ Instance fields ======================================================== //~ Instance fields ========================================================
@ -42,18 +39,16 @@ public class NamedEntityObjectIdentity implements AclObjectIdentity {
//~ Constructors =========================================================== //~ Constructors ===========================================================
public NamedEntityObjectIdentity(String classname, String id) { public NamedEntityObjectIdentity(String classname, String id) {
if ((classname == null) || "".equals(classname)) { Assert.hasText(classname, "classname required");
throw new IllegalArgumentException("classname required"); Assert.hasText(id, "id required");
}
if ((id == null) || "".equals(id)) {
throw new IllegalArgumentException("id required");
}
this.classname = classname; this.classname = classname;
this.id = id; this.id = id;
} }
protected NamedEntityObjectIdentity() {
throw new IllegalArgumentException("Cannot use default constructor");
}
/** /**
* Creates the <code>NamedEntityObjectIdentity</code> based on the passed * Creates the <code>NamedEntityObjectIdentity</code> based on the passed
* object instance. The passed object must provide a <code>getId()</code> * object instance. The passed object must provide a <code>getId()</code>
@ -83,30 +78,8 @@ public class NamedEntityObjectIdentity implements AclObjectIdentity {
} }
} }
protected NamedEntityObjectIdentity() {
throw new IllegalArgumentException("Cannot use default constructor");
}
//~ Methods ================================================================ //~ Methods ================================================================
/**
* Indicates the classname portion of the object identity.
*
* @return the classname (never <code>null</code>)
*/
public String getClassname() {
return classname;
}
/**
* Indicates the instance identity portion of the object identity.
*
* @return the instance identity (never <code>null</code>)
*/
public String getId() {
return id;
}
/** /**
* Important so caching operates properly. * Important so caching operates properly.
* *
@ -138,6 +111,24 @@ public class NamedEntityObjectIdentity implements AclObjectIdentity {
return false; return false;
} }
/**
* Indicates the classname portion of the object identity.
*
* @return the classname (never <code>null</code>)
*/
public String getClassname() {
return classname;
}
/**
* Indicates the instance identity portion of the object identity.
*
* @return the instance identity (never <code>null</code>)
*/
public String getId() {
return id;
}
/** /**
* Important so caching operates properly. * Important so caching operates properly.
* *