com.untzuntz.ustackserverapi.params.AndParam Maven / Gradle / Ivy
package com.untzuntz.ustackserverapi.params;
import java.util.ArrayList;
import java.util.List;
import com.untzuntz.ustackserverapi.APIException;
import com.untzuntz.ustackserverapi.CallParameters;
import com.untzuntz.ustackserverapi.params.exceptions.ParamGroupException;
/**
* AND multiple parameters together to ensure more than one value is required (probably used with an OrParam)
*
* @author jdanner
*
*/
public class AndParam implements Validated {
private String name;
private List params;
public AndParam(String name) {
params = new ArrayList();
this.name = name;
}
public AndParam add(OrParam param) {
params.add(param);
return this;
}
public AndParam add(AndParam param)
{
params.add(param);
return this;
}
public AndParam add(APICallParam param)
{
params.add(param);
return this;
}
@Override
public void validate(CallParameters data) throws APIException {
ParamGroupException preExcep = new ParamGroupException(name);
for (Validated val : params)
{
try {
val.validate(data);
} catch (APIException e) {
preExcep.addException(e);
}
}
if (preExcep.getChildExceptions().size() > 0)
throw preExcep;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy