package com.upweather.upobject;
import com.uplibrary.upexception.UPInvalidParameterException;
/**
* This class represent the output. It has a name
* and a description.
* @author Giuseppe Persico - University of Naples "Parthenope"
* @version 1.0
*/
public final class UPOutput {
// The output name
private String outputName;
// The output description
private String outputDescription;
/**
* The constructor initialize the name and the output
* description.
* @param outputName the output name
* @param outputDescription the output description.
* @throws UPInvalidParameterException if the parameters specified are invalid.
*/
public UPOutput(final String outputName, final String outputDescription) throws UPInvalidParameterException {
this.setOutputName(outputName).setOutputDescription(outputDescription);
}
/**
* This method returns the output name
* @return the output name.
*/
public String getOutputName() {
return this.outputName;
}
/**
* This method returns the output description.
* @return the output description.
*/
public String getOutputDescription() {
return this.outputDescription;
}
/**
* Override of toString method.
* It gives a representation of the UPOutput object.
* @return UPOutput string representation.
*/
@Override
public final String toString() {
return "OUTPUT: "+this.outputName+"\nDESCRIPTION: "+this.outputDescription;
}
/**
* This method sets the output name
* @param outputName the output name
* @return a reference to enable cascade calls.
* @throws UPInvalidParameterException if the name is invalid.
*/
protected final UPOutput setOutputName(final String outputName) throws UPInvalidParameterException {
if (outputName==null || outputName.isEmpty()) {
throw new UPInvalidParameterException("Output name can not be null or an empty string");
}
this.outputName = outputName;
return this;
}
/**
* This method the output description.
* @param outputDescription the output description.
* @return a reference to enable cascade calls.
* @throws UPInvalidParameterException if the description is invalid.
*/
protected final UPOutput setOutputDescription(final String outputDescription) throws UPInvalidParameterException {
if (outputDescription==null) {
throw new UPInvalidParameterException("Output description can not be null");
} else if (outputDescription.isEmpty()) {
this.outputDescription = "No description supplied";
} else {
this.outputDescription = outputDescription;
}
return this;
}
}