List of usage examples for com.google.common.collect Sets newLinkedHashSet
public static <E> LinkedHashSet<E> newLinkedHashSet()
From source file:org.eclipse.sirius.ui.tools.internal.operations.SemanticResourceAdditionOperation.java
@Override public void run(IProgressMonitor monitor) throws java.lang.reflect.InvocationTargetException, InterruptedException { try {//from w w w .j a va 2 s. c o m monitor.beginTask(Messages.SemanticResourceAdditionOperation_semanticResourceAdditionTask, uris.size() * sessions.size()); results = Sets.newLinkedHashSet(); for (Session session : sessions) { TransactionalEditingDomain transDomain = session.getTransactionalEditingDomain(); CompoundCommand command = new CompoundCommand(); for (URI semanticModelURI : uris) { RecordingCommand cmd = new AddSemanticResourceCommand(session, semanticModelURI, new SubProgressMonitor(monitor, 1)); command.append(cmd); } transDomain.getCommandStack().execute(command); results.addAll(command.getResult()); } } finally { monitor.done(); } }
From source file:cc.kave.episodes.model.EnclosingMethods.java
public Set<IMethodName> getMethodNames(int numberOfMethods) { Set<IMethodName> someMethods = Sets.newLinkedHashSet(); for (Map.Entry<IMethodName, Integer> entry : methods.entrySet()) { someMethods.add(entry.getKey()); if (someMethods.size() == numberOfMethods) { break; }//from w ww.ja v a2s. c om } return someMethods; }
From source file:com.baidu.rigel.biplatform.ma.model.meta.DimTableMetaDefine.java
/** * ?//w w w. j a va 2 s. c o m * * @return */ public ColumnMetaDefine[] getColumns() { if (columns == null) { columns = Sets.newLinkedHashSet(); } return columns.toArray(new ColumnMetaDefine[0]); }
From source file:org.terasology.world.propagation.SunlightRegenBatchPropagator.java
public SunlightRegenBatchPropagator(PropagationRules regenRules, PropagatorWorldView regenWorld, BatchPropagator sunlightPropagator, PropagatorWorldView sunlightWorld) { this.regenRules = regenRules; this.regenWorld = regenWorld; this.sunlightPropagator = sunlightPropagator; this.sunlightWorld = sunlightWorld; increaseQueues = new Set[regenRules.getMaxValue() + 1]; reduceQueues = new Set[regenRules.getMaxValue() + 1]; for (int i = 0; i < regenRules.getMaxValue() + 1; ++i) { increaseQueues[i] = Sets.newLinkedHashSet(); reduceQueues[i] = Sets.newLinkedHashSet(); }// ww w . j a va 2s.c om }
From source file:org.eclipse.xtext.xtext.generator.parser.antlr.splitting.SyntacticPredicateFixup.java
private String toParameterList(String argumentList) { Matcher matcher = SINGLE_ARG.matcher(argumentList); Set<String> names = Sets.newLinkedHashSet(); while (matcher.find()) { names.add(matcher.group(1));/* w w w . j ava2 s. c o m*/ } StringBuilder result = new StringBuilder("boolean "); Joiner.on(", boolean ").appendTo(result, names); return result.toString(); }
From source file:org.eclipse.sirius.tree.ui.tools.internal.editor.provider.DTreeItemDragListener.java
/** * {@inheritDoc}/*from w w w . jav a 2 s . c o m*/ * * @see org.eclipse.swt.dnd.DragSourceAdapter#dragSetData(org.eclipse.swt.dnd.DragSourceEvent) */ @SuppressWarnings("unchecked") @Override public void dragSetData(DragSourceEvent event) { // We set the data of the drag to all selected DTreeItem (if any) ISelection selection = this.selectionProvider.getSelection(); if (selection instanceof IStructuredSelection) { Set<DTreeItem> dragData = Sets.newLinkedHashSet(); Iterator<Object> selectionIterator = ((IStructuredSelection) selection).iterator(); while (selectionIterator.hasNext()) { Object selectedElement = selectionIterator.next(); if (selectedElement instanceof DTreeItem) { dragData.add((DTreeItem) selectedElement); } } LocalSelectionTransfer.getTransfer().setSelection(this.selectionProvider.getSelection()); event.data = dragData; } }
From source file:org.eclipse.xtext.graphview.lib.extensions.JvmModelExtensions.java
public static Iterable<JvmTypeReference> allRawTypes(JvmTypeReference typeReference) { final TypeReferences typeReferences = getLanguageService(typeReference, TypeReferences.class); final Set<JvmTypeReference> result = Sets.newLinkedHashSet(); typeReference.accept(new AbstractTypeReferenceVisitor.InheritanceAware<Boolean>() { @Override/*w w w . j av a 2 s.co m*/ public Boolean doVisitGenericArrayTypeReference(JvmGenericArrayTypeReference reference) { return result.add(reference.getComponentType()); } @Override public Boolean doVisitCompoundTypeReference(JvmCompoundTypeReference reference) { for (JvmTypeReference containedReference : reference.getReferences()) visit(containedReference); return true; } @Override public Boolean doVisitParameterizedTypeReference(JvmParameterizedTypeReference reference) { result.add(typeReferences.createTypeRef(reference.getType())); for (JvmTypeReference argument : reference.getArguments()) visit(argument); return true; } }); return result; }
From source file:org.apache.brooklyn.rest.transform.CatalogTransformer.java
public static <T extends Entity> CatalogEntitySummary catalogEntitySummary(BrooklynRestResourceUtils b, CatalogItem<T, EntitySpec<? extends T>> item) { Set<EntityConfigSummary> config = Sets.newLinkedHashSet(); Set<SensorSummary> sensors = Sets.newTreeSet(SummaryComparators.nameComparator()); Set<EffectorSummary> effectors = Sets.newTreeSet(SummaryComparators.nameComparator()); EntitySpec<?> spec = null;//from ww w. j a va 2 s.c o m try { @SuppressWarnings({ "unchecked", "rawtypes" }) // the raw type isn't needed according to eclipse IDE, but jenkins maven fails without it; // must be a java version or compiler thing. don't remove even though it looks okay without it! EntitySpec<?> specRaw = (EntitySpec<?>) b.getCatalog().createSpec((CatalogItem) item); spec = specRaw; EntityDynamicType typeMap = BrooklynTypes.getDefinedEntityType(spec.getType()); EntityType type = typeMap.getSnapshot(); AtomicInteger paramPriorityCnt = new AtomicInteger(); for (SpecParameter<?> input : spec.getParameters()) { config.add(EntityTransformer.entityConfigSummary(input, paramPriorityCnt)); if (input.getSensor() != null) sensors.add(SensorTransformer.sensorSummaryForCatalog(input.getSensor())); } for (Sensor<?> x : type.getSensors()) sensors.add(SensorTransformer.sensorSummaryForCatalog(x)); for (Effector<?> x : type.getEffectors()) effectors.add(EffectorTransformer.effectorSummaryForCatalog(x)); } catch (Exception e) { Exceptions.propagateIfFatal(e); // templates with multiple entities can't have spec created in the manner above; just ignore if (item.getCatalogItemType() == CatalogItemType.ENTITY) { log.warn("Unable to create spec for " + item + ": " + e, e); } if (log.isTraceEnabled()) { log.trace("Unable to create spec for " + item + ": " + e, e); } } return new CatalogEntitySummary(item.getSymbolicName(), item.getVersion(), item.getDisplayName(), item.getJavaType(), item.getPlanYaml(), item.getDescription(), tidyIconLink(b, item, item.getIconUrl()), makeTags(spec, item), config, sensors, effectors, item.isDeprecated(), makeLinks(item)); }
From source file:org.eclipse.sirius.tools.internal.validation.description.constraints.ValidInterpretedExpressionConstraint.java
/** * /* ww w . j a v a2 s.c o m*/ * {@inheritDoc} * * @see org.eclipse.emf.validation.AbstractModelConstraint#validate(org.eclipse.emf.validation.IValidationContext) */ @Override public IStatus validate(IValidationContext ctx) { final EObject target = ctx.getTarget(); Collection<IStatus> statuses = Sets.newLinkedHashSet(); // For each structural features of the element to validate for (EAttribute feature : target.eClass().getEAllAttributes()) { // If this feature is an Interpreted expression if (DescriptionPackage.eINSTANCE.getInterpretedExpression().equals(feature.getEAttributeType())) { IStatus status = checkExpression(ctx, target, feature); if (status != null) { statuses.add(status); } } } if (statuses.isEmpty()) { return ctx.createSuccessStatus(); } final IStatus returnStatus; if (statuses.size() == 1) { returnStatus = statuses.iterator().next(); } else { returnStatus = ConstraintStatus.createMultiStatus(ctx, statuses); } return returnStatus; }
From source file:org.sbs.goodcrawler.extractor.selector.SetElementCssSelector.java
@Override public Set<String> getContent() throws ExtractException { try {/*from www.java2 s .c o m*/ if (null != content && !newDoc) { return content; } content = Sets.newLinkedHashSet(); if (document != null) { Elements elements = super.document.select(value); if (elements.isEmpty()) return null; switch ($Attr) { case text: for (Element e : elements) { content.add(e.text()); } break; default: for (Element e : elements) { content.add(e.attr(attr)); } break; } if (null != actions && actions.size() > 0) { Set<String> newSet = Sets.newLinkedHashSet(); for (String string : content) { String temp = string; for (StringSelectorAction action : actions) { temp = action.doAction(temp); } newSet.add(temp); } this.content = newSet; } newDoc = false; return content; } } catch (Exception e) { e.printStackTrace(); throw new ExtractException( SetElementCssSelector.class.getSimpleName() + "????:" + e.getMessage()); } return null; }