@Override public String getDescription() { return "The dimensionality of the vectors of vector list parameter " + vector.getName() + " must have the value of integer parameter " + size.getName(); } }
@Override protected Integer parseValue(Object obj) throws ParameterException { if(obj instanceof Integer) { return (Integer) obj; } try { final String s = obj.toString(); return (int) FormatUtil.parseLongBase10(s, 0, s.length()); } catch(NullPointerException e) { throw new WrongParameterValueException("Wrong parameter format! Parameter \"" + getName() + "\" requires an integer value, read: " + obj + "!\n"); } catch(NumberFormatException e) { throw new WrongParameterValueException("Wrong parameter format! Parameter \"" + getName() + "\" requires an integer value, read: " + obj + "!\n"); } }
/** * Checks if the dimensions of each vector of the vector list parameter have * the appropriate size provided by the integer parameter. If not, a parameter * exception will be thrown. * */ @Override public void test() throws ParameterException { if(!vector.isDefined()) { return; } for(double[] vec : vector.getValue()) { if(vec.length != size.intValue()) { throw new WrongParameterValueException("Global Parameter Constraint Error.\n" // + "The vectors of vector list parameter " + vector.getName() // + " have not the required dimension of " + size.getValue() // + " given by integer parameter " + size.getName() + "."); } } }
/** * Checks is the size of the list parameter is equal to the constraint list * size specified. If not, a parameter exception is thrown. * */ @Override public void test() throws ParameterException { if(!list.isDefined() || !length.isDefined()) { return; } if(list.size() != length.intValue()) { throw new WrongParameterValueException("Global Parameter Constraint Error." + "\nThe size of the list parameter \"" + list.getName() + "\" must be " + length.getValue() + ", current size is " + list.size() + ". The value is defined by the integer parameter " + length.getName() + ".\n"); } }