[Minor] Code formatting

This commit is contained in:
Robert von Burg 2014-03-31 21:37:13 +02:00
parent 6ae9cbf866
commit c8cedae647
3 changed files with 100 additions and 82 deletions

View File

@ -49,7 +49,7 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
/** /**
* Default Constructor * Default Constructor
* *
* @param id * @param id
* @param name * @param name
* @param type * @param type
@ -66,8 +66,9 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
/** /**
* Sets the type of this {@link GroupedParameterizedElement} * Sets the type of this {@link GroupedParameterizedElement}
* *
* @param type the type to set * @param type
* the type to set
*/ */
public void setType(String type) { public void setType(String type) {
if (StringHelper.isEmpty(type)) { if (StringHelper.isEmpty(type)) {
@ -82,10 +83,12 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
/** /**
* Returns the {@link Parameter} with the given key from the {@link ParameterBag} with the given bagKey, or null if * Returns the {@link Parameter} with the given key from the {@link ParameterBag} with the given bagKey, or null if
* the {@link Parameter} or the {@link ParameterBag} does not exist * the {@link Parameter} or the {@link ParameterBag} does not exist
* *
* @param bagKey the key of the {@link ParameterBag} from which the {@link Parameter} is to be returned * @param bagKey
* @param paramKey the key of the {@link Parameter} which is to be returned * the key of the {@link ParameterBag} from which the {@link Parameter} is to be returned
* * @param paramKey
* the key of the {@link Parameter} which is to be returned
*
* @return the found {@link Parameter} or null if it was not found * @return the found {@link Parameter} or null if it was not found
*/ */
public <T> T getParameter(String bagKey, String paramKey) { public <T> T getParameter(String bagKey, String paramKey) {
@ -102,11 +105,14 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
/** /**
* Adds a new {@link Parameter} to the {@link ParameterBag} with the given key * Adds a new {@link Parameter} to the {@link ParameterBag} with the given key
* *
* @param bagKey the key of the {@link ParameterBag} to which the {@link Parameter} should be added * @param bagKey
* @param parameter the {@link Parameter} to be added to the {@link ParameterBag} * the key of the {@link ParameterBag} to which the {@link Parameter} should be added
* * @param parameter
* @throws StrolchException if the {@link ParameterBag} does not exist * the {@link Parameter} to be added to the {@link ParameterBag}
*
* @throws StrolchException
* if the {@link ParameterBag} does not exist
*/ */
public void addParameter(String bagKey, Parameter<?> parameter) throws StrolchException { public void addParameter(String bagKey, Parameter<?> parameter) throws StrolchException {
if (this.parameterBagMap == null) { if (this.parameterBagMap == null) {
@ -124,10 +130,12 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
/** /**
* Removes the {@link Parameter} with the given paramKey from the {@link ParameterBag} with the given bagKey * Removes the {@link Parameter} with the given paramKey from the {@link ParameterBag} with the given bagKey
* *
* @param bagKey the key of the {@link ParameterBag} from which the {@link Parameter} is to be removed * @param bagKey
* @param paramKey the key of the {@link Parameter} which is to be removed * the key of the {@link ParameterBag} from which the {@link Parameter} is to be removed
* * @param paramKey
* the key of the {@link Parameter} which is to be removed
*
* @return the removed {@link Parameter} or null if it did not exist * @return the removed {@link Parameter} or null if it did not exist
*/ */
public <T> Parameter<T> removeParameter(String bagKey, String paramKey) { public <T> Parameter<T> removeParameter(String bagKey, String paramKey) {
@ -144,9 +152,10 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
/** /**
* Returns the {@link ParameterBag} with the given key, or null if it does not exist * Returns the {@link ParameterBag} with the given key, or null if it does not exist
* *
* @param key the key of the {@link ParameterBag} to return * @param key
* * the key of the {@link ParameterBag} to return
*
* @return the {@link ParameterBag} with the given key, or null if it does not exist * @return the {@link ParameterBag} with the given key, or null if it does not exist
*/ */
public ParameterBag getParameterBag(String key) { public ParameterBag getParameterBag(String key) {
@ -158,22 +167,29 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
/** /**
* Adds the given {@link ParameterBag} to this {@link GroupedParameterizedElement} * Adds the given {@link ParameterBag} to this {@link GroupedParameterizedElement}
* *
* @param bag the {@link ParameterBag} to add * @param bag
* the {@link ParameterBag} to add
*/ */
public void addParameterBag(ParameterBag bag) { public void addParameterBag(ParameterBag bag) {
if (this.parameterBagMap == null) { if (this.parameterBagMap == null) {
this.parameterBagMap = new HashMap<String, ParameterBag>(); this.parameterBagMap = new HashMap<String, ParameterBag>();
} }
if (this.parameterBagMap.containsKey(bag.getId())) {
String msg = "A ParameterBag already exists with id {0} on {1}";
throw new StrolchException(MessageFormat.format(msg, bag.getId(), getLocator()));
}
this.parameterBagMap.put(bag.getId(), bag); this.parameterBagMap.put(bag.getId(), bag);
bag.setParent(this); bag.setParent(this);
} }
/** /**
* Removes the {@link ParameterBag} with the given key * Removes the {@link ParameterBag} with the given key
* *
* @param key the key of the {@link ParameterBag} to remove * @param key
* * the key of the {@link ParameterBag} to remove
*
* @return the removed {@link ParameterBag}, or null if it does not exist * @return the removed {@link ParameterBag}, or null if it does not exist
*/ */
public ParameterBag removeParameterBag(String key) { public ParameterBag removeParameterBag(String key) {
@ -185,7 +201,7 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
/** /**
* Returns true if this {@link GroupedParameterizedElement} has any {@link ParameterBag ParameterBag} * Returns true if this {@link GroupedParameterizedElement} has any {@link ParameterBag ParameterBag}
* *
* @return true if this {@link GroupedParameterizedElement} has any {@link ParameterBag ParameterBag} * @return true if this {@link GroupedParameterizedElement} has any {@link ParameterBag ParameterBag}
*/ */
public boolean hasParameterBags() { public boolean hasParameterBags() {
@ -194,8 +210,9 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
/** /**
* Returns true if the {@link ParameterBag} with the given key exists on this {@link GroupedParameterizedElement}. * Returns true if the {@link ParameterBag} with the given key exists on this {@link GroupedParameterizedElement}.
* *
* @param bagKey the key of the {@link ParameterBag} which is to be checked for existence * @param bagKey
* the key of the {@link ParameterBag} which is to be checked for existence
* @return true if the {@link ParameterBag} with the given key exists on this {@link GroupedParameterizedElement}. * @return true if the {@link ParameterBag} with the given key exists on this {@link GroupedParameterizedElement}.
*/ */
public boolean hasParameterBag(String bagKey) { public boolean hasParameterBag(String bagKey) {
@ -205,13 +222,15 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
/** /**
* Returns true if the {@link Parameter} with the given paramKey exists on the {@link ParameterBag} with the given * Returns true if the {@link Parameter} with the given paramKey exists on the {@link ParameterBag} with the given
* bagKey * bagKey
* *
* @param bagKey the key of the {@link ParameterBag} on which to find the {@link Parameter} * @param bagKey
* @param paramKey the key of the {@link Parameter} to be found * the key of the {@link ParameterBag} on which to find the {@link Parameter}
* * @param paramKey
* the key of the {@link Parameter} to be found
*
* @return true if the {@link Parameter} with the given paramKey exists on the {@link ParameterBag} with the given * @return true if the {@link Parameter} with the given paramKey exists on the {@link ParameterBag} with the given
* bagKey. False is returned if the {@link ParameterBag} does not exist, or the {@link Parameter} does not exist on * bagKey. False is returned if the {@link ParameterBag} does not exist, or the {@link Parameter} does not
* the {@link ParameterBag} * exist on the {@link ParameterBag}
*/ */
public boolean hasParameter(String bagKey, String paramKey) { public boolean hasParameter(String bagKey, String paramKey) {
if (this.parameterBagMap == null) { if (this.parameterBagMap == null) {
@ -227,7 +246,7 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
/** /**
* Returns the {@link Set} of keys for the {@link ParameterBag}s on this {@link GroupedParameterizedElement} * Returns the {@link Set} of keys for the {@link ParameterBag}s on this {@link GroupedParameterizedElement}
* *
* @return the {@link Set} of keys for the {@link ParameterBag}s on this {@link GroupedParameterizedElement} * @return the {@link Set} of keys for the {@link ParameterBag}s on this {@link GroupedParameterizedElement}
*/ */
public Set<String> getParameterBagKeySet() { public Set<String> getParameterBagKeySet() {
@ -265,7 +284,7 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
/** /**
* Fills {@link GroupedParameterizedElement} properties of this clone * Fills {@link GroupedParameterizedElement} properties of this clone
* *
* @param clone * @param clone
*/ */
protected void fillClone(GroupedParameterizedElement clone) { protected void fillClone(GroupedParameterizedElement clone) {

View File

@ -16,6 +16,7 @@
package li.strolch.model; package li.strolch.model;
import ch.eitchnet.utils.dbc.DBC; import ch.eitchnet.utils.dbc.DBC;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -61,7 +62,7 @@ public abstract class ParameterizedElement extends AbstractStrolchElement {
/** /**
* Default Constructor * Default Constructor
* *
* @param id * @param id
* @param name * @param name
* @param type * @param type
@ -79,8 +80,9 @@ public abstract class ParameterizedElement extends AbstractStrolchElement {
/** /**
* Sets the type of this {@link ParameterizedElement} * Sets the type of this {@link ParameterizedElement}
* *
* @param type the type to set * @param type
* the type to set
*/ */
public void setType(String type) { public void setType(String type) {
if (StringHelper.isEmpty(type)) { if (StringHelper.isEmpty(type)) {
@ -94,9 +96,10 @@ public abstract class ParameterizedElement extends AbstractStrolchElement {
/** /**
* Returns the {@link Parameter} with the given id, or null if it does not exist * Returns the {@link Parameter} with the given id, or null if it does not exist
* *
* @param key the id of the parameter to return * @param key
* * the id of the parameter to return
*
* @return the {@link Parameter} with the given id, or null if it does not exist * @return the {@link Parameter} with the given id, or null if it does not exist
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -109,22 +112,29 @@ public abstract class ParameterizedElement extends AbstractStrolchElement {
/** /**
* Adds the given {@link Parameter} to the {@link ParameterizedElement} * Adds the given {@link Parameter} to the {@link ParameterizedElement}
* *
* @param parameter the {@link Parameter} to add * @param parameter
* the {@link Parameter} to add
*/ */
public void addParameter(Parameter<?> parameter) { public void addParameter(Parameter<?> parameter) {
if (this.parameterMap == null) { if (this.parameterMap == null) {
this.parameterMap = new HashMap<String, Parameter<?>>(); this.parameterMap = new HashMap<String, Parameter<?>>();
} }
if (this.parameterMap.containsKey(parameter.getId())) {
String msg = "A Parameter already exists with id {0} on {1}";
throw new StrolchException(MessageFormat.format(msg, parameter.getId(), getLocator()));
}
this.parameterMap.put(parameter.getId(), parameter); this.parameterMap.put(parameter.getId(), parameter);
parameter.setParent(this); parameter.setParent(this);
} }
/** /**
* Removes the {@link Parameter} with the given key * Removes the {@link Parameter} with the given key
* *
* @param key the key of the {@link Parameter} to remove * @param key
* * the key of the {@link Parameter} to remove
*
* @return the removed {@link Parameter}, or null if it does not exist * @return the removed {@link Parameter}, or null if it does not exist
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -137,7 +147,7 @@ public abstract class ParameterizedElement extends AbstractStrolchElement {
/** /**
* Returns a list of all the {@link Parameter}s in this {@link ParameterizedElement} * Returns a list of all the {@link Parameter}s in this {@link ParameterizedElement}
* *
* @return a list of all the {@link Parameter}s in this {@link ParameterizedElement} * @return a list of all the {@link Parameter}s in this {@link ParameterizedElement}
*/ */
public List<Parameter<?>> getParameters() { public List<Parameter<?>> getParameters() {
@ -149,7 +159,7 @@ public abstract class ParameterizedElement extends AbstractStrolchElement {
/** /**
* Returns true, if the this {@link ParameterizedElement} has any {@link Parameter Parameters}, false otherwise * Returns true, if the this {@link ParameterizedElement} has any {@link Parameter Parameters}, false otherwise
* *
* @return true, if the this {@link ParameterizedElement} has any {@link Parameter Parameters}, false otherwise * @return true, if the this {@link ParameterizedElement} has any {@link Parameter Parameters}, false otherwise
*/ */
public boolean hasParameters() { public boolean hasParameters() {
@ -158,9 +168,10 @@ public abstract class ParameterizedElement extends AbstractStrolchElement {
/** /**
* Returns true, if the {@link Parameter} exists with the given key, false otherwise * Returns true, if the {@link Parameter} exists with the given key, false otherwise
* *
* @param key the key of the {@link Parameter} to check for * @param key
* * the key of the {@link Parameter} to check for
*
* @return true, if the {@link Parameter} exists with the given key, false otherwise * @return true, if the {@link Parameter} exists with the given key, false otherwise
*/ */
public boolean hasParameter(String key) { public boolean hasParameter(String key) {
@ -172,7 +183,7 @@ public abstract class ParameterizedElement extends AbstractStrolchElement {
/** /**
* Returns a {@link Set} of all the {@link Parameter} keys in this {@link ParameterizedElement} * Returns a {@link Set} of all the {@link Parameter} keys in this {@link ParameterizedElement}
* *
* @return a {@link Set} of all the {@link Parameter} keys in this {@link ParameterizedElement} * @return a {@link Set} of all the {@link Parameter} keys in this {@link ParameterizedElement}
*/ */
public Set<String> getParameterKeySet() { public Set<String> getParameterKeySet() {
@ -269,8 +280,9 @@ public abstract class ParameterizedElement extends AbstractStrolchElement {
/** /**
* Set the parent for this {@link ParameterizedElement} * Set the parent for this {@link ParameterizedElement}
* *
* @param parent the parent to set * @param parent
* the parent to set
*/ */
public void setParent(GroupedParameterizedElement parent) { public void setParent(GroupedParameterizedElement parent) {
this.parent = parent; this.parent = parent;

View File

@ -15,15 +15,13 @@
*/ */
package li.strolch.model.parameter; package li.strolch.model.parameter;
import li.strolch.model.Order;
import li.strolch.model.ParameterizedElement; import li.strolch.model.ParameterizedElement;
import li.strolch.model.Resource;
import li.strolch.model.StrolchElement; import li.strolch.model.StrolchElement;
import li.strolch.model.visitor.ParameterVisitor; import li.strolch.model.visitor.ParameterVisitor;
/** /**
* @author Robert von Burg <eitch@eitchnet.ch> * @author Robert von Burg <eitch@eitchnet.ch>
* *
*/ */
public interface Parameter<T> extends StrolchElement { public interface Parameter<T> extends StrolchElement {
@ -37,84 +35,73 @@ public interface Parameter<T> extends StrolchElement {
*/ */
public static final String UOM_NONE = "None"; //$NON-NLS-1$ public static final String UOM_NONE = "None"; //$NON-NLS-1$
/**
* This interpretation value indicates that the value of the {@link Parameter} should be understood as a reference
* to a {@link Resource}
*/
public static final String INTERPRETATION_RESOURCE_REF = "Resource-Reference"; //$NON-NLS-1$
/**
* This interpretation value indicates that the value of the {@link Parameter} should be understood as a reference
* to a {@link Order}
*/
public static final String INTERPRETATION_ORDER_REF = "Order-Reference"; //$NON-NLS-1$
/** /**
* the value of the parameter as string * the value of the parameter as string
* *
* @return String * @return String
*/ */
public String getValueAsString(); public String getValueAsString();
/** /**
* the value of the parameter * the value of the parameter
* *
* @return * @return
*/ */
public T getValue(); public T getValue();
/** /**
* the value of the parameter * the value of the parameter
* *
* @param value * @param value
*/ */
public void setValue(T value); public void setValue(T value);
/** /**
* get the hidden attribute * get the hidden attribute
* *
* @return * @return
*/ */
public boolean isHidden(); public boolean isHidden();
/** /**
* set the hidden attribute * set the hidden attribute
* *
* @param hidden * @param hidden
*/ */
public void setHidden(boolean hidden); public void setHidden(boolean hidden);
/** /**
* Get the UOM of this {@link Parameter} * Get the UOM of this {@link Parameter}
* *
* @return * @return
*/ */
public String getUom(); public String getUom();
/** /**
* Set the UOM of this {@link Parameter} * Set the UOM of this {@link Parameter}
* *
* @param uom * @param uom
*/ */
public void setUom(String uom); public void setUom(String uom);
/** /**
* Returns the index of this {@link Parameter}. This can be used to sort the parameters in a UI * Returns the index of this {@link Parameter}. This can be used to sort the parameters in a UI
* *
* @return the index of this {@link Parameter}. This can be used to sort the parameters in a UI * @return the index of this {@link Parameter}. This can be used to sort the parameters in a UI
*/ */
public int getIndex(); public int getIndex();
/** /**
* Set the index of this {@link Parameter}. This can be used to sort the parameters in a UI * Set the index of this {@link Parameter}. This can be used to sort the parameters in a UI
* *
* @param index the index to set * @param index
* the index to set
*/ */
public void setIndex(int index); public void setIndex(int index);
/** /**
* The {@link ParameterizedElement} parent to which this {@link Parameter} belongs * The {@link ParameterizedElement} parent to which this {@link Parameter} belongs
* *
* @return * @return
*/ */
public ParameterizedElement getParent(); public ParameterizedElement getParent();
@ -132,7 +119,7 @@ public interface Parameter<T> extends StrolchElement {
* <li>{@link Parameter#INTERPRETATION_ORDER_REF}</li> * <li>{@link Parameter#INTERPRETATION_ORDER_REF}</li>
* <li>{@link Parameter#INTERPRETATION_RESOURCE_REF}</li> * <li>{@link Parameter#INTERPRETATION_RESOURCE_REF}</li>
* </ul> * </ul>
* *
* @return string value * @return string value
*/ */
public String getInterpretation(); public String getInterpretation();
@ -145,7 +132,7 @@ public interface Parameter<T> extends StrolchElement {
* <li>{@link Parameter#INTERPRETATION_ORDER_REF}</li> * <li>{@link Parameter#INTERPRETATION_ORDER_REF}</li>
* <li>{@link Parameter#INTERPRETATION_RESOURCE_REF}</li> * <li>{@link Parameter#INTERPRETATION_RESOURCE_REF}</li>
* </ul> * </ul>
* *
* @param interpretation * @param interpretation
*/ */
public void setInterpretation(String interpretation); public void setInterpretation(String interpretation);