Example usage for com.google.common.collect Sets newLinkedHashSet

List of usage examples for com.google.common.collect Sets newLinkedHashSet

Introduction

In this page you can find the example usage for com.google.common.collect Sets newLinkedHashSet.

Prototype

public static <E> LinkedHashSet<E> newLinkedHashSet() 

Source Link

Document

Creates a mutable, empty LinkedHashSet instance.

Usage

From source file:org.eclipse.sirius.diagram.ui.business.internal.migration.FontStyleForDNodeListElementMigrationParticipant.java

@SuppressWarnings("unchecked")
@Override/*from  w  w  w.  j ava  2 s  .  c o  m*/
protected void postLoad(DAnalysis dAnalysis, Version loadedVersion) {
    if (loadedVersion.compareTo(MIGRATION_VERSION) < 0) {
        EClass fontStyleClass = NotationPackage.eINSTANCE.getFontStyle();

        // Step 1: get all view to update
        final Collection<View> allViewsToUpdate = Sets.newLinkedHashSet();
        for (DView dView : dAnalysis.getOwnedViews()) {
            for (DDiagram dDiagram : Iterables.filter(dView.getOwnedRepresentations(), DDiagram.class)) {
                DiagramCreationUtil diagramCreationUtil = new DiagramCreationUtil(dDiagram);
                if (diagramCreationUtil.findAssociatedGMFDiagram()) {
                    Diagram gmfDiagram = diagramCreationUtil.getAssociatedGMFDiagram();
                    TreeIterator<EObject> childIterator = gmfDiagram.eAllContents();
                    while (childIterator.hasNext()) {
                        EObject child = childIterator.next();
                        if (child instanceof View && ((View) child).getElement() instanceof DNodeListElement) {
                            View view = (View) child;
                            Style style = view.getStyle(fontStyleClass);
                            if (style == null) {
                                allViewsToUpdate.add(view);
                            }

                            // Do not loop inner this view
                            childIterator.prune();
                        }
                    }
                }
            }
        }

        // Step 2: update views
        for (View viewToUpdate : allViewsToUpdate) {
            FontStyle style = (FontStyle) fontStyleClass.getEPackage().getEFactoryInstance()
                    .create(fontStyleClass);
            viewToUpdate.getStyles().add(style);
        }
    }
}

From source file:org.jclouds.vcloud.xml.ovf.VirtualSystemHandler.java

public VirtualSystem getResult() {
    VirtualSystem vs = new VirtualSystem(id, info, name, operatingSystem, hardware);
    id = null;//www  .  java2s  .co  m
    info = null;
    name = null;
    operatingSystem = null;
    hardware = Sets.newLinkedHashSet();
    return vs;
}

From source file:org.eclipse.sirius.common.acceleo.mtl.business.internal.interpreter.AcceleoSiriusCrossReferencerProvider.java

/**
 * {@inheritDoc}/*from ww  w.  j  ava2 s .  c  o  m*/
 * 
 * @see org.eclipse.acceleo.common.utils.IAcceleoCrossReferenceProvider#getInverseReferences(org.eclipse.emf.ecore.EObject,
 *      org.eclipse.emf.ecore.EClassifier)
 */
public Set<EObject> getInverseReferences(EObject eObject, EClassifier filter) {
    final Set<EObject> result = Sets.newLinkedHashSet();
    for (EStructuralFeature.Setting setting : crossReferencer.getInverseReferences(eObject)) {
        final EObject eObj = setting.getEObject();
        if (filter == null || filter.isInstance(eObj)) {
            result.add(eObj);
        }
    }
    return result;
}

From source file:org.eclipse.xtext.xbase.scoping.batch.StaticFeatureScope.java

@Override
protected List<IEObjectDescription> getLocalElementsByName(QualifiedName name) {
    final Set<JvmFeature> allFeatures = Sets.newLinkedHashSet();
    processFeatureNames(name, new NameAcceptor() {
        @Override//from   w w w.  j a v a 2  s  .com
        public void accept(String simpleName, int order) {
            for (JvmType type : bucket.getTypes()) {
                if (type instanceof JvmDeclaredType) {
                    List<JvmFeature> features = findAllFeaturesByName(type, simpleName,
                            bucket.getResolvedFeaturesProvider());
                    if (order == 1) {
                        allFeatures.addAll(features);
                    } else {
                        for (int i = 0, size = features.size(); i < size; i++) {
                            JvmFeature feature = features.get(i);
                            if (feature.eClass() == TypesPackage.Literals.JVM_OPERATION) {
                                allFeatures.add(feature);
                            }
                        }
                    }
                }
            }
        }
    });
    if (allFeatures.isEmpty())
        return Collections.emptyList();
    List<IEObjectDescription> allDescriptions = Lists.newArrayListWithCapacity(allFeatures.size());
    for (JvmFeature feature : allFeatures) {
        addDescription(name, feature, allDescriptions);
    }
    return allDescriptions;
}

From source file:org.gradle.api.reporting.dependents.internal.DependentComponentsRenderableDependency.java

public static DependentComponentsRenderableDependency of(DependentBinariesResolvedResult resolvedResult) {
    LibraryBinaryIdentifier id = resolvedResult.getId();
    String name = DependentComponentsUtils.getBuildScopedTerseName(id);
    String description = id.getDisplayName();
    boolean buildable = resolvedResult.isBuildable();
    boolean testSuite = resolvedResult.isTestSuite();
    LinkedHashSet<DependentComponentsRenderableDependency> children = Sets.newLinkedHashSet();
    for (DependentBinariesResolvedResult childResolutionResult : resolvedResult.getChildren()) {
        children.add(of(childResolutionResult));
    }//from   w  w  w  .j a  v  a2s  . c  o m
    return new DependentComponentsRenderableDependency(id, name, description, buildable, testSuite, children);
}

From source file:org.jclouds.json.internal.IgnoreNullSetTypeAdapterFactory.java

private <E> TypeAdapter<Set<E>> newSetAdapter(final TypeAdapter<E> elementAdapter) {
    return new TypeAdapter<Set<E>>() {
        public void write(JsonWriter out, Set<E> value) throws IOException {
            out.beginArray();//from www  .  ja  v  a 2s .  co m
            for (E element : value) {
                elementAdapter.write(out, element);
            }
            out.endArray();
        }

        public Set<E> read(JsonReader in) throws IOException {
            Set<E> result = Sets.newLinkedHashSet();
            in.beginArray();
            while (in.hasNext()) {
                E element = elementAdapter.read(in);
                if (element != null)
                    result.add(element);
            }
            in.endArray();
            return result;
        }
    }.nullSafe();
}

From source file:com.google.javascript.jscomp.GroupVariableDeclarations.java

public void enterScope(NodeTraversal t) {
    Set<Node> varNodes = Sets.newLinkedHashSet();
    Iterator<Var> scopeVarIter = t.getScope().getVars();
    while (scopeVarIter.hasNext()) {
        Node parentNode = scopeVarIter.next().getParentNode();
        if (parentNode.getType() == Token.VAR) {
            varNodes.add(parentNode);//from   w  ww  .j a v a 2 s  .co m
        }
    }
    if (varNodes.size() <= 1) {
        return;
    }
    Iterator<Node> varNodeIter = varNodes.iterator();
    Node firstVarNode = varNodeIter.next();
    while (varNodeIter.hasNext()) {
        Node varNode = varNodeIter.next();
        applyGroupingToVar(firstVarNode, varNode);
    }
}

From source file:org.eclipse.sirius.diagram.sequence.ui.tool.internal.edit.validator.InteractionUseMoveValidator.java

/**
 * {@inheritDoc}/*from w  w w. java 2s  . c  o  m*/
 */
@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;
    // return frame.computeParentEvents();
}

From source file:org.splevo.ui.vpexplorer.handler.characteristics.AbstractChangeCharacteristicHandler.java

/**
 * Change a characteristic of the selected variation points and save the resources of each
 * modified variation point. //w  w w.j a va2s .  c o m
 * @param selection the current selected items in the vpexplorer/feature outline
 * @return null
 * @throws ExecutionException if it fails to save the modified resource
 */
public Object execute(ISelection selection) throws ExecutionException {
    Set<Resource> resourceToSave = Sets.newLinkedHashSet();

    if (selection != null && selection instanceof IStructuredSelection) {
        IStructuredSelection strucSelection = (IStructuredSelection) selection;
        for (Object element : strucSelection.toList()) {
            if (element instanceof VariationPoint) {
                VariationPoint vp = (VariationPoint) element;
                if (changeVariationPointCharacteristic(vp)) {
                    resourceToSave.add((vp).eResource());
                }
            } else if (element instanceof VariationPointGroup) {
                VariationPointGroup group = (VariationPointGroup) element;
                for (VariationPoint vp : group.getVariationPoints()) {
                    if (changeVariationPointCharacteristic(vp)) {
                        resourceToSave.add(vp.eResource());

                    }
                }
            }
        }
    }
    for (Resource resource : resourceToSave) {
        try {
            resource.save(null);
        } catch (IOException e) {
            throw new ExecutionException("Failed to save modified resource", e);
        }
    }
    refreshPropertySheet(selection);
    return null;
}

From source file:org.eclipse.sirius.common.acceleo.aql.business.api.TypesUtil.java

private static Collection<EClassifierType> searchEClassifierType(IQueryEnvironment queryEnvironment,
        TypeName targetTypeName) {/*  w  ww. j  a  va 2s  .  co m*/
    Collection<EClassifier> found = Sets.newLinkedHashSet();
    if (targetTypeName.getPackagePrefix().some()) {
        String typeName = targetTypeName.getClassifierName();
        String name = targetTypeName.getPackagePrefix().get();
        found.addAll(queryEnvironment.getEPackageProvider().getTypes(name, typeName));
    } else {
        found.addAll(queryEnvironment.getEPackageProvider().getTypes(targetTypeName.getClassifierName()));
    }

    Collection<EClassifierType> types = Sets.newLinkedHashSet();

    for (EClassifier eClassifier : found) {
        types.add(new EClassifierType(queryEnvironment, eClassifier));
    }
    return types;
}