java.util.Properties#containsKey ( )源码实例Demo

下面列出了java.util.Properties#containsKey ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

private Properties createJobConfig(FlowSpec flowSpec) {
  Properties jobConfig = new Properties();
  Properties flowSpecProperties = flowSpec.getConfigAsProperties();

  jobConfig.putAll(this.properties);
  jobConfig.setProperty(ConfigurationKeys.JOB_NAME_KEY, flowSpec.getUri().toString());
  jobConfig.setProperty(ConfigurationKeys.JOB_GROUP_KEY,
      flowSpec.getConfig().getValue(ConfigurationKeys.FLOW_GROUP_KEY).toString());
  jobConfig.setProperty(ConfigurationKeys.FLOW_RUN_IMMEDIATELY,
      ConfigUtils.getString((flowSpec).getConfig(), ConfigurationKeys.FLOW_RUN_IMMEDIATELY, "false"));

  // todo : we should check if the job schedule is a valid cron schedule
  if (flowSpecProperties.containsKey(ConfigurationKeys.JOB_SCHEDULE_KEY) && StringUtils.isNotBlank(
      flowSpecProperties.getProperty(ConfigurationKeys.JOB_SCHEDULE_KEY))) {
    jobConfig.setProperty(ConfigurationKeys.JOB_SCHEDULE_KEY,
        flowSpecProperties.getProperty(ConfigurationKeys.JOB_SCHEDULE_KEY));
  }

  return jobConfig;
}
 
private static boolean isJulConfiguration(final Properties properties) {
    // First check for .levels as it's the cheapest
    if (properties.containsKey(".level")) {
        return true;
        // Check the handlers, in JBoss Log Manager they should be handler.HANDLER_NAME=HANDLER_CLASS,
        // J.U.L. uses fully.qualified.handler.class.property
    } else if (properties.containsKey("handlers")) {
        final String prop = properties.getProperty("handlers", "");
        if (prop != null && !prop.trim().isEmpty()) {
            final String[] handlers = prop.split("\\s*,\\s*");
            for (String handler : handlers) {
                final String key = String.format("handler.%s", handler);
                if (!properties.containsKey(key)) {
                    return true;
                }
            }
        }
    }
    // Assume it's okay
    return false;
}
 
源代码3 项目: docker-maven-plugin   文件: AuthConfigFactory.java
private AuthConfig getAuthConfigFromOpenShiftConfig(LookupMode lookupMode, Map authConfigMap) throws MojoExecutionException {
    Properties props = System.getProperties();
    String useOpenAuthModeProp = lookupMode.asSysProperty(AUTH_USE_OPENSHIFT_AUTH);
    // Check for system property
    if (props.containsKey(useOpenAuthModeProp)) {
        boolean useOpenShift = Boolean.valueOf(props.getProperty(useOpenAuthModeProp));
        if (useOpenShift) {
            return validateMandatoryOpenShiftLogin(parseOpenShiftConfig(), useOpenAuthModeProp);
        } else {
            return null;
        }
    }

    // Check plugin config
    Map mapToCheck = getAuthConfigMapToCheck(lookupMode,authConfigMap);
    if (mapToCheck != null && mapToCheck.containsKey(AUTH_USE_OPENSHIFT_AUTH) &&
        Boolean.valueOf((String) mapToCheck.get(AUTH_USE_OPENSHIFT_AUTH))) {
            return validateMandatoryOpenShiftLogin(parseOpenShiftConfig(), useOpenAuthModeProp);
    } else {
        return null;
    }
}
 
源代码4 项目: Flink-CEPplus   文件: Configuration.java
/**
 * Checks for the presence of the property <code>name</code> in the
 * deprecation map. Returns the first of the list of new keys if present
 * in the deprecation map or the <code>name</code> itself. If the property
 * is not presently set but the property map contains an entry for the
 * deprecated key, the value of the deprecated key is set as the value for
 * the provided property name.
 *
 * @param deprecations deprecation context
 * @param name the property name
 * @return the first property in the list of properties mapping
 *         the <code>name</code> or the <code>name</code> itself.
 */
private String[] handleDeprecation(DeprecationContext deprecations,
                                   String name) {
	if (null != name) {
		name = name.trim();
	}
	// Initialize the return value with requested name
	String[] names = new String[]{name};
	// Deprecated keys are logged once and an updated names are returned
	DeprecatedKeyInfo keyInfo = deprecations.getDeprecatedKeyMap().get(name);
	if (keyInfo != null) {
		if (!keyInfo.getAndSetAccessed()) {
			logDeprecation(keyInfo.getWarningMessage(name));
		}
		// Override return value for deprecated keys
		names = keyInfo.newKeys;
	}
	// If there are no overlay values we can return early
	Properties overlayProperties = getOverlay();
	if (overlayProperties.isEmpty()) {
		return names;
	}
	// Update properties and overlays with reverse lookup values
	for (String n : names) {
		String deprecatedKey = deprecations.getReverseDeprecatedKeyMap().get(n);
		if (deprecatedKey != null && !overlayProperties.containsKey(n)) {
			String deprecatedValue = overlayProperties.getProperty(deprecatedKey);
			if (deprecatedValue != null) {
				getProps().setProperty(n, deprecatedValue);
				overlayProperties.setProperty(n, deprecatedValue);
			}
		}
	}
	return names;
}
 
源代码5 项目: flink-statefun   文件: KafkaIngressSpec.java
private static KafkaIngressStartupPosition requireValidStartupPosition(
    KafkaIngressStartupPosition startupPosition, Properties properties) {
  if (startupPosition.isGroupOffsets()
      && !properties.containsKey(ConsumerConfig.GROUP_ID_CONFIG)) {
    throw new IllegalStateException(
        "The ingress is configured to start from committed consumer group offsets in Kafka, but no consumer group id was set.\n"
            + "Please set the group id with the withConsumerGroupId(String) method.");
  }

  return startupPosition;
}
 
private static Properties getTableProperties(Properties tableProperties) {
  if (null == tableProperties || tableProperties.size() == 0) {
    return (Properties) DEFAULT_TBL_PROPERTIES.clone();
  }

  for (String property : DEFAULT_TBL_PROPERTIES.stringPropertyNames()) {
    if (!tableProperties.containsKey(property)) {
      tableProperties.put(property, DEFAULT_TBL_PROPERTIES.get(property));
    }
  }

  return tableProperties;
}
 
源代码7 项目: h2o-2   文件: PersistS3.java
static ClientConfiguration s3ClientCfg() {
  ClientConfiguration cfg = new ClientConfiguration();
  Properties prop = System.getProperties();
  if( prop.containsKey(S3_SOCKET_TIMEOUT_PROP) ) cfg.setSocketTimeout(Integer.getInteger(S3_SOCKET_TIMEOUT_PROP));
  if( prop.containsKey(S3_CONNECTION_TIMEOUT_PROP) ) cfg.setConnectionTimeout(Integer
      .getInteger(S3_CONNECTION_TIMEOUT_PROP));
  if( prop.containsKey(S3_MAX_ERROR_RETRY_PROP) ) cfg.setMaxErrorRetry(Integer.getInteger(S3_MAX_ERROR_RETRY_PROP));
  if( prop.containsKey(S3_MAX_HTTP_CONNECTIONS_PROP) ) cfg.setMaxConnections(Integer
      .getInteger(S3_MAX_HTTP_CONNECTIONS_PROP));
  cfg.setProtocol(Protocol.HTTP);
  return cfg;
}
 
public static Properties convertDeprecatedProperties(Properties props) {
  if (props.containsKey(DEPRECATED_WATERMARK_REGEX_KEY)) {
    log.info(String.format("Found deprecated key %s. Replacing it with %s", DEPRECATED_WATERMARK_REGEX_KEY,
        org.apache.gobblin.data.management.version.finder.WatermarkDatasetVersionFinder.WATERMARK_REGEX_KEY));

    props.setProperty(org.apache.gobblin.data.management.version.finder.WatermarkDatasetVersionFinder.WATERMARK_REGEX_KEY,
        props.getProperty(DEPRECATED_WATERMARK_REGEX_KEY));
    props.remove(DEPRECATED_WATERMARK_REGEX_KEY);
  }

  return props;
}
 
源代码9 项目: gemfirexd-oss   文件: Hash1Index.java
@Override
protected void allocateMemory(Properties properties, int tmpFlag)
    throws StandardException {
  // hash index does not support case-sensitivity setting
  if (properties.containsKey(GfxdConstants.INDEX_CASE_SENSITIVE_PROP)) {
    throw StandardException.newException(
        SQLState.INDEX_CASE_INSENSITIVITY_NOT_SUPPORTED,
        "primary key constraint");
  }
}
 
源代码10 项目: XACML   文件: XACMLProperties.java
/**
 * Clear policy references from a Properties object.
 *
 * @param properties Properties object to clear
 * @param strField Key field
 * @return Properties object passed in
 */
public static Properties clearPolicyProperties(Properties properties, String strField) {
    String policyValue = properties.getProperty(strField);

    String[] policies = policyValue.split("\\s*,\\s*");

    for (String policy : policies) {
        if (properties.containsKey(policy + FILE_APPEND)) {
            properties.remove(policy + FILE_APPEND);
        }
    }

    return properties;
}
 
源代码11 项目: DDMQ   文件: ConfigUpdate.java
private void updateConfig(String config) {
    if (StringUtils.isEmpty(config)) {
        return;
    }
    log.info("update config:{}", config);
    Map<String, Object> configMap = JSONObject.parseObject(config, Map.class);
    if (configMap == null || configMap.isEmpty()) {
        return;
    }

    Properties properties = new Properties();
    for (Map.Entry<String, Object> entry : configMap.entrySet()) {
        if (isConfigIgnore(entry.getKey())) {
            log.info("not first start, ignore config:{}", entry.getKey());
            continue;
        }

        properties.put(entry.getKey(), entry.getValue().toString());
    }
    if (!controller.getBrokerConfig().isRoleConfigInit()) {
        properties.put(ConfigName.ROLE_CONFIG_INIT, "true");
    }
    log.info("properties:{}", properties);

    controller.getConfiguration().update(properties);

    if (properties.containsKey(ConfigName.NAME_SRV_ADDR) && controller.getBrokerOuterAPI() != null) {
        controller.getBrokerOuterAPI().updateNameServerAddressList(controller.getBrokerConfig().getNamesrvAddr());
        log.info("update name srv addr:{}", controller.getBrokerConfig().getNamesrvAddr());
    }
}
 
源代码12 项目: geowave   文件: Stanag4676ImageryChipService.java
private static String getProperty(final Properties props, final String name) {
  if (System.getProperty(name) != null) {
    return System.getProperty(name);
  } else if (props.containsKey(name)) {
    return props.getProperty(name);
  } else {
    return null;
  }
}
 
源代码13 项目: lams   文件: LdapExtLoginModule.java
/**
 * <p>
 * Logs the specified LDAP env, masking security-sensitive information (passwords).
 * </p>
 *
 * @param env the LDAP env to be logged.
 */
private void traceLDAPEnv(Properties env)
{
   Properties tmp = new Properties();
   tmp.putAll(env);
   if (tmp.containsKey(Context.SECURITY_CREDENTIALS))
      tmp.setProperty(Context.SECURITY_CREDENTIALS, "******");
   if (tmp.containsKey(BIND_CREDENTIAL))
      tmp.setProperty(BIND_CREDENTIAL, "******");
   PicketBoxLogger.LOGGER.traceLDAPConnectionEnv(tmp);
}
 
源代码14 项目: juddi   文件: WADL2UDDI.java
public WADL2UDDI(UDDIClerk clerk, URLLocalizer urlLocalizer, Properties properties) throws ConfigurationException {
    super();
    this.clerk = clerk;
    this.urlLocalizer = urlLocalizer;
    this.properties = properties;

    if (clerk != null) {
        if (!properties.containsKey("keyDomain")) {
            throw new ConfigurationException("Property keyDomain is a required property when using WADL2UDDI.");
        }
        if (!properties.containsKey("businessKey") && !properties.containsKey("businessName")) {
            throw new ConfigurationException("Either property businessKey, or businessName, is a required property when using WADL2UDDI.");
        }
        if (!properties.containsKey("nodeName")) {
            if (properties.containsKey("serverName") && properties.containsKey("serverPort")) {
                String nodeName = properties.getProperty("serverName") + "_" + properties.getProperty("serverPort");
                properties.setProperty("nodeName", nodeName);
            } else {
                throw new ConfigurationException("Property nodeName is not defined and is a required property when using WADL2UDDI.");
            }
        }
    }

    //Obtaining values from the properties
    this.keyDomainURI = "uddi:" + properties.getProperty("keyDomain") + ":";
    if (properties.contains(Property.BUSINESS_KEY)) {
        this.businessKey = properties.getProperty(Property.BUSINESS_KEY);
    } else {
        //using the BusinessKey Template, and the businessName to construct the key 
        this.businessKey = UDDIKeyConvention.getBusinessKey(properties);
    }
    this.lang = properties.getProperty(Property.LANG, Property.DEFAULT_LANG);
}
 
/**
 * Inject in some additional properties
 * @param jobProps job properties
 * @param inputTags list of metadata tags
 * @return
 */
private static List<? extends Tag<?>> addAdditionalMetadataTags(Properties jobProps, List<? extends Tag<?>> inputTags) {
  List<Tag<?>> metadataTags = Lists.newArrayList(inputTags);
  String jobId;

  // generate job id if not already set
  if (jobProps.containsKey(ConfigurationKeys.JOB_ID_KEY)) {
    jobId = jobProps.getProperty(ConfigurationKeys.JOB_ID_KEY);
  } else {
    jobId = JobLauncherUtils.newJobId(JobState.getJobNameFromProps(jobProps));
    jobProps.put(ConfigurationKeys.JOB_ID_KEY, jobId);
  }

  String jobExecutionId = Long.toString(Id.Job.parse(jobId).getSequence());

  // only inject flow tags if a flow name is defined
  if (jobProps.containsKey(ConfigurationKeys.FLOW_NAME_KEY)) {
    metadataTags.add(new Tag<>(TimingEvent.FlowEventConstants.FLOW_GROUP_FIELD,
        jobProps.getProperty(ConfigurationKeys.FLOW_GROUP_KEY, "")));
    metadataTags.add(
        new Tag<>(TimingEvent.FlowEventConstants.FLOW_NAME_FIELD, jobProps.getProperty(ConfigurationKeys.FLOW_NAME_KEY)));

    // use job execution id if flow execution id is not present
    metadataTags.add(new Tag<>(TimingEvent.FlowEventConstants.FLOW_EXECUTION_ID_FIELD,
        jobProps.getProperty(ConfigurationKeys.FLOW_EXECUTION_ID_KEY, jobExecutionId)));
  }

  metadataTags.add(new Tag<>(TimingEvent.FlowEventConstants.JOB_GROUP_FIELD,
      jobProps.getProperty(ConfigurationKeys.JOB_GROUP_KEY, "")));
  metadataTags.add(new Tag<>(TimingEvent.FlowEventConstants.JOB_NAME_FIELD,
      jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY, "")));
  metadataTags.add(new Tag<>(TimingEvent.FlowEventConstants.JOB_EXECUTION_ID_FIELD, jobExecutionId));

  LOGGER.debug("GobblinHelixJobLauncher.addAdditionalMetadataTags: metadataTags {}", metadataTags);

  return metadataTags;
}
 
public PropertyFileAbstractMarker(Properties p) throws Exception {
  super("", "", MarkerColors.Aqua);
  if (!p.containsKey(CONDITION) || !p.containsKey(DESCRIPTION) || !p.containsKey(GROUPS) || !p.containsKey(NAME) || !p.containsKey(IGNORE_CASE)) {
    throw new Exception("Not enought parameters");
  }
  this.ignoreCase = Boolean.parseBoolean(p.getProperty(IGNORE_CASE));

  if (ignoreCase) {
    this.condition = p.getProperty(CONDITION).toLowerCase();
  } else {
    this.condition = p.getProperty(CONDITION);
  }

  this.description = p.getProperty(DESCRIPTION);
  this.groups = p.getProperty(GROUPS).split(",");
  for (int i = 0; i < groups.length; i++) {
    groups[i] = groups[i].trim();
  }
  this.name = p.getProperty(NAME);
  this.include = Boolean.parseBoolean(p.getProperty(INCLUDE, "true"));
  this.markerColors = MarkerColors.fromString(p.getProperty(COLOR, ""));
  if (p.containsKey(FILE)) {
    fileName = p.getProperty(FILE);
  }
  test1 = p.getProperty(TEST_STRING_1, "");
  test2 = p.getProperty(TEST_STRING_2, "");
  test3 = p.getProperty(TEST_STRING_3, "");
}
 
源代码17 项目: pgadba   文件: PgSessionBuilder.java
/**
 * Parses the postgresql connection url that the user supplies to the library.
 * @param url url string
 * @param defaults the default values that's used if the user doesn't override them
 * @return a map of properties
 */
public static Map<SessionProperty, Object> parseUrl(String url, Properties defaults) {
  Map<SessionProperty, Object> urlProps = new HashMap<>();

  String urlServer = url;
  String urlArgs = "";

  int qPos = url.indexOf('?');
  if (qPos != -1) {
    urlServer = url.substring(0, qPos);
    urlArgs = url.substring(qPos + 1);
  }

  if (!urlServer.startsWith("jdbc:postgresql:")) {
    return null;
  }
  urlServer = urlServer.substring("jdbc:postgresql:".length());

  if (urlServer.startsWith("//")) {
    urlServer = urlServer.substring(2);
    int slash = urlServer.indexOf('/');
    if (slash == -1) {
      return null;
    }
    urlProps.put(PgSessionProperty.DATABASE,
        URLDecoder.decode(urlServer.substring(slash + 1), StandardCharsets.UTF_8));

    String[] addresses = urlServer.substring(0, slash).split(",");
    StringBuilder hosts = new StringBuilder();
    StringBuilder ports = new StringBuilder();
    for (String address : addresses) {
      int portIdx = address.lastIndexOf(':');
      if (portIdx != -1 && address.lastIndexOf(']') < portIdx) {
        String portStr = address.substring(portIdx + 1);
        try {
          // squid:S2201 The return value of "parseInt" must be used.
          // The side effect is NumberFormatException, thus ignore sonar error here
          Integer.parseInt(portStr); // NOSONAR
        } catch (NumberFormatException ex) {
          return null;
        }
        ports.append(portStr);
        hosts.append(address.subSequence(0, portIdx));
      } else {
        ports.append("5432");
        hosts.append(address);
      }
      ports.append(',');
      hosts.append(',');
    }
    ports.setLength(ports.length() - 1);
    hosts.setLength(hosts.length() - 1);
    urlProps.put(PgSessionProperty.PORT, Integer.parseInt(ports.toString()));
    urlProps.put(PgSessionProperty.HOST, hosts.toString());
  } else {
    /*
     * if there are no defaults set or any one of PORT, HOST, DBNAME not set then
     * set it to default
     */
    if (defaults == null || !defaults.containsKey(PgSessionProperty.PORT.name())) {
      urlProps.put(PgSessionProperty.PORT, 5432);
    }
    if (defaults == null || !defaults.containsKey(PgSessionProperty.HOST.name())) {
      urlProps.put(PgSessionProperty.HOST, "localhost");
    }
    if (defaults == null || !defaults.containsKey(PgSessionProperty.DATABASE.name())) {
      urlProps.put(PgSessionProperty.DATABASE, URLDecoder.decode(urlServer, StandardCharsets.UTF_8));
    }
  }

  // parse the args part of the url
  String[] args = urlArgs.split("&");
  for (String token : args) {
    if (token.isEmpty()) {
      continue;
    }
    int pos = token.indexOf('=');
    if (pos == -1) {
      urlProps.put(PgSessionProperty.lookup(token), "");
    } else {
      urlProps.put(PgSessionProperty.lookup(token.substring(0, pos)),
          URLDecoder.decode(token.substring(pos + 1), StandardCharsets.UTF_8));
    }
  }

  return urlProps;
}
 
public StandaloneStreamUpdateHandler(KeyStore keystore, Properties properties, StandaloneDirectoryClient directoryClient, StoreClient storeClient) {
  super(StandaloneStreamUpdateWebSocket.class);

  this.keyStore = keystore;
  
  this.classKeyLongs = SipHashInline.getKey(this.keyStore.getKey(KeyStore.SIPHASH_CLASS));    
  this.labelsKeyLongs = SipHashInline.getKey(this.keyStore.getKey(KeyStore.SIPHASH_LABELS));

  this.storeClient = storeClient;
  this.directoryClient = directoryClient;
  this.properties = properties;
  this.updateActivity = "true".equals(properties.getProperty(Configuration.INGRESS_ACTIVITY_UPDATE));

  this.maxValueSize = Long.parseLong(properties.getProperty(Configuration.STANDALONE_VALUE_MAXSIZE, StandaloneIngressHandler.DEFAULT_VALUE_MAXSIZE));
  
  this.parseAttributes = "true".equals(properties.getProperty(Configuration.INGRESS_PARSE_ATTRIBUTES));
  this.allowDeltaAttributes = "true".equals(WarpConfig.getProperty(Configuration.INGRESS_ATTRIBUTES_ALLOWDELTA));

  if (null != WarpConfig.getProperty(Configuration.INGRESS_MAXPAST_DEFAULT)) {
    this.maxpastDefault = Long.parseLong(WarpConfig.getProperty(Configuration.INGRESS_MAXPAST_DEFAULT));
    if (this.maxpastDefault < 0) {
      throw new RuntimeException("Value of '" + Configuration.INGRESS_MAXPAST_DEFAULT + "' MUST be positive.");
    }
  } else {
    this.maxpastDefault = null;
  }
  
  if (null != WarpConfig.getProperty(Configuration.INGRESS_MAXFUTURE_DEFAULT)) {
    this.maxfutureDefault = Long.parseLong(WarpConfig.getProperty(Configuration.INGRESS_MAXFUTURE_DEFAULT));
    if (this.maxfutureDefault < 0) {
      throw new RuntimeException("Value of '" + Configuration.INGRESS_MAXFUTURE_DEFAULT + "' MUST be positive.");
    }
  } else {
    this.maxfutureDefault = null;
  }

  if (null != WarpConfig.getProperty(Configuration.INGRESS_MAXPAST_OVERRIDE)) {
    this.maxpastOverride = Long.parseLong(WarpConfig.getProperty(Configuration.INGRESS_MAXPAST_OVERRIDE));
    if (this.maxpastOverride < 0) {
      throw new RuntimeException("Value of '" + Configuration.INGRESS_MAXPAST_OVERRIDE + "' MUST be positive.");
    }
  } else {
    this.maxpastOverride = null;
  }
  
  if (null != WarpConfig.getProperty(Configuration.INGRESS_MAXFUTURE_OVERRIDE)) {
    this.maxfutureOverride = Long.parseLong(WarpConfig.getProperty(Configuration.INGRESS_MAXFUTURE_OVERRIDE));
    if (this.maxfutureOverride < 0) {
      throw new RuntimeException("Value of '" + Configuration.INGRESS_MAXFUTURE_OVERRIDE + "' MUST be positive.");
    }
  } else {
    this.maxfutureOverride = null;
  }
  
  this.ignoreOutOfRange = "true".equals(WarpConfig.getProperty(Configuration.INGRESS_OUTOFRANGE_IGNORE));
  
  if ("false".equals(properties.getProperty(Configuration.DATALOG_LOGSHARDKEY))) {
    logShardKey = false;
  } else {
    logShardKey = true;
  }

  if (properties.containsKey(Configuration.DATALOG_DIR)) {
    File dir = new File(properties.getProperty(Configuration.DATALOG_DIR));
    
    if (!dir.exists()) {
      throw new RuntimeException("Data logging target '" + dir + "' does not exist.");
    } else if (!dir.isDirectory()) {
      throw new RuntimeException("Data logging target '" + dir + "' is not a directory.");
    } else {
      loggingDir = dir;
      LOG.info("Data logging enabled in directory '" + dir + "'.");
    }
    
    String id = properties.getProperty(Configuration.DATALOG_ID);
    
    if (null == id) {
      throw new RuntimeException("Property '" + Configuration.DATALOG_ID + "' MUST be set to a unique value for this instance.");
    } else {
      datalogId = new String(OrderPreservingBase64.encode(id.getBytes(StandardCharsets.UTF_8)), StandardCharsets.US_ASCII);
    }
    
  } else {
    loggingDir = null;
    datalogId = null;
  }

  this.datalogSync = "true".equals(WarpConfig.getProperty(Configuration.DATALOG_SYNC));
  if (properties.containsKey(Configuration.DATALOG_PSK)) {
    this.datalogPSK = this.keyStore.decodeKey(properties.getProperty(Configuration.DATALOG_PSK));
  } else {
    this.datalogPSK = null;
  }    
}
 
源代码19 项目: luxun   文件: Utils.java
public static String getString(Properties props, String name) {
    if (props.containsKey(name)) {
        return props.getProperty(name);
    }
    throw new IllegalArgumentException("Missing required property '" + name + "'");
}
 
源代码20 项目: wisdom   文件: Instructions.java
/**
 * Utility method to merge instructions from {@code props2} into the {@code props1}. The instructions
 * from {@code props2} do not override the instructions  from {@code props1} (when both contain the same
 * instruction), so instructions from {@code props1} stay unchanged and are contained in the file set of
 * instructions.
 * <p>
 * Notice that entries with empty values from {@code props2} are <strong>not</strong> merged.
 *
 * @param props1 the first set of instructions
 * @param props2 the second set of instructions
 * @return the new set of instructions containing the instructions from {@code props2} merged into {@code props1}.
 */
public static Properties mergeAndSkipExisting(Properties props1, Properties props2) {
    Properties properties = new Properties();
    properties.putAll(props1);
    for (String key : props2.stringPropertyNames()) {
        if (!props1.containsKey(key) && !Strings.isNullOrEmpty(props2.getProperty(key))) {
            properties.put(key, props2.getProperty(key));
        }
    }
    return properties;
}