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(Iterable<? extends E> elements) 

Source Link

Document

Creates a mutable LinkedHashSet instance containing the given elements in order.

Usage

From source file:org.jclouds.tmrk.enterprisecloud.domain.resource.memory.VirtualMachinesMemoryUsage.java

private VirtualMachinesMemoryUsage(Set<VirtualMachineMemoryUsageDetail> virtualMachinesMemoryUsageDetail) {
    this.virtualMachinesMemoryUsageDetail = Sets.newLinkedHashSet(virtualMachinesMemoryUsageDetail);
}

From source file:net.sourceforge.ganttproject.CalendarEventAction.java

public static CalendarEventAction removeException(GPCalendar calendar, Date date,
        final GPUndoManager undoManager) {
    return new CalendarEventAction(calendar, date, "calendar.action.weekendException.remove") {
        @Override/*  w w  w . j  a va  2 s .  c  om*/
        public void actionPerformed(ActionEvent e) {
            final Set<CalendarEvent> events = Sets.newLinkedHashSet(myCalendar.getPublicHolidays());
            events.remove(CalendarEvent.newEvent(myDate, false, Type.WORKING_DAY, null, null));
            undoManager.undoableEdit(getLocalizedName(), new Runnable() {
                @Override
                public void run() {
                    myCalendar.setPublicHolidays(events);
                }
            });
        }
    };
}

From source file:org.gradle.api.internal.tasks.compile.incremental.IncrementalAnnotationProcessingCompiler.java

/**
 * Scans the processor path for processor declarations. Filters them if the explicit <code>-processor</code> argument is given.
 * Treats explicit processors that didn't have a matching declaration on the path as non-incremental.
 *//* w  w w.  j a v a 2  s  .  c om*/
private Set<AnnotationProcessorDeclaration> getEffectiveAnnotationProcessors(JavaCompileSpec spec) {
    Map<String, AnnotationProcessorDeclaration> declarations = annotationProcessorDetector
            .detectProcessors(spec.getAnnotationProcessorPath());
    List<String> compilerArgs = spec.getCompileOptions().getCompilerArgs();
    int processorIndex = compilerArgs.lastIndexOf("-processor");
    if (processorIndex == -1) {
        return Sets.newLinkedHashSet(declarations.values());
    }
    Collection<String> explicitProcessors = Splitter.on(',').splitToList(compilerArgs.get(processorIndex + 1));
    Set<AnnotationProcessorDeclaration> effectiveProcessors = Sets.newLinkedHashSet();
    for (String explicitProcessor : explicitProcessors) {
        AnnotationProcessorDeclaration declaration = declarations.get(explicitProcessor);
        if (declaration != null) {
            effectiveProcessors.add(declaration);
        } else {
            effectiveProcessors.add(new AnnotationProcessorDeclaration(explicitProcessor,
                    IncrementalAnnotationProcessorType.UNKNOWN));
        }
    }
    return effectiveProcessors;
}

From source file:org.jetbrains.jet.lang.types.TypeUtils.java

public static boolean isIntersectionEmpty(@NotNull JetType typeA, @NotNull JetType typeB) {
    return intersect(JetTypeChecker.INSTANCE, Sets.newLinkedHashSet(Lists.newArrayList(typeA, typeB))) == null;
}

From source file:org.jclouds.tmrk.enterprisecloud.domain.vm.VirtualMachineReferences.java

private VirtualMachineReferences(Set<VirtualMachineReference> virtualMachineReference) {
    this.virtualMachineReferences = Sets.newLinkedHashSet(virtualMachineReference);
}

From source file:org.eclipse.emf.compare.ide.ui.internal.logical.IdenticalResourceMinimizer.java

/**
 * {@inheritDoc} Specifically, we'll remove all resources that can be seen as binary identical (we match
 * resources through exact equality of their names).
 * /*  w  w w .  ja v a2  s . com*/
 * @see org.eclipse.emf.compare.ide.ui.logical.IModelMinimizer#minimize(org.eclipse.emf.compare.ide.ui.logical.SynchronizationModel,
 *      org.eclipse.core.runtime.IProgressMonitor)
 */
public void minimize(SynchronizationModel syncModel, IProgressMonitor monitor) {
    SubMonitor progess = SubMonitor.convert(monitor, 100);
    progess.subTask(EMFCompareIDEUIMessages.getString("EMFSynchronizationModel.minimizing")); //$NON-NLS-1$

    final StorageTraversal leftTraversal = syncModel.getLeftTraversal();
    final StorageTraversal rightTraversal = syncModel.getRightTraversal();
    final StorageTraversal originTraversal = syncModel.getOriginTraversal();

    final boolean threeWay = !originTraversal.getStorages().isEmpty();
    // Copy the sets to update them as we go.
    final Set<IStorage> leftCopy = Sets.newLinkedHashSet(leftTraversal.getStorages());
    final Set<IStorage> rightCopy = Sets.newLinkedHashSet(rightTraversal.getStorages());
    final Set<IStorage> originCopy = Sets.newLinkedHashSet(originTraversal.getStorages());

    SubMonitor subMonitor = progess.newChild(98).setWorkRemaining(leftCopy.size());
    for (IStorage left : leftCopy) {
        final IStorage right = removeLikeNamedStorageFrom(left, rightCopy);
        if (right != null && threeWay) {
            final IStorage origin = removeLikeNamedStorageFrom(left, originCopy);

            if (origin != null && equals(left, right, origin)) {
                leftTraversal.removeStorage(left);
                rightTraversal.removeStorage(right);
                originTraversal.removeStorage(origin);
            }
        } else if (right != null && equals(left, right)) {
            leftTraversal.removeStorage(left);
            rightTraversal.removeStorage(right);
        } else if (right == null && isIgnoredStorage(left)) {
            /*
             * This has no match and is in plugins. We would detect an insane number of false positives on
             * it (every element "added"), so remove it from the scope.
             */
            leftTraversal.getStorages().remove(left);
        }
        subMonitor.worked(1);
    }

    subMonitor = progess.newChild(1).setWorkRemaining(rightCopy.size());
    for (IStorage right : rightCopy) {
        final IStorage origin = removeLikeNamedStorageFrom(right, originCopy);
        if (origin != null) {
            // we had a match in the origin, leave this file in scope (it's been removed from left)
        } else if (isIgnoredStorage(right)) {
            /*
             * This has no match and is in plugins. We would detect an insane number of false positives on
             * it (every element "removed"), so remove it from the scope.
             */
            rightTraversal.removeStorage(right);
        }
        subMonitor.worked(1);
    }

    subMonitor = progess.newChild(1).setWorkRemaining(rightCopy.size());
    for (IStorage origin : originCopy) {
        // These have no match on left and right.
        if (isIgnoredStorage(origin)) {
            originTraversal.removeStorage(origin);
        }
        subMonitor.worked(1);
    }
}

From source file:com.puppycrawl.tools.checkstyle.PackageObjectFactory.java

/**
 * Creates a new {@code PackageObjectFactory} instance.
 * @param packageNames the list of package names to use
 * @param moduleClassLoader class loader used to load Checkstyle
 *          core and custom modules/*from   w w w  . j  a  v a2 s  .  c  o  m*/
 */
PackageObjectFactory(Set<String> packageNames, ClassLoader moduleClassLoader) {
    if (moduleClassLoader == null) {
        throw new IllegalArgumentException("moduleClassLoader must not be null");
    }

    //create a copy of the given set, but retain ordering
    packages = Sets.newLinkedHashSet(packageNames);
    this.moduleClassLoader = moduleClassLoader;
}

From source file:org.jclouds.tmrk.enterprisecloud.domain.resource.storage.VirtualMachinesStorageDetails.java

private VirtualMachinesStorageDetails(Set<VirtualMachineStorageUsageDetail> virtualMachinesStorageUsageDetail) {
    this.virtualMachinesStorageUsageDetail = Sets.newLinkedHashSet(virtualMachinesStorageUsageDetail);
}

From source file:com.qcadoo.view.internal.ribbon.templates.model.TemplateRibbonGroupsPack.java

private void appendGroupsFromTemplate(final List<InternalRibbonGroup> templateGroups) {
    Set<InternalRibbonGroup> groupsSet = Sets.newLinkedHashSet(groups);
    groupsSet.addAll(templateGroups);/*from   ww w. j  av a2s  .  c  o m*/
    groups = Lists.newArrayList(groupsSet);
}

From source file:com.github.djabry.platform.service.security.DefaultUserDetails.java

/**
 * Returns the authorities granted to the user. Cannot return <code>null</code>.
 *
 * @return the authorities, sorted by natural key (never <code>null</code>)
 *//*w w w.jav  a  2  s .co  m*/
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
    Set<Permission> permissions = permissionMapper.mapPermissions(userAccount.getRole());

    Set<GrantedAuthority> authorities = Sets
            .newLinkedHashSet(Iterables.transform(permissions, PERMISSION_CONVERTER));
    Iterator<Group> iterator = userAccount.getGroups().iterator();
    while (iterator.hasNext()) {
        Group next = iterator.next();
        Iterables.addAll(authorities, Iterables.transform(next.getPermissions(), PERMISSION_CONVERTER));
    }

    return authorities;
}