Added some documentation to the Gate class.

This commit is contained in:
Tobias Ottenweller 2013-05-18 19:54:43 +02:00
parent f1d623df60
commit 00573c2763

View File

@ -31,7 +31,10 @@ public class Gate implements ConfigurationSerializable
protected String id;
/**
* You should never create two gates with the same 'id'. Also see 'setId(String id)'.
* @param id This parameter must not be 'null'. An exception will be thrown otherwise!
*/
public Gate(String id)
{
setId(id);
@ -48,12 +51,23 @@ public class Gate implements ConfigurationSerializable
* SETTER & GETTER
*/
/**
*
* @return This method might return a 'null' value.
*/
public Location getLocation()
{
return location;
}
/**
*
* @param location Supplying 'null' is permitted.
* @throws Exception Will throw an exception if the gate is open and an invalid (no gate frame) location is
* supplied. Note that the supplied 'location' will be set even if an exception is thrown. Note that this
* gate will be closed if an exception is thrown.
*/
public void setLocation(Location location) throws Exception
{
this.location = location;
@ -65,12 +79,23 @@ public class Gate implements ConfigurationSerializable
}
/**
*
* @return This method might return a 'null' value.
*/
public Location getExit()
{
return exit;
}
/**
*
* @param exit Supplying 'null' is permitted.
* @throws Exception An exception will be thrown if 'null' value is supplied and this gate is open. Note that the
* supplied 'exit' will be set even if an exception is thrown. Note that this gate will be closed if an
* exception is thrown.
*/
public void setExit(Location exit) throws Exception
{
this.exit = exit;
@ -78,12 +103,27 @@ public class Gate implements ConfigurationSerializable
}
public String getId() {
/**
*
* @return This method will never return 'null'.
*/
public String getId()
{
return id;
}
public void setId(String id) {
/**
* Every gate should have an unique 'id'. You should therefore check if another gate with the same 'id' exists.
* Note that this method will not check if another gate with the same 'id' exists!
* @param id This parameter must not be 'null'. An exception will be thrown otherwise!
*/
public void setId(String id)
{
if (id == null) {
throw new IllegalArgumentException("gate 'id' cannot be 'null'");
}
this.id = id;
}
@ -133,7 +173,10 @@ public class Gate implements ConfigurationSerializable
validate();
}
/**
*
* @return Will never return 'null' but might return an empty Set.
*/
public Set<Location> getGateBlockLocations()
{
return gateBlockLocations;
@ -189,7 +232,7 @@ public class Gate implements ConfigurationSerializable
*/
/**
* Checks if valus attributes do add up; will close gate on wrong values.
* Checks if values attributes do add up; will close gate on wrong values.
*/
public void validate() throws Exception
{
@ -240,10 +283,15 @@ public class Gate implements ConfigurationSerializable
@SuppressWarnings("unchecked")
private Gate(Map<String, Object> map)
public Gate(Map<String, Object> map)
{
try {
id = map.get(idKey).toString();
if (id == null) {
throw new Exception("gates need to have an id");
}
isHidden = (Boolean)map.get(isHiddenKey);
isOpen = (Boolean)map.get(isOpenKey);