Tabnine Logo
ConfigPropertyParser.getConfigPropertiesByName
Code IndexAdd Tabnine to your IDE (free)

How to use
getConfigPropertiesByName
method
in
org.chorusbdd.chorus.handlerconfig.configproperty.ConfigPropertyParser

Best Java code snippets using org.chorusbdd.chorus.handlerconfig.configproperty.ConfigPropertyParser.getConfigPropertiesByName (Showing top 3 results out of 315)

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

@Test
public void primitiveTypedPropertiesGetDefaultValidation() throws ConfigBuilderException {
  Map<String, HandlerConfigProperty> m = configPropertyParser.getConfigPropertiesByName(ConfigBeanWithPrimitiveTypedProperties.class);
  assertEquals("^[-+]?\\d+$", m.get("integerProperty").getValidationPattern().get().pattern());
  assertEquals("^[-+]?\\d+$", m.get("longProperty").getValidationPattern().get().pattern());
  assertEquals("^[-+]?\\d+$", m.get("shortProperty").getValidationPattern().get().pattern());
  assertEquals("^[-+]?[0-9]*\\.?[0-9]+(?:[eE][-+]?[0-9]+)?$", m.get("floatProperty").getValidationPattern().get().pattern());
  assertEquals("^[-+]?[0-9]*\\.?[0-9]+(?:[eE][-+]?[0-9]+)?$", m.get("doubleProperty").getValidationPattern().get().pattern());
  assertEquals("(?i)^true|false$", m.get("booleanProperty").getValidationPattern().get().pattern());
  assertEquals("^\\S$", m.get("charProperty").getValidationPattern().get().pattern());
}
origin: Chorus-bdd/Chorus

@Test
public void defaultValuesCanBeConvertedToSimpleTypes() throws ConfigBuilderException {
  Map<String, HandlerConfigProperty> m = configPropertyParser.getConfigPropertiesByName(ConfigBeanWithPrimitiveTypedProperties.class);
  assertEquals(7, m.size());
  assertEquals(1, m.get("integerProperty").getDefaultValue().get());
  assertEquals(1000000L, m.get("longProperty").getDefaultValue().get());
  assertEquals(1.23d, m.get("doubleProperty").getDefaultValue().get());
  assertEquals(2.34f, m.get("floatProperty").getDefaultValue().get());
  assertEquals(true, m.get("booleanProperty").getDefaultValue().get());
  assertEquals('C', m.get("charProperty").getDefaultValue().get());
  assertEquals((short)9, m.get("shortProperty").getDefaultValue().get());
}
org.chorusbdd.chorus.handlerconfig.configpropertyConfigPropertyParsergetConfigPropertiesByName

Popular methods of ConfigPropertyParser

  • getConfigProperties
  • addConfigProperty
  • checkValidationMethod
  • compilePattern
  • convertDefaultValue
  • getAnnotationDescription
  • getConverterFunction
  • getDefaultValidationPattern
    Try to create a sensible default for validation pattern, in the case where the java type of the para
  • getMethodsFromConfigClass
  • getValidationMethods
  • getValidationPattern
  • validateDefaultValue
  • getValidationPattern,
  • validateDefaultValue

Popular in Java

  • Making http post requests using okhttp
  • runOnUiThread (Activity)
  • getSystemService (Context)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • ConnectException (java.net)
    A ConnectException is thrown if a connection cannot be established to a remote host on a specific po
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • Join (org.hibernate.mapping)
  • 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