Object name validator component

* Moved the component from the -user package to the -naming package

* Added a separate interface to the component
This commit is contained in:
Emmanuel BENOîT 2012-02-04 15:26:53 +01:00
parent 35d8891fe3
commit b4903d78e4
14 changed files with 483 additions and 104 deletions
legacyworlds-server-interfaces/src/main/java/com/deepclone/lw/interfaces/naming

View file

@ -0,0 +1,55 @@
package com.deepclone.lw.interfaces.naming;
import com.deepclone.lw.cmd.ObjectNameError;
/**
* Object name validator
*
* <p>
* This interface corresponds to a component which can be used to "pre-validate" the names of
* objects (empires, map objects, fleets, etc...). It does not check for banned or duplicate names.
*
* @author <a href="mailto:tseeker@legacyworlds.com">E. Benoît</a>
*/
public interface ObjectNameValidator
{
/**
* Validate a name using the component's defaults
*
* <p>
* Check the name's validity. The name must match the usual naming constraints (valid
* characters, no sequences of white space, name starts with an alphabetic character) and its
* length is checked against the component's default constraints.
*
* @param name
* the name to validate
*
* @return the validation error if one occurred, or <code>null</code> if the name is valid
*/
public ObjectNameError validate( String name );
/**
* Validate a name using specific length constraints
*
* <p>
* Check the name's validity. The name must match the usual naming constraints (valid
* characters, no sequences of white space, name starts with an alphabetic character) and its
* length is checked against the specific constraints given as arguments.
*
* @param name
* the name to validate
* @param minLength
* the minimal accepted length
* @param maxLength
* the maximal accepted length
*
* @return the validation error if one occurred, or <code>null</code> if the name is valid
*/
public ObjectNameError validate( String name , int minLength , int maxLength );
}