List of usage examples for com.google.common.collect Sets newLinkedHashSet
public static <E> LinkedHashSet<E> newLinkedHashSet()
From source file:org.eclipse.emf.compare.match.eobject.IdentifierEObjectMatcher.java
/** * {@inheritDoc}/*from w ww . j a v a 2s .com*/ * * @see org.eclipse.emf.compare.match.eobject.IEObjectMatcher#createMatches(java.util.Iterator, * java.util.Iterator, java.util.Iterator) */ public Iterable<Match> createMatches(Iterator<? extends EObject> leftEObjects, Iterator<? extends EObject> rightEObjects, Iterator<? extends EObject> originEObjects) { final Set<Match> matches = Sets.newLinkedHashSet(); // This lookup map will be used by iterations on right and origin to find the match in which they // should add themselves final Map<String, Match> idToMatch = Maps.newHashMap(); // We will try and mimic the structure of the input model. // These map do not need to be ordered, we only need fast lookup. final Map<EObject, Match> leftEObjectsToMatch = Maps.newHashMap(); final Map<EObject, Match> rightEObjectsToMatch = Maps.newHashMap(); final Map<EObject, Match> originEObjectsToMatch = Maps.newHashMap(); // We'll only iterate once on each of the three sides, building the matches as we go while (leftEObjects.hasNext()) { final EObject left = leftEObjects.next(); final Match match = CompareFactory.eINSTANCE.createMatch(); match.setLeft(left); // Can we find a parent? Assume we're iterating in containment order final EObject parentEObject = left.eContainer(); final Match parent = leftEObjectsToMatch.get(parentEObject); if (parent != null) { parent.getSubmatches().add(match); } else { matches.add(match); } final String identifier = getID(left); if (identifier != null) { idToMatch.put(identifier, match); } leftEObjectsToMatch.put(left, match); } while (rightEObjects.hasNext()) { final EObject right = rightEObjects.next(); // Do we have an existing match? final String identifier = getID(right); Match match = idToMatch.get(identifier); if (match != null) { match.setRight(right); rightEObjectsToMatch.put(right, match); } else { // Otherwise, create and place it. match = CompareFactory.eINSTANCE.createMatch(); match.setRight(right); // Can we find a parent? final EObject parentEObject = right.eContainer(); final Match parent = rightEObjectsToMatch.get(parentEObject); if (parent != null) { parent.getSubmatches().add(match); } else { matches.add(match); } if (identifier != null) { idToMatch.put(identifier, match); } rightEObjectsToMatch.put(right, match); } } while (originEObjects.hasNext()) { final EObject origin = originEObjects.next(); // Do we have an existing match? final String identifier = getID(origin); Match match = idToMatch.get(identifier); if (match != null) { match.setOrigin(origin); originEObjectsToMatch.put(origin, match); } else { // Otherwise, create and place it. match = CompareFactory.eINSTANCE.createMatch(); match.setOrigin(origin); // Can we find a parent? final EObject parentEObject = origin.eContainer(); final Match parent = originEObjectsToMatch.get(parentEObject); if (parent != null) { parent.getSubmatches().add(match); } else { matches.add(match); } if (identifier != null) { idToMatch.put(identifier, match); } originEObjectsToMatch.put(origin, match); } } return matches; }
From source file:org.eclipse.sirius.common.acceleo.mtl.business.internal.interpreter.AcceleoSiriusCrossReferencerProvider.java
/** * {@inheritDoc}//ww w . ja v a 2 s. co m * * @see org.eclipse.acceleo.common.utils.IAcceleoCrossReferenceProvider#getInverseReferences(org.eclipse.emf.ecore.EObject) */ public Set<EObject> getInverseReferences(EObject eObject) { final Set<EObject> result = Sets.newLinkedHashSet(); for (EStructuralFeature.Setting setting : crossReferencer.getInverseReferences(eObject)) { result.add(setting.getEObject()); } return result; }
From source file:org.smartdeveloperhub.vocabulary.publisher.handlers.AllowedMethodsHandler.java
private AllowedMethodsHandler(final HttpHandler aHandler) { this.next = aHandler; this.methods = Sets.newLinkedHashSet(); }
From source file:org.eclipse.emf.ecoretools.design.service.RelatedElementsSwitch.java
public List<EObject> getRelatedElements(EObject ctx) { Session sess = SessionManager.INSTANCE.getSession(ctx); relateds = Sets.newLinkedHashSet(); if (sess != null) { xRefs = sess.getSemanticCrossReferencer().getInverseReferences(ctx); } else if (referencer != null) { xRefs = referencer.getInverseReferences(ctx); }//from w ww .j a v a 2s .c om doSwitch(ctx); relateds.remove(ctx); // hack to prevent some null element in relateds for a unknown reason. relateds.remove(null); return ImmutableList.copyOf(relateds); }
From source file:org.jetbrains.jet.lang.resolve.calls.inference.TypeBoundsImpl.java
@NotNull private static Set<JetType> filterBounds(@NotNull Collection<Bound> bounds, @NotNull BoundKind kind, @Nullable Collection<JetType> errorValues) { Set<JetType> result = Sets.newLinkedHashSet(); for (Bound bound : bounds) { if (bound.kind == kind) { if (!ErrorUtils.containsErrorType(bound.type)) { result.add(bound.type);//from w w w .j ava 2 s. co m } else if (errorValues != null) { errorValues.add(bound.type); } } } return result; }
From source file:org.jclouds.cloudwatch.options.GetMetricStatisticsOptions.java
/** * A dimension describing qualities of the metric. * * @param dimension the dimension describing the qualities of the metric * * @return this {@code Builder} object// www . ja va 2s . c o m */ public GetMetricStatisticsOptions dimension(Dimension dimension) { if (dimensions == null) { dimensions = Sets.newLinkedHashSet(); } this.dimensions.add(dimension); return this; }
From source file:org.eclipse.buildship.ui.workspace.ProjectSynchronizer.java
private static Set<IProject> collectGradleProjects(List<?> candidates) { Set<IProject> projects = Sets.newLinkedHashSet(); AdapterFunction<IResource> adapterFunction = AdapterFunction.forType(IResource.class); for (Object candidate : candidates) { IResource resource = adapterFunction.apply(candidate); if (resource != null) { projects.add(resource.getProject()); }/*from w w w . ja v a 2 s . com*/ } return projects; }
From source file:no.ssb.vtl.script.visitors.join.UnfoldVisitor.java
@Override public UnfoldOperation visitJoinUnfoldExpression(VTLParser.JoinUnfoldExpressionContext ctx) { Component dimension = componentVisitor.visit(ctx.dimension); Component measure = componentVisitor.visit(ctx.measure); Set<String> elements = Sets.newLinkedHashSet(); for (VTLParser.StringLiteralContext strLit : ctx.stringLiteral()) { elements.add(literalVisitor.visitStringLiteral(strLit).get()); }//w w w . j a v a 2 s. c o m return new UnfoldOperation(dataset, dimension, measure, elements); }
From source file:uk.ac.ebi.atlas.experimentimport.experimentdesign.magetab.TwoColourExperimentMageTabParser.java
@Override protected Set<NamedSdrfNode<HybridizationNode>> getAssayNodes(SDRF sdrf) { Set<NamedSdrfNode<HybridizationNode>> namedSdrfNodes = Sets.newLinkedHashSet(); Collection<? extends HybridizationNode> hybridizationNodes = sdrf.getNodes(HybridizationNode.class); if (hybridizationNodes.size() == 0) { //this is required because of a bug in limpopo... hybridizationNodes = sdrf.getNodes(uk.ac.ebi.arrayexpress2.magetab.datamodel.sdrf.node.AssayNode.class); }/* ww w.ja v a 2s . c om*/ for (HybridizationNode node : hybridizationNodes) { // create separate node for each each channel for (int channelNo = 1; channelNo <= 2; channelNo++) { namedSdrfNodes.add(new NamedSdrfNode<>( buildTwoColourExperimentAssayName(node.getNodeName(), sdrf.getLabelForChannel(channelNo)), node, channelNo)); } } return namedSdrfNodes; }
From source file:cc.recommenders.evaluation.queries.PartialUsageQueryBuilder.java
@Override public List<Query> createQueries(Usage usage) { // TODO re-implement this! (ad-hoc implementation) int numCalls = calcCountFor(usage.getReceiverCallsites().size()); int numParams = calcCountFor(usage.getParameterCallsites().size()); int iteration = 0; Set<Set<CallSite>> paths = Sets.newLinkedHashSet(); while (paths.size() < numOfQueries && iteration++ < 100) { Set<CallSite> calls = getRandom(numCalls, usage.getReceiverCallsites()); Set<CallSite> params = getRandom(numParams, usage.getParameterCallsites()); Set<CallSite> path = mergeAndShuffle(calls, params); if (!paths.contains(path)) { paths.add(path);//www . ja v a2 s . c o m } } List<Query> qs = Lists.newLinkedList(); for (Set<CallSite> path : paths) { Query query = createAsCopyFrom(usage); query.setAllCallsites(path); qs.add(query); } return qs; }