Example usage for java.util Properties containsKey

List of usage examples for java.util Properties containsKey

Introduction

In this page you can find the example usage for java.util Properties containsKey.

Prototype

@Override
    public boolean containsKey(Object key) 

Source Link

Usage

From source file:nl.strohalm.cyclos.CyclosConfiguration.java

private static void ensureProperty(final String property, final Integer value, final Properties properties) {
    if (!properties.containsKey(property)) {
        properties.put(property, value.toString());
    }//w w  w.  j a  va 2  s.  co  m
}

From source file:hd3gtv.embddb.MainClass.java

private static List<InetSocketAddress> importConf(PoolManager poolmanager, Properties conf, int default_port)
        throws Exception {
    if (conf.containsKey("hosts") == false) {
        throw new NullPointerException("No hosts in configuration");
    }/*from   w  ww  . j  a  v a 2  s.  c o m*/
    String hosts = conf.getProperty("hosts");

    return Arrays.asList(hosts.split(" ")).stream().map(addr -> {
        if (addr.isEmpty() == false) {
            log.debug("Found host in configuration: " + addr);
            return new InetSocketAddress(addr, default_port);
        } else {
            return null;
        }
    }).filter(addr -> {
        return addr != null;
    }).collect(Collectors.toList());
}

From source file:gobblin.kafka.schemareg.KafkaSchemaRegistryFactory.java

@SuppressWarnings("unchecked")
public static KafkaSchemaRegistry getSchemaRegistry(Properties props) {
    Preconditions.checkArgument(/*  w  w w .j  a v  a 2s .com*/
            props.containsKey(KafkaSchemaRegistryConfigurationKeys.KAFKA_SCHEMA_REGISTRY_CLASS),
            "Missing required property " + KafkaSchemaRegistryConfigurationKeys.KAFKA_SCHEMA_REGISTRY_CLASS);

    boolean tryCache = Boolean.parseBoolean(props.getProperty(
            KafkaSchemaRegistryConfigurationKeys.KAFKA_SCHEMA_REGISTRY_CACHE, DEFAULT_TRY_CACHING));

    Class<?> clazz;
    try {
        clazz = (Class<?>) Class
                .forName(props.getProperty(KafkaSchemaRegistryConfigurationKeys.KAFKA_SCHEMA_REGISTRY_CLASS));
        KafkaSchemaRegistry schemaRegistry = (KafkaSchemaRegistry) ConstructorUtils.invokeConstructor(clazz,
                props);
        if (tryCache && !schemaRegistry.hasInternalCache()) {
            schemaRegistry = new CachingKafkaSchemaRegistry(schemaRegistry);
        }
        return schemaRegistry;
    } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException
            | InstantiationException e) {
        log.error("Failed to instantiate " + KafkaSchemaRegistry.class, e);
        throw Throwables.propagate(e);
    }
}

From source file:io.unravelling.ferguson.configuration.FergusonConfiguration.java

/**
 * Validates the server password that was supplied.
 * @param configuration Configuration of the server.
 * @return Boolean indicating if the server configuration is correct or not.
 *//*from w  w  w.j ava 2 s.c om*/
static boolean validateServerPassword(final Properties configuration) {

    return configuration.containsKey(FergusonConfiguration.SERVER_PASSWORD);
}

From source file:io.unravelling.ferguson.configuration.FergusonConfiguration.java

/**
 * Validates the server type that was supplied.
 * @param configuration Configuration of the server.
 * @return Boolean indicating if the server configuration is correct or not.
 *///from   w w  w. jav  a  2  s . c  om
static boolean validateServerType(final Properties configuration) {

    return (configuration.containsKey(FergusonConfiguration.SERVER_TYPE) && EnumUtils
            .isValidEnum(ServerType.class, configuration.getProperty(FergusonConfiguration.SERVER_TYPE)));
}

From source file:io.unravelling.ferguson.configuration.FergusonConfiguration.java

/**
 * Validates the server URL that was supplied.
 * @param configuration Configuration of the server.
 * @return Boolean indicating if the server configuration is correct or not.
 *//*  ww  w .j a v  a  2 s  . co  m*/
static boolean validateServerUrl(final Properties configuration) {

    return (configuration.containsKey(FergusonConfiguration.SERVER_URL)
            && !configuration.getProperty(FergusonConfiguration.SERVER_URL).isEmpty());
}

From source file:io.unravelling.ferguson.configuration.FergusonConfiguration.java

/**
 * Validates the server username that was supplied.
 * @param configuration Configuration of the server.
 * @return Boolean indicating if the server configuration is correct or not.
 *//*from   w ww. j  a va 2  s .c o m*/
static boolean validateServerUsername(final Properties configuration) {

    return (configuration.containsKey(FergusonConfiguration.SERVER_USERNAME)
            && !configuration.getProperty(FergusonConfiguration.SERVER_USERNAME).isEmpty());
}

From source file:dk.alexandra.fresco.suite.bgw.configuration.BgwConfiguration.java

public static BgwConfiguration fromCmdLine(SCEConfiguration sceConf, CommandLine cmd) throws ParseException {
    // Validate BGW specific arguments.
    Properties p = cmd.getOptionProperties("D");
    if (!p.containsKey("bgw.threshold")) {
        throw new ParseException("BGW requires setting -Dbgw.threshold=[int]");
    }/*from  w ww . j  a  v  a 2s. c  o  m*/

    try {
        final int threshold = Integer.parseInt(p.getProperty("bgw.threshold"));
        if (threshold < 1)
            throw new ParseException("bgw.threshold must be > 0");
        if (threshold > sceConf.getParties().size() / 2)
            throw new ParseException("bgw.threshold must be < n/2");

        final BigInteger modulus = new BigInteger(p.getProperty("bgw.modulus", "618970019642690137449562111"));
        if (!modulus.isProbablePrime(40)) {
            throw new ParseException("BGW Modulus must be a prime number");
        }

        return new BgwConfiguration() {

            @Override
            public int getThreshold() {
                return threshold;
            }

            @Override
            public BigInteger getModulus() {
                return modulus;
            }

        };
    } catch (NumberFormatException e) {
        throw new ParseException("Invalid bgw.threshold value: '" + p.getProperty("bgw.threshold") + "'");
    }
}

From source file:com.anjlab.tapestry5.services.ConfigHelper.java

private static void assertPropertyDefined(String propertyName, Properties properties) {
    if (!properties.containsKey(propertyName)) {
        throw new IllegalStateException("Required property not defined: " + propertyName);
    }/*from  w w  w.j  a va2 s  . c om*/
}

From source file:de.hypoport.ep2.support.configuration.properties.PropertiesLoader.java

private static boolean propertyLocationsPresent(Properties locationProperties) {
    return locationProperties.containsKey(PROPERTY_LOCATIONS);
}