List of usage examples for com.google.common.collect Sets newLinkedHashSet
public static <E> LinkedHashSet<E> newLinkedHashSet()
From source file:com.opengamma.integration.tool.marketdata.HtsSyncTool.java
private Set<String> filterClassifiers(Set<String> srcMasterClassifiers, Set<String> destMasterClassifiers) { Set<String> commonComponentNames = Sets.newLinkedHashSet(); commonComponentNames.addAll(srcMasterClassifiers); commonComponentNames.retainAll(destMasterClassifiers); if (getCommandLine().hasOption("classifiers")) { List<String> classifiersList = Arrays.asList(getCommandLine().getOptionValues("classifiers")); Set<String> classifiers = Sets.newHashSet(); classifiers.addAll(classifiersList); classifiers.removeAll(classifiers); if (classifiers.size() > 0) { System.err.println("Couldn't find classifiers: " + classifiers.toString() + ", skipping those"); }/* ww w. j a v a 2 s . c om*/ classifiers.clear(); classifiers.addAll(classifiersList); commonComponentNames.retainAll(classifiers); } return commonComponentNames; }
From source file:com.textocat.textokit.tokenizer.AnnotationToTokenFitter.java
@Override public void process(JCas jCas) throws AnalysisEngineProcessException { Set<ST> anno2Remove = Sets.newLinkedHashSet(); Map<ST, Offsets> anno2Fix = Maps.newLinkedHashMap(); OverlapIndex<Token> tokenOverlapIndex = createOverlapIndex(JCasUtil.select(jCas, Token.class).iterator()); ///*www .j a v a2 s. c o m*/ for (ST span : JCasUtil.select(jCas, targetTypeClass)) { Offsets spanOffsets = new Offsets(span); LinkedList<Token> overlappingTokens = Lists .newLinkedList(tokenOverlapIndex.getOverlapping(spanOffsets.getBegin(), spanOffsets.getEnd())); if (overlappingTokens.isEmpty()) { getLogger().warn(format("No overlapping tokens for typed span: %s", toPrettyString(span))); anno2Remove.add(span); continue; } // OT stands for 'overlapping token' Token firstOT = overlappingTokens.getFirst(); Token lastOT = overlappingTokens.getLast(); // check the first overlapping token if (firstOT.getBegin() != spanOffsets.getBegin()) { spanOffsets = new Offsets(firstOT.getBegin(), spanOffsets.getEnd()); } // check the last overlapping token if (lastOT.getEnd() != spanOffsets.getEnd()) { spanOffsets = new Offsets(spanOffsets.getBegin(), lastOT.getEnd()); } // if (!spanOffsets.isIdenticalWith(span)) { // fix anno2Fix.put(span, spanOffsets); } } // remove empty spans for (ST span : anno2Remove) { span.removeFromIndexes(); } // fix span offsets for (Map.Entry<ST, Offsets> e : anno2Fix.entrySet()) { ST span = e.getKey(); String oldText = span.getCoveredText(); Offsets fixedOffsets = e.getValue(); span.removeFromIndexes(); span.setBegin(fixedOffsets.getBegin()); span.setEnd(fixedOffsets.getEnd()); span.addToIndexes(); String newText = span.getCoveredText(); getLogger().debug(format("Annotation offsets are fixed: '%s' => '%s'", oldText, newText)); } }
From source file:de.uni_stuttgart.iste.cowolf.model.sequence_diagram.sirius.editor.design.services.internal.RelatedCompositeStructureElementsSwitch.java
public List<EObject> getRelatedElements(EObject ctx) { Session sess = SessionManager.INSTANCE.getSession(ctx); relateds = Sets.newLinkedHashSet(); if (sess != null) { sess.getSemanticCrossReferencer().getInverseReferences(ctx); } else if (referencer != null) { 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.eclipse.sirius.diagram.sequence.ui.tool.internal.edit.validator.CombinedFragmentMoveValidator.java
/** * Overridden to get final parents.//from w w w. ja v a2 s.c o m * * {@inheritDoc} */ @Override protected Collection<ISequenceEvent> getFinalParents() { // Possibility to handle "reparent" and insertion" Collection<ISequenceEvent> finalParents = Sets.newLinkedHashSet(); Range insertionPoint = new Range(finalRange.getLowerBound(), finalRange.getLowerBound()); Collection<Lifeline> coveredLifelines = frame.computeCoveredLifelines(); for (Lifeline lifeline : coveredLifelines) { EventFinder finder = new EventFinder(lifeline); finder.setEventsToIgnore(Predicates.in(Collections.<ISequenceEvent>singletonList(frame))); ISequenceEvent localParent = finder.findMostSpecificEvent(insertionPoint); if (localParent != null) { finalParents.add(localParent); } } return finalParents; }
From source file:org.terasology.module.ClasspathModule.java
/** * Creates a classpath module from a set of code sources. * <p>/*from w ww . j a v a2s. c o m*/ * There is an option to include directories on the classpath. This should only be done for one classpath module - this is for use when running from source * in environments that keep resources and classes in separate locations (e.g. gradle by default). Any directory on the classpath (as opposed to jars) will be * included in this module * </p> * * @param metadata Metadata describing the module to create * @param includeDirectories Whether to include directories on the classpath. * @param primarySource The first source to include in this module * @param additionalSources Any additional sources to include * @return A new ClasspathModule * @throws URISyntaxException If a source location cannot be converted to a proper URI (typically because the path to the source includes an invalid character). */ public static ClasspathModule create(ModuleMetadata metadata, boolean includeDirectories, CodeSource primarySource, CodeSource... additionalSources) throws URISyntaxException { Set<Path> paths = Sets.newLinkedHashSet(); for (CodeSource source : Varargs.combineToSet(primarySource, additionalSources)) { paths.add(Paths.get(source.getLocation().toURI())); } if (includeDirectories) { addClasspathDirectories(paths); } return new ClasspathModule(metadata, paths); }
From source file:org.napile.compiler.lang.descriptors.TypeParameterDescriptorImpl.java
public TypeParameterDescriptorImpl(@NotNull DeclarationDescriptor containingDeclaration, @NotNull List<AnnotationDescriptor> annotations, @NotNull Name name, int index) { super(containingDeclaration, annotations, name); this.index = index; this.upperBounds = Sets.newLinkedHashSet(); // TODO: Should we actually pass the annotations on to the type constructor? this.typeConstructor = new TypeConstructorImpl(this, annotations, false, name.getName(), Collections.<TypeParameterDescriptor>emptyList(), upperBounds); }
From source file:org.jetbrains.kotlin.resolve.lazy.LazyResolveTestUtil.java
@NotNull public static Set<Name> getTopLevelPackagesFromFileList(@NotNull List<KtFile> files) { Set<Name> shortNames = Sets.newLinkedHashSet(); for (KtFile file : files) { List<Name> packageFqNameSegments = file.getPackageFqName().pathSegments(); Name name = packageFqNameSegments.isEmpty() ? SpecialNames.ROOT_PACKAGE : packageFqNameSegments.get(0); shortNames.add(name);/* w ww . java 2 s . c om*/ } return shortNames; }
From source file:de.xaniox.simpletrading.TradeFactory.java
public TradeFactory(SimpleTrading plugin, TradeConfiguration config, Economy econ, ItemControlManager controlManager) { this.plugin = plugin; this.config = config; this.trades = Sets.newLinkedHashSet(); this.econ = econ; this.controlManager = controlManager; plugin.getServer().getPluginManager().registerEvents(this, plugin); }
From source file:org.eclipse.sirius.business.internal.session.danalysis.TrackingModificationTrigger.java
@Override public Option<Command> localChangesAboutToCommit(Collection<Notification> notifications) { /*/* www . jav a 2 s .c om*/ * eContainer() calls can become costly and as such eResource() ones. * Let's make sure first we won't process several time the same EObject * as often there are several changes per EObject. */ final Set<Resource> impactedResources = Sets.newLinkedHashSet(); Set<EObject> impactedObjects = Sets.newLinkedHashSet(); for (Notification change : notifications) { if (change.getNotifier() instanceof EObject && !(change.getNotifier() instanceof Resource)) { EObject changed = (EObject) change.getNotifier(); if (impactedObjects.add(changed)) { Resource res = changed.eResource(); if (res != null && !res.isModified()) { impactedResources.add(res); } } } } if (!impactedResources.isEmpty()) { Command setIsModified = new RecordingCommand(domain) { @Override protected void doExecute() { for (Resource resource : impactedResources) { resource.setModified(true); } } }; return Options.newSome(setIsModified); } return Options.newNone(); }
From source file:org.obeonetwork.dsl.dart.design.internal.services.RelatedElementsSwitch.java
/** * Returns the list of elements related to the given EObject. * * @param eObject/*from ww w . j a v a 2 s . c o m*/ * The EObject * @return The list of elements related to the given EObject */ public Collection<EObject> getRelatedElements(EObject eObject) { Session session = SessionManager.INSTANCE.getSession(eObject); this.relatedElements = Sets.newLinkedHashSet(); if (session != null) { this.crossReferences = session.getSemanticCrossReferencer().getInverseReferences(eObject); } this.doSwitch(eObject); // In case there is a reference from the EObject to itself relatedElements.remove(eObject); relatedElements.remove(null); return ImmutableList.copyOf(this.relatedElements); }