List of usage examples for java.util Map containsKey
boolean containsKey(Object key);
From source file:it.damore.solr.importexport.App.java
/** * @throws IOException//from w w w .j a v a 2 s. co m * @throws JsonParseException * @throws JsonMappingException * @throws MalformedURLException */ private static void readUniqueKeyFromSolrSchema() throws IOException, JsonParseException, JsonMappingException, MalformedURLException { String sUrl = config.getSolrUrl() + "/schema/uniquekey?wt=json"; Map<String, Object> uniqueKey = objectMapper.readValue(readUrl(sUrl), new TypeReference<Map<String, Object>>() { }); if (uniqueKey.containsKey("uniqueKey")) { config.setUniqueKey((String) uniqueKey.get("uniqueKey")); } else { logger.warn("unable to find valid uniqueKey defaulting to \"id\"."); } }
From source file:Main.java
/** * <p>Generate reverse result</p> * @param allResult all result// ww w. j a va 2s. c o m * @param partResult part result * @return reverse result */ public static <T extends Object> List<T> getReverseResult(Set<T> allResult, Set<T> partResult) { List<T> resultList = new ArrayList<T>(); Map<T, T> map = new HashMap<T, T>(); if (partResult != null) { for (T obj : partResult) { map.put(obj, obj); } } if (allResult != null) { Iterator<T> itor = allResult.iterator(); while (itor.hasNext()) { T obj = itor.next(); if (map.containsKey(obj)) { itor.remove(); } else { resultList.add(obj); } } } return resultList; }
From source file:com.netflix.spinnaker.clouddriver.kubernetes.v2.description.manifest.KubernetesManifestAnnotater.java
private static void storeAnnotation(Map<String, String> annotations, String key, Object value) { if (value == null) { return;/*from w w w . j a va 2 s .c o m*/ } if (annotations.containsKey(key)) { return; } try { if (value instanceof String) { // The "write value as string" method will attach quotes which are ugly to read annotations.put(key, (String) value); } else { annotations.put(key, objectMapper.writeValueAsString(value)); } } catch (JsonProcessingException e) { throw new IllegalArgumentException("Illegal annotation value for '" + key + "': " + e); } }
From source file:com.yahoo.gondola.container.Utils.java
public static String getAppUri(Config config, String hostId) { InetSocketAddress address = config.getAddressForHost(hostId); Map<String, String> attrs = config.getAttributesForHost(hostId); String appUri = String.format("%s://%s:%s", attrs.get(APP_SCHEME), address.getHostName(), attrs.get(APP_PORT));/*w ww . j a v a 2 s .c om*/ if (!attrs.containsKey(APP_PORT) || !attrs.containsKey(APP_SCHEME)) { throw new IllegalStateException( String.format("gondola.hosts[%s] is missing either the %s or %s config values", hostId, APP_PORT, APP_SCHEME)); } return appUri; }
From source file:org.jspringbot.keyword.expression.ELUtils.java
@SuppressWarnings("unchecked") public static List<Long> getExcludeIndices() { Map<String, Object> variables = getVariables().getVariables(); if (variables.containsKey(EXCLUDE_INDICES)) { return (List<Long>) variables.get(EXCLUDE_INDICES); }/*from w w w. j a v a 2 s. c om*/ return Collections.emptyList(); }
From source file:com.chiorichan.configuration.serialization.ConfigurationSerialization.java
/** * Attempts to deserialize the given arguments into a new instance of the given class. * <p />/*w w w. j a va2s . co m*/ * The class must implement {@link ConfigurationSerializable}, including the extra methods as specified in the javadoc of ConfigurationSerializable. * <p /> * If a new instance could not be made, an example being the class not fully implementing the interface, null will be returned. * * @param args * Arguments for deserialization * @return New instance of the specified class */ public static ConfigurationSerializable deserializeObject(Map<String, Object> args) { Class<? extends ConfigurationSerializable> clazz = null; if (args.containsKey(SERIALIZED_TYPE_KEY)) { try { String alias = (String) args.get(SERIALIZED_TYPE_KEY); if (alias == null) { throw new IllegalArgumentException("Cannot have null alias"); } clazz = getClassByAlias(alias); if (clazz == null) { throw new IllegalArgumentException("Specified class does not exist ('" + alias + "')"); } } catch (ClassCastException ex) { ex.fillInStackTrace(); throw ex; } } else { throw new IllegalArgumentException("Args doesn't contain type key ('" + SERIALIZED_TYPE_KEY + "')"); } return new ConfigurationSerialization(clazz).deserialize(args); }
From source file:com.github.rinde.gpem17.evo.StatsLogger.java
static <T extends Enum<?>> StringBuilder appendValuesTo(StringBuilder sb, Map<T, Object> props, T[] keys) { final List<Object> values = new ArrayList<>(); for (final T p : keys) { checkArgument(props.containsKey(p)); values.add(props.get(p));//w w w . j a v a2s. com } COMMA_JOINER.appendTo(sb, values); return sb; }
From source file:Main.java
public static Integer firstUnique(Collection<Integer> collection) { Map<Integer, Integer> linkedHashMap = new LinkedHashMap<Integer, Integer>(); java.util.Iterator<Integer> it = collection.iterator(); Integer currentInt;// ww w . j av a 2 s . co m java.util.Iterator it1; Set entrySet; Map.Entry<Integer, Integer> me; while (it.hasNext()) { currentInt = it.next(); if (!linkedHashMap.containsKey(currentInt)) { linkedHashMap.put(currentInt, 1); } else { linkedHashMap.put(currentInt, linkedHashMap.get(currentInt) + 1); } } entrySet = linkedHashMap.entrySet(); it1 = entrySet.iterator(); while (it1.hasNext()) { me = (Entry) it1.next(); if (me.getValue().equals(1)) { return (Integer) me.getKey(); } } return null; }
From source file:com.streamsets.pipeline.lib.el.StringEL.java
private static Pattern getPattern(Map<String, Pattern> patterns, String regEx) { if (patterns != null && patterns.containsKey(regEx)) { return patterns.get(regEx); } else {//from w w w.j a va 2 s. c o m Pattern pattern = Pattern.compile(regEx); if (patterns != null) { patterns.put(regEx, pattern); } return pattern; } }
From source file:com.vmware.identity.openidconnect.protocol.TokenRequest.java
public static TokenRequest parse(HttpRequest httpRequest) throws ParseException { Validate.notNull(httpRequest, "httpRequest"); Map<String, String> parameters = httpRequest.getParameters(); AuthorizationGrant authzGrant = AuthorizationGrant.parse(parameters); Scope scope = null;/*from w w w . ja v a 2s . c om*/ if (parameters.containsKey("scope")) { scope = Scope.parse(ParameterMapUtils.getString(parameters, "scope")); } SolutionUserAssertion solutionUserAssertion = null; if (parameters.containsKey("solution_user_assertion")) { solutionUserAssertion = SolutionUserAssertion.parse(parameters); } ClientAssertion clientAssertion = null; if (parameters.containsKey("client_assertion")) { clientAssertion = ClientAssertion.parse(parameters); } CorrelationID correlationId = null; if (parameters.containsKey("correlation_id")) { correlationId = new CorrelationID(ParameterMapUtils.getString(parameters, "correlation_id")); } if (parameters.get("client_id") != null) { throw new ParseException("client_id parameter is not allowed, send client_assertion instead"); } validate(authzGrant, scope, solutionUserAssertion, clientAssertion); return new TokenRequest(httpRequest.getURI(), authzGrant, scope, solutionUserAssertion, clientAssertion, correlationId); }