/** * Return the String property value associated with the given key, or * {@code defaultValue} if the key cannot be resolved. * * @param key the property name to resolve * @param defaultValue the default value to return if no value is found * @return The string property */ public String getString(String key, String defaultValue) { return configuration.getString(key, defaultValue); }
/** * Return the boolean property value associated with the given key, or * {@code defaultValue} if the key cannot be resolved. * * @param key the property name to resolve * @param defaultValue the default value to return if no value is found * @return The boolean property */ public boolean getBoolean(String key, boolean defaultValue) { return configuration.getBoolean(key, defaultValue); }
/** * Return the int property value associated with the given key, or * {@code defaultValue} if the key cannot be resolved. * * @param key the property name to resolve * @param defaultValue the default value to return if no value is found * @return The int property */ public int getInt(String key, int defaultValue) { return configuration.getInt(key, defaultValue); }
@Override public void scrubRegistrationProperties() { if (!exist()) { return; } try { PropertiesConfiguration config = new PropertiesConfiguration(); config.setIOFactory(new FilteringOutputWriterFactory()); PropertiesConfigurationLayout layout = new PropertiesConfigurationLayout(); layout.setLineSeparator("\n"); layout.load(config, reader()); try (FileWriter out = new FileWriter(this.configFile)) { layout.save(config, out); } loadProperties(); } catch (ConfigurationException | IOException e) { LOG.warn("[Agent Auto Registration] Unable to scrub registration key.", e); } }
public Swagger2MarkupConfigBuilder() { this(new PropertiesConfiguration()); }
/** * Return the list of keys. * * @return the list of keys. */ public List<String> getKeys() { return IteratorUtils.toList(configuration.getKeys()); }
public List<PageBreakLocations> getPageBreakLocations(String key) { List<PageBreakLocations> result = configuration.getList(PageBreakLocations.class, key); if(result == null) result = new ArrayList<PageBreakLocations>(); return result; }
public Swagger2MarkupProperties(Properties properties) { this(ConfigurationConverter.getConfiguration(properties)); }
public Swagger2MarkupProperties(Map<String, String> map) { this(new MapConfiguration(map)); }
/** * Returns an optional Integer property value associated with the given key. * * @param key the property name to resolve * @return An optional Integer property */ public Optional<Integer> getInteger(String key) { return Optional.ofNullable(configuration.getInteger(key, null)); }
@Override public void writeProperty(String key, Object value, boolean forceSingleLine) throws IOException { if (key.equals(AGENT_AUTO_REGISTER_KEY)) { scrubWithMessage("The autoregister key has been intentionally removed by Go as a security measure."); } if (key.equals(AGENT_AUTO_REGISTER_RESOURCES) || key.equals(AGENT_AUTO_REGISTER_ENVIRONMENTS) || key.equals(AGENT_AUTO_REGISTER_HOSTNAME)) { scrubWithMessage("This property has been removed by Go after attempting to auto-register with the Go server."); } super.writeProperty(key, value, forceSingleLine); }
/** * Throw a {@link MetricsException} if the given property is not set. * * @param key the key to validate */ private void checkIfPropertyExists(String key) { if (!properties.containsKey(key)) { throw new MetricsException("Metrics2 configuration is missing " + key + " property"); } }
/** * Return the property value if it's non-negative and throw an exception if * it's not. * * @param key the property key * @param defaultValue the default value */ private long getNonNegative(String key, int defaultValue) { int flushOffsetIntervalMillis = properties.getInt(key, defaultValue); if (flushOffsetIntervalMillis < 0) { throw new MetricsException("The " + key + " property must be " + "non-negative. Value was " + flushOffsetIntervalMillis); } return flushOffsetIntervalMillis; }
/** * Returns an optional String property value associated with the given key. * * @param key the property name to resolve * @return The string property */ public Optional<String> getString(String key) { return Optional.ofNullable(configuration.getString(key)); }
public Swagger2MarkupConfigBuilder(Properties properties) { this(ConfigurationConverter.getConfiguration(properties)); }
public Swagger2MarkupConfigBuilder(Map<String, String> map) { this(new MapConfiguration(map)); }
/** * Return the MarkupLanguage property value associated with the given key (never {@code null}). * * @return The MarkupLanguage property * @throws IllegalStateException if the key cannot be resolved */ public MarkupLanguage getRequiredMarkupLanguage(String key) { return MarkupLanguage.valueOf(configuration.getString(key)); }
/** * Return the GroupBy property value associated with the given key, or * {@code defaultValue} if the key cannot be resolved. * * @param key the property name to resolve * @return The GroupBy property * @throws IllegalStateException if the value cannot be mapped to the enum */ public GroupBy getGroupBy(String key) { return GroupBy.valueOf(configuration.getString(key)); }
/** * Return the OrderBy property value associated with the given key, or * {@code defaultValue} if the key cannot be resolved. * * @param key the property name to resolve * @return The OrderBy property * @throws IllegalStateException if the value cannot be mapped to the enum */ public OrderBy getOrderBy(String key) { return OrderBy.valueOf(configuration.getString(key)); }
/** * Return the Language property value associated with the given key, or * {@code defaultValue} if the key cannot be resolved. * * @param key the property name to resolve * @return The Language property */ public Language getLanguage(String key) { return Language.valueOf(configuration.getString(key)); }