congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
ConfigBuilderException
Code IndexAdd Tabnine to your IDE (free)

How to use
ConfigBuilderException
in
org.chorusbdd.chorus.handlerconfig.configproperty

Best Java code snippets using org.chorusbdd.chorus.handlerconfig.configproperty.ConfigBuilderException (Showing top 18 results out of 315)

origin: Chorus-bdd/Chorus

private boolean checkValidationMethod(Method method, Class configClass) throws ConfigBuilderException {
  if (method.getParameterCount() > 0) {
    throw new ConfigBuilderException("Validation method " + method.getName() + " on class " + configClass.getSimpleName() + " requires an argument and this is not supported");
  } else if (method.getReturnType() != Void.TYPE) {
    throw new ConfigBuilderException("Validation method " + method.getName() + " on class " + configClass.getSimpleName() + " does not have a void return type");
  }
  return true;
}
origin: Chorus-bdd/Chorus

private WebSocketsConfig getWebSocketsConfig(String configName, Properties webSocketsProperties) {
  WebSocketsConfigBean config;
  try {
    config = new ConfigBuilder().buildConfig(WebSocketsConfigBean.class, webSocketsProperties);
  } catch (ConfigBuilderException e) {
    throw new ChorusException(String.format("Invalid config '%s'. %s", configName, e.getMessage()));
  }
  config.setConfigName(configName);
  return config;
}
origin: Chorus-bdd/Chorus

private ProcessConfig buildProcessesConfig(String configName, Properties processProperties) {
  ProcessConfig config;
  try {
    config = new ConfigBuilder().buildConfig(ProcessConfig.class, processProperties);
  } catch (ConfigBuilderException e) {
    throw new ChorusException(String.format("Invalid config '%s'. %s", configName, e.getMessage()));
  }
  config.setConfigName(configName);
  return config;
}
origin: Chorus-bdd/Chorus

private SqlConfig getSqlConfig(String configName, Properties processProperties) {
  SqlConfigBean config;
  try {
    config = new ConfigBuilder().buildConfig(SqlConfigBean.class, processProperties);
  } catch (ConfigBuilderException e) {
    throw new ChorusException(String.format("Invalid config '%s'. %s", configName, e.getMessage()));
  }
  config.setConfigName(configName);
  return config;
}
origin: Chorus-bdd/Chorus

private void validate(String propertyName, String propertyValue, Optional<Pattern> p) throws ConfigBuilderException {
  if ( p.isPresent() ) {
    Pattern pattern = p.get();
    if ( ! pattern.matcher(propertyValue).matches()) {
      throw new ConfigBuilderException("Property " + propertyName + " value '" + propertyValue + "' does not match pattern '" + pattern + "'");
    }
    
  } 
}
origin: Chorus-bdd/Chorus

private SeleniumConfig getSeleniumConfig(String configName, Properties remotingProperties) {
  SeleniumConfigBean config;
  try {
    config = new ConfigBuilder().buildConfig(SeleniumConfigBean.class, remotingProperties);
  } catch (ConfigBuilderException e) {
    throw new ChorusException(String.format("Invalid config '%s'. %s", configName, e.getMessage()));
  }
  config.setConfigName(configName);
  return config;
}
origin: Chorus-bdd/Chorus

private Object mapToEnum(String propertyValue, Class targetClass) throws ConfigBuilderException {
  Object[] enumConstants = targetClass.getEnumConstants();
  for (Object e: enumConstants) {
    if ( ((Enum)e).name().equalsIgnoreCase(propertyValue)) {
      return e;
    }
  }
  throw new ConfigBuilderException("Could not convert property value " + propertyValue + " to an instance of Enum class " + targetClass.getName());
}
origin: Chorus-bdd/Chorus

private RemotingManagerConfig buildRemotingConfig(String configName, Properties remotingProperties) {
  RemotingConfig config;
  try {
    config = new ConfigBuilder().buildConfig(RemotingConfig.class, remotingProperties);
  } catch (ConfigBuilderException e) {
    throw new ChorusException(String.format("Invalid config '%s'. %s", configName, e.getMessage()));
  }
  config.setConfigName(configName);
  return config;
}
origin: Chorus-bdd/Chorus

private <C> void runClassLevelValidation(Class<C> configClass, C configInstance) throws ConfigBuilderException {
  List<Method> validationMethods = configPropertyParser.getValidationMethods(configClass);
  for (Method m : validationMethods) {
    try {
      m.invoke(configInstance);
    } catch (InvocationTargetException i) {
      log.debug("Config validation failed", i);
      throw new ConfigBuilderException("Validation method failed: [" + i.getCause().getMessage() + "]");
    } catch (Exception e) {
      throw new ConfigBuilderException("Failed to execute validation method " + m.getName() + " on config class " + configClass.getSimpleName(), e);
    }
  }
}
origin: Chorus-bdd/Chorus

private Object mapToEnumOrPrimitiveWrapper(String propertyValue, Class targetClass) throws ConfigBuilderException {
  Object result;
  try {
    if ( targetClass.isEnum()) {
      result = mapToEnum(propertyValue, targetClass);
    } else {
      result = mapToPrimitiveWrapper(propertyValue, targetClass);
    }
  } catch (NumberFormatException nfe) {
    throw new ConfigBuilderException(getClass().getSimpleName() +  " could not convert the property value '" +
      propertyValue + "' to a " + targetClass.getName());
  }
  return result;
}
origin: Chorus-bdd/Chorus

  return propertyValue.charAt(0);
} else {
  throw new ConfigBuilderException("Could not convert a String with more than one character to a char");
throw new ConfigBuilderException(getClass().getSimpleName() +
  " cannot convert property value to a " + targetClass.getName() + " consider configuring a custom value converter");
origin: Chorus-bdd/Chorus

private void validateDefaultValue(Pattern validationPattern, ConfigProperty p) throws ConfigBuilderException {
  if (!validationPattern.matcher(p.defaultValue()).matches()) {
    throw new ConfigBuilderException(
      String.format("The default value [%s] did not match the validation pattern [%s], for %s",
        p.defaultValue(),
        validationPattern.pattern(),
        getAnnotationDescription(p)
      )
    );
  }
}
origin: Chorus-bdd/Chorus

private ConfigBuilderTypeConverter getConverterFunction(ConfigProperty p, Class javaType) throws ConfigBuilderException {
  ConfigBuilderTypeConverter f;
  try {
    Class<? extends ConfigBuilderTypeConverter> c = p.valueConverter();
    f = c.newInstance();
  } catch (Exception e) {
    throw new ConfigBuilderException("Failed to instantiate converter class " + p.valueConverter().getClass().getName() +
        " for " + getAnnotationDescription(p), e);
  }
  return f;
}
origin: Chorus-bdd/Chorus

public <C> C buildConfig(Class<C> configClass, Properties properties) throws ConfigBuilderException {
  Map<String, HandlerConfigProperty> configPropertiesByName = configPropertyParser.getConfigPropertiesByName(configClass);
  C configInstance;
  try {
    configInstance = configClass.newInstance();
  } catch (Exception e) {
    throw new ConfigBuilderException("Failed to instantiate config class " + configClass.getSimpleName() + " - " + e.getClass().getSimpleName(), e);
  }
  
  //iterate sorted by field name for consistent/deterministic behaviour
  List<String> props = configPropertiesByName.keySet().stream().sorted().collect(Collectors.toList());
    
  for ( String configPropertyName : props) {
    log.debug("Processing config property " + configPropertyName);
    
    HandlerConfigPropertyImpl configProperty = (HandlerConfigPropertyImpl)configPropertiesByName.get(configPropertyName);
    String propertyValue = properties.getProperty(configPropertyName);
    setValueForConfigProperty(configInstance, configPropertyName, configProperty, propertyValue);
  }
  
  warnOnUnusedProperties(properties, configPropertiesByName);
  runClassLevelValidation(configClass, configInstance);
  
  return configInstance;
}
origin: Chorus-bdd/Chorus

private Pattern compilePattern(ConfigProperty p) throws ConfigBuilderException {
  Pattern pattern;
  try {
    pattern = Pattern.compile(p.validationPattern());
  } catch (PatternSyntaxException e) {
    throw new ConfigBuilderException("The validation pattern '" + p.validationPattern() + "' could not be compiled, for " + getAnnotationDescription(p));
  }
  return pattern;
}
origin: Chorus-bdd/Chorus

private Object applyConverterFunction(String propertyName, HandlerConfigPropertyImpl configProperty, String propertyValue) throws ConfigBuilderException {
  Object result = configProperty.getValueConverter().convertToTargetType(propertyValue, configProperty.getJavaType());
  
  if ( result == null) {
    throw new ConfigBuilderException("Property " + propertyName + " converter function returned null when converting value " + propertyValue);
  }
  return result;
}
origin: Chorus-bdd/Chorus

throw new ConfigBuilderException(
    "A config bean can only annotate a setter method (the method " + method.getName() +
        " does not start with 'set'), for " + getAnnotationDescription(p));
throw new ConfigBuilderException(
    "The annotated method must take a single argument, for " + getAnnotationDescription(p)
);
  throw new ConfigBuilderException("Default value \"" + p.defaultValue() + "\" was converted to a type " +
      defaultValue.getClass().getName() + " which did not match the expected class type " + javaType.getName()
      + " for " + getAnnotationDescription(p));
origin: Chorus-bdd/Chorus

  throw new ConfigBuilderException("Property " + configPropertyName + " is mandatory but no value was provided");
  throw new ConfigBuilderException("The expected value type for the property " + configPropertyName + 
    " is a " + configProperty.getJavaType().getName() + " but the converted value was a " 
    + convertedValue.getClass().getName());
  configProperty.getSetterMethod().invoke(configInstance, convertedValue);
} catch (Exception e) {
  throw new ConfigBuilderException("Failed to set property + " + configPropertyName + " to value " + convertedValue + 
    " on config instance with class type " + configInstance.getClass().getName(), e);
org.chorusbdd.chorus.handlerconfig.configpropertyConfigBuilderException

Javadoc

A checked Exception which describes an error which occurred while building an instance of a config class

Most used methods

  • getMessage
  • <init>

Popular in Java

  • Finding current android device location
  • getSupportFragmentManager (FragmentActivity)
  • runOnUiThread (Activity)
  • requestLocationUpdates (LocationManager)
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • Notification (javax.management)
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now