@Override public SharedResource getSharedResource(final String name) { final SharedResource result = sharedResources.get(name); if (result == null) { throw new ConfigurationException("Shared resource \"" + name + "\" not found"); } return result; }
protected DateFormat parseDateFormat() { try { return new SimpleDateFormat(dateformat != null ? dateformat : DEFAULT_DATE_FORMAT); } catch (final IllegalArgumentException e) { throw new ConfigurationException("Failed to parse date format: \"" + dateformat + "\""); } }
public static void notNull(final Object xbean, final String name, final Object value) { if (value == null) { throw new ConfigurationException("Element \"" + name + "\" of " + determineBeanName(xbean) + " is mandatory"); } }
public static void validPattern(final Object xbean, final String name, final String value) { if (value != null) { try { Pattern.compile(value); } catch (final PatternSyntaxException e) { throw new ConfigurationException("Value \"" + value + "\" of attribute \"" + name + "\" of " + determineBeanName(xbean) + " must be a valid regular expression but compiling it failed with error: " + e.getMessage(), e); } } } }
public static void notEmpty(final Object xbean, final String name, final String value) { if (value == null || value.equals("")) { throw new ConfigurationException("Attribute \"" + name + "\" of " + determineBeanName(xbean) + " is mandatory"); } }
public static void validPort(final Object xbean, final String name, final Integer value) { if (value == null) { throw new ConfigurationException("Attribute \"" + name + "\" of " + determineBeanName(xbean) + " is mandatory"); } if (value < 1 || value > 65535) { throw new ConfigurationException("Attribute \"" + name + "\" of " + determineBeanName(xbean) + " with value " + value + " is not a valid port in range [1,65535]"); } }
public static void notEmpty(final Object xbean, final String name, final Collection<?> value) { if (value == null || value.isEmpty()) { throw new ConfigurationException("Attribute \"" + name + "\" of " + determineBeanName(xbean) + " is mandatory"); } }
public static void notNegative(final Object xbean, final String name, final Integer value) { if (value == null) { throw new ConfigurationException("Attribute \"" + name + "\" of " + determineBeanName(xbean) + " is mandatory"); } if (value < 0) { throw new ConfigurationException("Attribute \"" + name + "\" of " + determineBeanName(xbean) + " with value " + value + " is not a valid number greater than or equal to 0"); } }
public static void validPattern(final Object xbean, final String name, final String value) { if (value != null) { try { Pattern.compile(value); } catch (final PatternSyntaxException e) { throw new ConfigurationException("Value \"" + value + "\" of attribute \"" + name + "\" of " + determineBeanName(xbean) + " must be a valid regular expression but compiling it failed with error: " + e.getMessage(), e); } } } }
public static void notNegativeOptional(final Object xbean, final String name, final Integer value) { if (value != null) { if (value < 0) { throw new ConfigurationException("Attribute \"" + name + "\" of " + determineBeanName(xbean) + " with value " + value + " is not a valid number greater than or equal to 0"); } } }
protected URL parseUrl() { try { return new URL(getUrl()); } catch (final MalformedURLException e) { throw new ConfigurationException("Invalid URL: " + e.getMessage()); } } }
public static void greaterThanZero(final Object xbean, final String name, final Integer value) { if (value == null) { throw new ConfigurationException("Attribute \"" + name + "\" of " + determineBeanName(xbean) + " is mandatory"); } if (value < 1) { throw new ConfigurationException("Attribute \"" + name + "\" of " + determineBeanName(xbean) + " with value " + value + " is not a valid number greater than 0"); } }
public static void greaterThanZero(final Object xbean, final String name, final Integer value) { if (value == null) { throw new ConfigurationException("Attribute \"" + name + "\" of " + determineBeanName(xbean) + " is mandatory"); } if (value < 1) { throw new ConfigurationException("Attribute \"" + name + "\" of " + determineBeanName(xbean) + " with value " + value + " is not a valid number greater than 0"); } }
private void applyPostProcessing(XBean bean) { try { for (final XBeanPostProcessor postProcessor : xbeanPostProcessors) { postProcessor.postProcessAfterLoad(bean); } } catch (IllegalAccessException|InvocationTargetException|NoSuchMethodException e) { throw new ConfigurationException("Failed to execute post processors", e); } }
private void applyPostProcessing(XBean bean) { try { for (final XBeanPostProcessor postProcessor : xbeanPostProcessors) { postProcessor.postProcessAfterLoad(bean); } } catch (IllegalAccessException|InvocationTargetException|NoSuchMethodException e) { throw new ConfigurationException("Failed to execute post processors", e); } }
public static void notEmpty(final Object xbean, final String name, final String value) { if (value == null || value.equals("")) { throw new ConfigurationException("Attribute \"" + name + "\" of " + determineBeanName(xbean) + " is mandatory"); } }
public static void notNull(final Object xbean, final String name, final Object value) { if (value == null) { throw new ConfigurationException("Element \"" + name + "\" of " + determineBeanName(xbean) + " is mandatory"); } }
public static void notNegative(final Object xbean, final String name, final Integer value) { if (value == null) { throw new ConfigurationException("Attribute \"" + name + "\" of " + determineBeanName(xbean) + " is mandatory"); } if (value < 0) { throw new ConfigurationException("Attribute \"" + name + "\" of " + determineBeanName(xbean) + " with value " + value + " is not a valid number greater than or equal to 0"); } }
protected URL parseUrl() { try { return new URL(getUrl()); } catch (final MalformedURLException e) { throw new ConfigurationException("Invalid URL: " + e.getMessage()); } } }
public static void validPort(final Object xbean, final String name, final Integer value) { if (value == null) { throw new ConfigurationException("Attribute \"" + name + "\" of " + determineBeanName(xbean) + " is mandatory"); } if (value < 1 || value > 65535) { throw new ConfigurationException("Attribute \"" + name + "\" of " + determineBeanName(xbean) + " with value " + value + " is not a valid port in range [1,65535]"); } }