Java Code Examples for com.typesafe.config.ConfigException#WrongType

The following examples show how to use com.typesafe.config.ConfigException#WrongType . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultScopedConfig.java    From ditto with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public String getString(final String path) {
    try {
        return config.getString(path);
    } catch (final ConfigException.Missing | ConfigException.WrongType e) {
        final String msgPattern = "Failed to get String value for path <{0}>!";
        throw new DittoConfigError(MessageFormat.format(msgPattern, appendToConfigPath(path)), e);
    }
}
 
Example 2
Source File: DefaultScopedConfig.java    From ditto with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public List<Number> getNumberList(final String path) {
    try {
        return config.getNumberList(path);
    } catch (final ConfigException.Missing | ConfigException.WrongType e) {
        final String msgPattern = "Failed to get List of Numbers for path <{0}>!";
        throw new DittoConfigError(MessageFormat.format(msgPattern, appendToConfigPath(path)), e);
    }
}
 
Example 3
Source File: DefaultScopedConfig.java    From ditto with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Period getPeriod(final String path) {
    try {
        return config.getPeriod(path);
    } catch (final ConfigException.Missing | ConfigException.WrongType | ConfigException.BadValue e) {
        final String msgPattern = "Failed to get Period for path <{0}>!";
        throw new DittoConfigError(MessageFormat.format(msgPattern, appendToConfigPath(path)), e);
    }
}
 
Example 4
Source File: DefaultScopedConfig.java    From ditto with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public List<Long> getBytesList(final String path) {
    try {
        return config.getBytesList(path);
    } catch (final ConfigException.Missing | ConfigException.WrongType e) {
        final String msgPattern = "Failed to get List of byte sizes for path <{0}>!";
        throw new DittoConfigError(MessageFormat.format(msgPattern, appendToConfigPath(path)), e);
    }
}
 
Example 5
Source File: DefaultScopedConfig.java    From ditto with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public long getDuration(final String path, final TimeUnit unit) {
    try {
        return config.getDuration(path, unit);
    } catch (final ConfigException.Missing | ConfigException.WrongType e) {
        final String msgPattern = "Failed to get duration as long value for path <{0}>!";
        throw new DittoConfigError(MessageFormat.format(msgPattern, appendToConfigPath(path)), e);
    }
}
 
Example 6
Source File: DefaultScopedConfig.java    From ditto with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public ConfigMemorySize getMemorySize(final String path) {
    try {
        return config.getMemorySize(path);
    } catch (final ConfigException.Missing | ConfigException.WrongType e) {
        final String msgPattern = "Failed to get memory size for path <{0}>!";
        throw new DittoConfigError(MessageFormat.format(msgPattern, appendToConfigPath(path)), e);
    }
}
 
Example 7
Source File: DefaultScopedConfig.java    From ditto with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Long getBytes(final String path) {
    try {
        return config.getBytes(path);
    } catch (final ConfigException.Missing | ConfigException.WrongType e) {
        final String msgPattern = "Failed to get long value for path <{0}>!";
        throw new DittoConfigError(MessageFormat.format(msgPattern, appendToConfigPath(path)), e);
    }
}
 
Example 8
Source File: DefaultScopedConfig.java    From ditto with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public <T extends Enum<T>> List<T> getEnumList(final Class<T> enumClass, final String path) {
    try {
        return config.getEnumList(enumClass, path);
    } catch (final ConfigException.Missing | ConfigException.WrongType e) {
        final String msgPattern = "Failed to get List of Enums for path <{0}>!";
        throw new DittoConfigError(MessageFormat.format(msgPattern, appendToConfigPath(path)), e);
    }
}
 
Example 9
Source File: DefaultScopedConfig.java    From ditto with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public List<? extends ConfigObject> getObjectList(final String path) {
    try {
        return config.getObjectList(path);
    } catch (final ConfigException.Missing | ConfigException.WrongType e) {
        final String msgPattern = "Failed to get List of ConfigObjects for path <{0}>!";
        throw new DittoConfigError(MessageFormat.format(msgPattern, appendToConfigPath(path)), e);
    }
}
 
Example 10
Source File: DefaultScopedConfig.java    From ditto with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public List<ConfigMemorySize> getMemorySizeList(final String path) {
    try {
        return config.getMemorySizeList(path);
    } catch (final ConfigException.Missing | ConfigException.WrongType e) {
        final String msgPattern = "Failed to get List of memory sizes for path <{0}>!";
        throw new DittoConfigError(MessageFormat.format(msgPattern, appendToConfigPath(path)), e);
    }
}
 
Example 11
Source File: DittoService.java    From ditto with Eclipse Public License 2.0 5 votes vote down vote up
private static ScopedConfig tryToGetDittoConfigOrEmpty(final Config rawConfig) {
    try {
        return getDittoConfigOrEmpty(rawConfig);
    } catch (final ConfigException.WrongType e) {
        final String msgPattern = "Value at <{0}> was not of type Config!";
        throw new DittoConfigError(MessageFormat.format(msgPattern, DITTO_CONFIG_PATH), e);
    }
}
 
Example 12
Source File: DefaultScopedConfig.java    From ditto with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public List<? extends Object> getAnyRefList(final String path) {
    try {
        return config.getAnyRefList(path);
    } catch (final ConfigException.Missing | ConfigException.WrongType e) {
        final String msgPattern = "Failed to get List with elements of any kind for path <{0}>!";
        throw new DittoConfigError(MessageFormat.format(msgPattern, appendToConfigPath(path)), e);
    }
}
 
Example 13
Source File: DefaultScopedConfig.java    From ditto with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public double getDouble(final String path) {
    try {
        return tryToGetDoubleValue(path);
    } catch (final ConfigException.Missing | ConfigException.WrongType | NumberFormatException e) {
        final String msgPattern = "Failed to get double value for path <{0}>!";
        throw new DittoConfigError(MessageFormat.format(msgPattern, appendToConfigPath(path)), e);
    }
}
 
Example 14
Source File: DefaultScopedConfig.java    From ditto with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public List<Long> getLongList(final String path) {
    try {
        return config.getLongList(path);
    } catch (final ConfigException.Missing | ConfigException.WrongType e) {
        final String msgPattern = "Failed to get List of long values for path <{0}>!";
        throw new DittoConfigError(MessageFormat.format(msgPattern, appendToConfigPath(path)), e);
    }
}
 
Example 15
Source File: DefaultScopedConfig.java    From ditto with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public long getLong(final String path) {
    try {
        return tryToGetLongValue(path);
    } catch (final ConfigException.Missing | ConfigException.WrongType | NumberFormatException e) {
        final String msgPattern = "Failed to get long value for path <{0}>!";
        throw new DittoConfigError(MessageFormat.format(msgPattern, appendToConfigPath(path)), e);
    }
}
 
Example 16
Source File: DefaultScopedConfig.java    From ditto with Eclipse Public License 2.0 5 votes vote down vote up
private int tryToGetIntValue(final String path) {
    try {
        return config.getInt(path);
    } catch (final ConfigException.WrongType e) {
        final ConfigValue configValue = config.getValue(path);
        if (ConfigValueType.STRING == configValue.valueType()) {
            return Integer.parseInt(String.valueOf(configValue.unwrapped()));
        }
        throw e;
    }
}
 
Example 17
Source File: DefaultScopedConfig.java    From ditto with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public int getInt(final String path) {
    try {
        return tryToGetIntValue(path);
    } catch(final ConfigException.Missing | ConfigException.WrongType | NumberFormatException e) {
        final String msgPattern = "Failed to get int value for path <{0}>!";
        throw new DittoConfigError(MessageFormat.format(msgPattern, appendToConfigPath(path)), e);
    }
}
 
Example 18
Source File: DefaultScopedConfig.java    From ditto with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Number getNumber(final String path) {
    try {
        return config.getNumber(path);
    } catch (final ConfigException.Missing | ConfigException.WrongType e) {
        final String msgPattern = "Failed to get Number for path <{0}>!";
        throw new DittoConfigError(MessageFormat.format(msgPattern, appendToConfigPath(path)), e);
    }
}
 
Example 19
Source File: DefaultScopedConfig.java    From ditto with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public List<Duration> getDurationList(final String path) {
    try {
        return config.getDurationList(path);
    } catch (final ConfigException.Missing | ConfigException.WrongType e) {
        final String msgPattern = "Failed to get List of Durations for path <{0}>!";
        throw new DittoConfigError(MessageFormat.format(msgPattern, appendToConfigPath(path)), e);
    }
}
 
Example 20
Source File: DefaultScopedConfig.java    From ditto with Eclipse Public License 2.0 5 votes vote down vote up
private static Config tryToGetAsConfig(final Config originalConfig, final String configPath) {
    try {
        return originalConfig.getConfig(configPath);
    } catch (final ConfigException.Missing | ConfigException.WrongType e) {
        final String msgPattern = "Failed to get nested Config at <{0}>!";
        throw new DittoConfigError(MessageFormat.format(msgPattern, configPath), e);
    }
}