List of usage examples for java.util Set contains
boolean contains(Object o);
From source file:com.siemens.sw360.importer.ComponentImportUtils.java
@NotNull private static HashSet<Release> getUpdatedReleases(Map<String, Release> releasesByIdentifier, final Set<String> releasesIdentifiersToBeUpdated) { return Sets.newHashSet(Maps.filterKeys(releasesByIdentifier, new Predicate<String>() { @Override// w ww. j a v a 2s .c o m public boolean apply(String input) { return releasesIdentifiersToBeUpdated.contains(input); } }).values()); }
From source file:com.tweetlanes.android.core.model.ComposeTweetDefault.java
private static String getReplyToUserNamesAsString(String userScreenName, TwitterStatuses inReplyToStatusList) { String replyingToUsers = ""; Set<String> screenNameSet = new HashSet<String>(); if (userScreenName != null) { screenNameSet.add(userScreenName.toLowerCase()); }//from w ww.jav a2 s.c o m // Note: There are 2 for loops here so that we cleanly handle the case // where a user replies to their own tweet. for (int i = 0; i < inReplyToStatusList.getStatusCount(); i++) { TwitterStatus status = inReplyToStatusList.getStatus(i); String author = status.getAuthorScreenName(); if (!screenNameSet.contains(author.toLowerCase())) { screenNameSet.add(author.toLowerCase()); replyingToUsers += "@" + author + " "; } if (status.mIsRetweet) { String tweeter = status.mUserScreenName; if (!screenNameSet.contains(tweeter.toLowerCase())) { screenNameSet.add(tweeter.toLowerCase()); replyingToUsers += "@" + tweeter + " "; } } } for (int i = 0; i < inReplyToStatusList.getStatusCount(); i++) { TwitterStatus status = inReplyToStatusList.getStatus(i); String[] userMentions = status.mUserMentions; if (userMentions != null) { for (String screenName : userMentions) { if (!screenNameSet.contains(screenName.toLowerCase())) { screenNameSet.add(screenName.toLowerCase()); replyingToUsers += "@" + screenName + " "; } } } } return replyingToUsers; }
From source file:com.github.rinde.opt.localsearch.Swaps.java
static <C, T> Iterator<Swap<T>> swapIterator(Schedule<C, T> schedule) { final ImmutableList.Builder<Iterator<Swap<T>>> iteratorBuilder = ImmutableList.builder(); final Set<T> seen = newLinkedHashSet(); for (int i = 0; i < schedule.routes.size(); i++) { final ImmutableList<T> row = schedule.routes.get(i); for (int j = 0; j < row.size(); j++) { final T t = row.get(j); if (j >= schedule.startIndices.getInt(i) && !seen.contains(t)) { iteratorBuilder.add(oneItemSwapIterator(schedule, schedule.startIndices, t, i)); }/*from w ww . ja v a2 s . c om*/ seen.add(t); } } return Iterators.concat(iteratorBuilder.build().iterator()); }
From source file:com.netflix.spinnaker.halyard.deploy.deployment.v1.OrcaRunner.java
private static void logPipelineOutput(Pipeline pipeline, Set<String> loggedTasks) { List<Pipeline.Stage> stages = pipeline.getStages(); for (Pipeline.Stage stage : stages) { String stageName = formatId(stage.type != null ? stage.type : stage.id); for (Pipeline.Stage.Task task : stage.getTasks()) { String taskName = formatId(task.name != null ? task.name : task.id); String fullTaskId = stageName + ": " + taskName; String taskStatus = task.getStatus(); if (!loggedTasks.contains(fullTaskId) && (taskStatus.equalsIgnoreCase("running") || taskStatus.equalsIgnoreCase("succeeded"))) { DaemonTaskHandler.message(taskName); loggedTasks.add(fullTaskId); }//www . j a va2 s . c o m } } }
From source file:com.netflix.spinnaker.halyard.deploy.provider.v1.OrcaRunner.java
private static void logPipelineOutput(Pipeline pipeline, Set<String> loggedTasks) { List<Pipeline.Stage> stages = pipeline.getStages(); for (Pipeline.Stage stage : stages) { String stageName = formatId(stage.type != null ? stage.type : stage.id); for (Pipeline.Stage.Task task : stage.getTasks()) { String taskName = formatId(task.name != null ? task.name : task.id); String fullTaskId = stageName + ": " + taskName; String taskStatus = task.getStatus(); if (!loggedTasks.contains(fullTaskId) && (taskStatus.equalsIgnoreCase("running") || taskStatus.equalsIgnoreCase("succeeded"))) { DaemonTaskHandler.log(taskName); loggedTasks.add(fullTaskId); }//from w w w . j a v a 2 s .c o m } } }
From source file:com.aurel.track.admin.customize.category.filter.tree.design.FilterUpperFromQNodeTransformer.java
/** * Gets the value form the qNodeExpression * @param qNodeExpression/*from ww w. ja v a 2 s .c om*/ * @param directProcessFields * @param presentUpperFields out parameter to gather the present upper fields * @param directValuesMap map for direct values (those with hard coded matcher) * @param presentUpperCustomSelectFieldsMap gather the custom simple selects on the upper part * @param matcherExpressionMap gather the simple field expressions (matcher is not hard coded) */ private static void getValueFromQNodeExpression(QNodeExpression qNodeExpression, Set<Integer> directProcessFields, Set<Integer> presentUpperFields, Map<Integer, List<Object>> directValuesMap, Map<Integer, Integer> presentUpperCustomSelectFieldsMap, Map<Integer, QNodeExpression> matcherExpressionMap) { Integer fieldID = qNodeExpression.getField(); boolean isCustomSelect = FieldBL.isCustomSelect(fieldID); presentUpperFields.add(fieldID); if (directProcessFields.contains(fieldID) || isCustomSelect) { //hard coded matchers: system/custom simple selects, miscellaneous filtering attributes //List of Object because simple selects are Integer[] and miscellaneous values are Strings //(typically valid Integer strings except the keyword) because the haven't fieldType based matchers List<Object> fieldValuesList = directValuesMap.get(fieldID); if (fieldValuesList == null) { fieldValuesList = new LinkedList<Object>(); directValuesMap.put(fieldID, fieldValuesList); } fieldValuesList.add(qNodeExpression.getValue()); if (isCustomSelect) { if (!presentUpperCustomSelectFieldsMap.keySet().contains(fieldID)) { presentUpperCustomSelectFieldsMap.put(fieldID, FieldBL.getSystemOptionType(fieldID)); } } } else { //simple field expressions: the matcher is not hard coded, it should be dealt with fieldType specific matcherExpressionMap.put(fieldID, qNodeExpression); } }
From source file:com.shieldsbetter.sbomg.ViewModelGenerator.java
private static void outfitModel(ModelClass dest, String contextName, Set<String> options, Object modelDesc) { boolean finalFlag = options.contains("final"); boolean leafFlag = options.contains("leaf"); String fieldName = contextName; if (fieldName.isEmpty()) { fieldName = "Value"; }/*from www. j a v a 2s. c om*/ if (modelDesc instanceof String) { String fieldTypeString = (String) modelDesc; TypeName fieldType = typeName(fieldTypeString); FieldSpec.Builder fieldBuild = FieldSpec.builder(fieldType, "my" + fieldName, Modifier.PRIVATE); dest.addRootMethod("get" + fieldName, fieldType, ImmutableList.of(), CodeBlock.builder().addStatement("return my$L", fieldName).build()); if (!leafFlag) { dest.addListenerEvent(contextName + "Updated", ImmutableList.of(ImmutablePair.of("value", fieldType), ImmutablePair.of("event", ClassName.get("", fieldTypeString + ".Event")))); } if (finalFlag) { fieldBuild.addModifiers(Modifier.FINAL); String paramName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, fieldName); dest.addInitializationParameter(paramName, fieldType); dest.addInitializationCode( CodeBlock.builder().addStatement("my$L = $L", fieldName, paramName).build()); if (!leafFlag) { dest.addInitializationCode(renderCodeBlock(SUBSCRIBE_TEMPL, "finalFlag", finalFlag, "fieldName", fieldName, "fieldType", fieldTypeString, "parentType", dest.getName())); } } else { String subscribeCode; if (leafFlag) { subscribeCode = ""; } else { FieldSpec.Builder subscriptionField = FieldSpec.builder( ClassName.get("", fieldTypeString + ".Subscription"), "my" + fieldName + "Subscription", Modifier.PRIVATE); dest.addField(subscriptionField.build()); subscribeCode = renderTemplate(SUBSCRIBE_TEMPL, "finalFlag", finalFlag, "fieldName", fieldName, "fieldType", fieldTypeString, "parentType", dest.getName()); } dest.addBuildCode( CodeBlock.builder().addStatement("l.on$LSet(this, my$L)", contextName, fieldName).build()); dest.addListenerEvent(contextName + "Set", ImmutableList.of(ImmutablePair.of("newValue", fieldType))); dest.addRootMethod("set" + contextName, TypeName.VOID, ImmutableList.of(ImmutablePair.of("newValue", fieldType)), renderCodeBlock(SET_METHOD_TEMPL, "parentType", dest.getName(), "fieldName", fieldName, "valueParam", "newValue", "leafFlag", leafFlag, "contextName", contextName, "afterUnsubscribe", subscribeCode)); } dest.addField(fieldBuild.build()); } else if (modelDesc instanceof List) { List listDesc = (List) modelDesc; switch (listDesc.size()) { case 1: { outfitModelWithList(dest, contextName, options, listDesc.get(0)); break; } case 2: { outfitModelWithList(dest, contextName, options, listDesc); break; } default: { throw new RuntimeException(); } } } else if (modelDesc instanceof Map) { Map<String, Object> mapDesc = (Map<String, Object>) modelDesc; for (Map.Entry<String, Object> field : mapDesc.entrySet()) { outfitModel(dest, contextName + field.getKey(), field.getValue()); } } else { throw new RuntimeException(modelDesc.getClass().getSimpleName()); } }
From source file:edu.uci.ics.hyracks.algebricks.core.algebra.util.OperatorPropertiesUtil.java
/** * Adds the free variables of the plan rooted at that operator to the * collection provided./*from w w w .jav a2s.co m*/ * * @param op * @param vars * - The collection to which the free variables will be added. */ public static void getFreeVariablesInSelfOrDesc(AbstractLogicalOperator op, Set<LogicalVariable> freeVars) throws AlgebricksException { HashSet<LogicalVariable> produced = new HashSet<LogicalVariable>(); VariableUtilities.getProducedVariables(op, produced); for (LogicalVariable v : produced) { freeVars.remove(v); } HashSet<LogicalVariable> used = new HashSet<LogicalVariable>(); VariableUtilities.getUsedVariables(op, used); for (LogicalVariable v : used) { if (!freeVars.contains(v)) { freeVars.add(v); } } if (op.hasNestedPlans()) { AbstractOperatorWithNestedPlans s = (AbstractOperatorWithNestedPlans) op; for (ILogicalPlan p : s.getNestedPlans()) { for (Mutable<ILogicalOperator> r : p.getRoots()) { getFreeVariablesInSelfOrDesc((AbstractLogicalOperator) r.getValue(), freeVars); } } s.getUsedVariablesExceptNestedPlans(freeVars); HashSet<LogicalVariable> produced2 = new HashSet<LogicalVariable>(); s.getProducedVariablesExceptNestedPlans(produced2); freeVars.removeAll(produced); } for (Mutable<ILogicalOperator> i : op.getInputs()) { getFreeVariablesInSelfOrDesc((AbstractLogicalOperator) i.getValue(), freeVars); } }
From source file:io.coala.json.JsonUtil.java
/** * @param om the {@link ObjectMapper} used to parse/deserialize/unmarshal * @param type the {@link Class} to register * @param imports the {@link Properties} instances for default values, etc. * @return/*w ww. java 2 s .c om*/ */ @SuppressWarnings({ "unchecked", "rawtypes" }) public static <T> Class<T> checkRegistered(final ObjectMapper om, final Class<T> type, final Properties... imports) { synchronized (JSON_REGISTRATION_CACHE) { if (type.isPrimitive()) return type; Set<Class<?>> cache = JSON_REGISTRATION_CACHE.computeIfAbsent(om, key -> new HashSet<>()); if (type.getPackage() == Object.class.getPackage() || type.getPackage() == Collection.class.getPackage() || type.isPrimitive() // assume java.lang.* and java.util.* are already mapped || TreeNode.class.isAssignableFrom(type) || cache.contains(type)) return type; // use Class.forName(String) ? // see http://stackoverflow.com/a/9130560 // LOG.trace( "Register JSON conversion of type: {}", type ); if (type.isAnnotationPresent(BeanProxy.class)) { // if( !type.isInterface() ) // return Thrower.throwNew( IllegalArgumentException.class, // "@{} must target an interface, but annotates: {}", // BeanProxy.class.getSimpleName(), type ); DynaBean.registerType(om, type, imports); checkRegisteredMembers(om, type, imports); // LOG.trace("Registered Dynabean de/serializer for: " + type); } else if (Wrapper.class.isAssignableFrom(type)) { Wrapper.Util.registerType(om, (Class<? extends Wrapper>) type); checkRegisteredMembers(om, type, imports); // LOG.trace("Registered Wrapper de/serializer for: " + type); } // else // LOG.trace("Assume default de/serializer for: " + type); cache.add(type); return type; } }
From source file:io.github.jeddict.jcode.util.POMManager.java
public static void addNBActionMappingGoal(String actionName, Project project, List<String> goals) { try {/*from w w w .ja va 2s . c o m*/ M2ConfigProvider usr = project.getLookup().lookup(M2ConfigProvider.class); NetbeansActionMapping mapp = ModelHandle2.getMapping(actionName, project, usr.getActiveConfiguration()); if (mapp == null) { mapp = ModelHandle2.getDefaultMapping(actionName, project); } Set<String> existingGoals = new HashSet<>(mapp.getGoals()); for (String goal : goals) { if (!existingGoals.contains(goal)) { mapp.addGoal(goal); } } ModelHandle2.putMapping(mapp, project, usr.getActiveConfiguration()); } catch (Exception e) { Exceptions.attachMessage(e, "Cannot persist action configuration."); Exceptions.printStackTrace(e); } }