public interface Nameable extends Identifiable
Nameable
item is an item that has
a name
and description
.
The NameableUtil
class provides methods that
includes data validation to make it easy to implement
this interface.
Reference implementation
public String getName() { return getData().getName(); } public void setName(String name) throws PermissionDeniedException, InvalidDataException { checkPermission(Permission.WRITE); NameableUtil.setName(getData(), name); } public String getDescription() { return getData().getDescription(); } public void setDescription(String description) throws PermissionDeniedException, InvalidDataException { checkPermission(Permission.RESTRICTED_WRITE); NameableUtil.setDescription(getData(), description); }
NameableUtil
Modifier and Type | Field and Description |
---|---|
static int |
MAX_DESCRIPTION_LENGTH
The maximum length of the description.
|
static int |
MAX_NAME_LENGTH
The maximum length of the name of the item that can be
stored in the database.
|
Modifier and Type | Method and Description |
---|---|
String |
getDescription()
Get the description for the item.
|
String |
getName()
Get the name of the item.
|
void |
setDescription(String description)
Set the description for the item.
|
void |
setName(String name)
Set the name of the item.
|
getId, getType, getVersion
checkPermission, getPermissions, hasPermission
static final int MAX_NAME_LENGTH
setName(String)
method to avoid exceptions.setName(String)
,
Constant Field Valuesstatic final int MAX_DESCRIPTION_LENGTH
setDescription(String)
method to avoid exceptions.setDescription(String)
,
Constant Field ValuesString getName()
String
with the name of the itemvoid setName(String name) throws PermissionDeniedException, InvalidDataException
MAX_NAME_LENGTH
constant.name
- The new name for the itemPermissionDeniedException
- If the logged in user doesn't
have write permissionInvalidDataException
- If the name is null or longer
than specified by the MAX_NAME_LENGTH
constantString getDescription()
String
with a description of the itemvoid setDescription(String description) throws PermissionDeniedException, InvalidDataException
MAX_DESCRIPTION_LENGTH
constant.description
- The new description for the itemPermissionDeniedException
- If the logged in user doesn't
have write permissionInvalidDataException
- If the description longer
than specified by the MAX_DESCRIPTION_LENGTH
constant