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:net.minecraftforge.gradle.patcher.TaskMergeFiles.java

private void mergeFiles(FileCollection in, String ending, File out) throws IOException {
    Set<String> lines = Sets.newLinkedHashSet();
    for (File f : in.getFiles()) {
        if (f.isDirectory() || !f.exists() || !f.getName().endsWith(ending))
            continue;
        lines.addAll(Files.readLines(f, Constants.CHARSET));
    }//  w  w w. j av  a2s  . c o m

    out.getParentFile().mkdirs();
    Files.write(Joiner.on('\n').join(lines), out, Constants.CHARSET);
}

From source file:org.summer.ss.ide.builder.JavaProjectPreferencesInitializer.java

@Inject
public void addOwnFileExtensionsToJavaBuildResourceCopyFilter(FileExtensionProvider extensionProvider) {
    @SuppressWarnings("deprecation")
    IScopeContext defaultScope = new DefaultScope();

    // The class org.eclipse.jdt.internal.launching.LaunchingPreferenceInitializer has this very nasty habit 
    // of replacing all RESOURCE_COPY_FILTERs with its own filter. Calling getNode(LaunchingPlugin.ID_PLUGIN) 
    // causes LaunchingPreferenceInitializer to be executed that afterwards we can append our filters safely.    
    // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=395366
    defaultScope.getNode(LaunchingPlugin.ID_PLUGIN);

    IEclipsePreferences dnode = defaultScope.getNode(JavaCore.PLUGIN_ID);
    if (dnode == null)
        return;//www .j av  a  2s. c o m
    Set<String> filters = Sets.newLinkedHashSet();
    for (String filter : dnode.get(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, "").split(",")) {
        String trimmed = filter.trim();
        if (!"".equals(trimmed))
            filters.add(trimmed);
    }
    for (String ext : extensionProvider.getFileExtensions())
        filters.add("*." + ext);
    dnode.put(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, Joiner.on(", ").join(filters));
    try {
        dnode.flush();
    } catch (BackingStoreException e) {
        log.error(e);
    }
}

From source file:de.tu_berlin.dima.oligos.profiler.TableProfiler.java

private Set<Column<?>> getColumnStatistics() {
    Set<Column<?>> columns = Sets.newLinkedHashSet();
    for (ColumnProfiler<?> profiler : this.columnProfilers) {
        Column<?> column = profiler.profile();
        columns.add(column);//  w w w . j a v  a  2 s .  com
    }
    return columns;
}

From source file:org.obiba.magma.datasource.spss.support.SpssVariableValueSourceFactory.java

@Override
public Set<VariableValueSource> createSources() {
    Set<VariableValueSource> sources = Sets.newLinkedHashSet();

    for (int i = 1; i < spssFile.getVariableCount(); i++) {
        SPSSVariable spssVariable = spssFile.getVariable(i);
        try {//from ww  w  . jav  a 2s .c  om
            sources.add(new SpssVariableValueSource(createVariableBuilder(i, spssVariable), spssVariable,
                    identifierToVariableIndex));
        } catch (SpssInvalidCharacterException e) {
            String variableName = spssVariable.getName();
            // In the dictionary the first row is reserved for entity variable
            int variableIndex = i + 1;
            throw new SpssDatasourceParsingException("Failed to create variable value source.",
                    "InvalidCharsetCharacter", variableIndex, e.getSource())
                            .metadataInfo(variableName, variableIndex).extraInfo(e);
        }
    }

    return sources;
}

From source file:org.gradle.language.cpp.internal.NativeVariantIdentity.java

public NativeVariantIdentity(String name, Provider<String> baseName, Provider<String> group,
        Provider<String> version, boolean debuggable, boolean optimized,
        OperatingSystemFamily operatingSystemFamily, UsageContext linkUsage, UsageContext runtimeUsage) {
    this.name = name;
    this.baseName = baseName;
    this.group = group;
    this.version = version;
    this.debuggable = debuggable;
    this.optimized = optimized;
    this.operatingSystemFamily = operatingSystemFamily;
    this.linkUsage = linkUsage;
    this.runtimeUsage = runtimeUsage;
    this.usageContexts = Sets.newLinkedHashSet();
    if (linkUsage != null) {
        usageContexts.add(linkUsage);//ww  w  .  j a v  a2s  . c o  m
    }
    if (runtimeUsage != null) {
        usageContexts.add(runtimeUsage);
    }
}

From source file:io.druid.query.aggregation.datasketches.theta.SketchSetPostAggregator.java

@Override
public Set<String> getDependentFields() {
    Set<String> dependentFields = Sets.newLinkedHashSet();
    for (PostAggregator field : fields) {
        dependentFields.addAll(field.getDependentFields());
    }//from w  w  w. j  ava  2 s . c  om
    return dependentFields;
}

From source file:org.eclipse.xtend.ide.builder.JavaProjectPreferencesInitializer.java

@SuppressWarnings("restriction")
@Inject//ww w . j a  v a2 s .c  o m
public void addOwnFileExtensionsToJavaBuildResourceCopyFilter(FileExtensionProvider extensionProvider) {
    @SuppressWarnings("deprecation")
    IScopeContext defaultScope = new DefaultScope();

    // The class org.eclipse.jdt.internal.launching.LaunchingPreferenceInitializer has this very nasty habit 
    // of replacing all RESOURCE_COPY_FILTERs with its own filter. Calling getNode(LaunchingPlugin.ID_PLUGIN) 
    // causes LaunchingPreferenceInitializer to be executed that afterwards we can append our filters safely.    
    // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=395366
    defaultScope.getNode(org.eclipse.jdt.internal.launching.LaunchingPlugin.ID_PLUGIN);

    IEclipsePreferences dnode = defaultScope.getNode(JavaCore.PLUGIN_ID);
    if (dnode == null)
        return;
    Set<String> filters = Sets.newLinkedHashSet();
    for (String filter : dnode.get(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, "").split(",")) {
        String trimmed = filter.trim();
        if (!"".equals(trimmed))
            filters.add(trimmed);
    }
    for (String ext : extensionProvider.getFileExtensions())
        filters.add("*." + ext);
    dnode.put(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, Joiner.on(", ").join(filters));
    try {
        dnode.flush();
    } catch (BackingStoreException e) {
        log.error("Error saving preferences", e);
    }
}

From source file:com.textocat.textokit.commons.cas.TreeMapOverlapIndex.java

private TreeMapOverlapIndex(Iterator<A> srcIter) {
    beginIdx = Maps.newTreeMap();//from www  . j ava  2 s . c om
    endIdx = Maps.newTreeMap();
    annoIds = Maps.newHashMap();
    while (srcIter.hasNext()) {
        A sa = srcIter.next();
        // empty annotations overlap with nothing
        if (AnnotationUtils.isEmpty(sa)) {
            continue;
        }
        // by begin
        {
            int saBegin = sa.getBegin();
            Set<A> sameBeginSet = beginIdx.get(saBegin);
            if (sameBeginSet == null) {
                // preserve source iterator ordering
                sameBeginSet = Sets.newLinkedHashSet();
                beginIdx.put(saBegin, sameBeginSet);
            }
            sameBeginSet.add(sa);
        }
        // by end
        {
            int saEnd = sa.getEnd();
            Set<A> sameEndSet = endIdx.get(saEnd);
            if (sameEndSet == null) {
                // preserve source iterator ordering
                sameEndSet = Sets.newLinkedHashSet();
                endIdx.put(saEnd, sameEndSet);
            }
            sameEndSet.add(sa);
        }
        // this is required for internal comparator to preserve source iterator ordering
        // if offsets are equal
        if (!annoIds.containsKey(sa)) {
            annoIds.put(sa, ++annoIdCounter);
        }
    }
}

From source file:org.summer.dsl.xbase.scoping.batch.StaticFeatureScope.java

@Override
protected Collection<IEObjectDescription> getLocalElementsByName(QualifiedName name) {
    final Set<JvmFeature> allFeatures = Sets.newLinkedHashSet();
    processFeatureNames(name, new NameAcceptor() {
        public void accept(String simpleName, int order) {
            for (JvmType type : bucket.getTypes()) {
                if (type instanceof JvmDeclaredType) {
                    Iterable<JvmFeature> features = findAllFeaturesByName(type, simpleName,
                            bucket.getResolvedFeaturesProvider());
                    Iterable<? extends JvmFeature> filtered = order == 1 ? features
                            : filter(features, JvmOperation.class);
                    Iterables.addAll(allFeatures, filtered);
                }//from  ww  w.ja  v a 2  s  .  c  o  m
            }
        }
    });
    if (allFeatures.isEmpty())
        return Collections.emptyList();
    List<IEObjectDescription> allDescriptions = Lists.newArrayListWithCapacity(allFeatures.size());
    for (JvmFeature feature : allFeatures) {
        if (feature.isStatic())
            allDescriptions.add(createDescription(name, feature, bucket));
        else if (receiver == null && receiverType == null) {
            allDescriptions.add(createInstanceDescription(name, feature, bucket));
        }
    }
    return allDescriptions;
}

From source file:org.webtestingexplorer.config.selector.CompositeWebElementSelector.java

/**
 * This method uses a set internally to guard against duplicate elements
 * pulled in by the multiple selectors.//from w w  w .  ja v  a  2 s  . c o m
 */
@Override
public List<WebElement> select(WebDriver driver) {
    Set<WebElement> result = Sets.newLinkedHashSet();
    if (intersect && !selectorList.isEmpty()) {
        result.addAll(selectorList.get(0).select(driver));
        for (WebElementSelector selector : selectorList) {
            result.retainAll(selector.select(driver));
        }
    } else {
        for (WebElementSelector selector : selectorList) {
            result.addAll(selector.select(driver));
        }
    }
    return Lists.newArrayList(result);
}