Exemplo n.º 1
0
 private void checkValueCount(ConfigurationProperty p, List<String> values)
     throws InterpreterPropertyException {
   if (values.size() < p.getMinValueCount()) {
     throw new InterpreterPropertyException(
         "At least " + p.getMinValueCount() + " value(s) must be supplied for the property " + p);
   } else if (values.size() > p.getMaxValueCount()) {
     throw new InterpreterPropertyException(
         "At most " + p.getMaxValueCount() + " value(s) must be supplied for the property " + p);
   }
 }
Exemplo n.º 2
0
 private void checkValues(ConfigurationProperty p, List<String> values)
     throws InterpreterPropertyException {
   Pattern pattern = Pattern.compile(p.getValidatingExpression());
   for (String value : values) {
     Matcher m = pattern.matcher(value);
     if (!m.matches()) {
       throw new InterpreterPropertyException(
           "Could not parse the value for interpreter property "
               + p
               + " expected to be in the form "
               + p.getExample());
     }
   }
 }
Exemplo n.º 3
0
 private void mergeValues(
     List<String> valuesFromSource, ConfigurationProperty p, List<String> vals) {
   switch (p.getPropertySourceMode()) {
     case APPEND:
       vals.addAll(valuesFromSource);
       break;
     case OVERRIDE:
       vals.clear();
       vals.addAll(valuesFromSource);
       break;
     default:
       throw new UnsupportedOperationException("Unknown source mode " + p.getPropertySourceMode());
   }
 }
Exemplo n.º 4
0
 private void checkIfMandatory(
     Map<ConfigurationProperty, List<String>> results, ConfigurationProperty p)
     throws InterpreterPropertyException {
   if (p.isMandatory() && !results.containsKey(p)) {
     throw new InterpreterPropertyException(
         "Mandatory property "
             + p
             + " was not set. "
             + "You can set this property with the -"
             + p.getSwitchName()
             + " switch, "
             + "the -"
             + p.getSwitchShortName()
             + " switch or the "
             + p.getSystemProperty()
             + " system property");
   }
 }