/** * Returns the target configuration. * @param key the configuration key * @param mandatory whether the configuration is mandatory * @param resolve whether resolves the configuration * @return the corresponded configuration, or {@code null} if is not defined/empty * @throws IllegalArgumentException if some parameters were {@code null} * @since 0.4.0 */ public String getConfiguration(String key, boolean mandatory, boolean resolve) { if (key == null) { throw new IllegalArgumentException("key must not be null"); //$NON-NLS-1$ } String value = getConfiguration().get(key); return normalize(key, value, mandatory, resolve); }
private static long extractLong( ServiceProfile<?> profile, Map<String, String> conf, String key, long defaultValue) { assert profile != null; assert conf != null; assert key != null; String value = profile.normalize(key, conf.remove(key), false, true); if (value == null) { return defaultValue; } try { return Long.parseLong(value); } catch (RuntimeException e) { throw new IllegalArgumentException(MessageFormat.format( "{0}.{1} must be an integer ({2})", profile.getPrefix(), key, value)); } }