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

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

Introduction

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

Prototype

public static <E> HashSet<E> newHashSet(Iterator<? extends E> elements) 

Source Link

Document

Creates a mutable HashSet instance containing the given elements.

Usage

From source file:org.kitesdk.data.spi.Predicates.java

@SuppressWarnings("unchecked")
public static <T> In<T> in(T... set) {
    T item = set[0];//from  w  w  w . j  a v  a2  s. c  om
    if (item != null && item instanceof CharSequence) {
        return (In<T>) new In(
                new CharSequences.ImmutableCharSequenceSet((Set<CharSequence>) Sets.newHashSet(set)));
    }
    return new In<T>(set);
}

From source file:io.joynr.examples.jee.RadioConsumerRestApplication.java

@Override
public Set<Class<?>> getClasses() {
    return Sets.newHashSet(RadioConsumerRestEndpoint.class);
}

From source file:org.graylog.plugin.filter.dns.DnsResolverFilterModule.java

@Override
public Set<? extends PluginConfigBean> getConfigBeans() {
    return Sets.newHashSet(new DnsResolverConfiguration());
}

From source file:de.flapdoodle.mongoom.live.beans.fields.Book.java

public static Book getInstance(String name, String... categories) {
    Book ret = new Book();
    ret._name = name;//  w  ww .  j a v a2  s . com
    ret._category = Sets.newHashSet(categories);
    return ret;
}

From source file:io.joynr.test.interlanguage.jee.IltConsumerRestApplication.java

@Override
public Set<Class<?>> getClasses() {
    return Sets.newHashSet(IltConsumerRestEndpoint.class);
}

From source file:mtsar.api.csv.AnswerCSV.java

public static Iterator<Answer> parse(Stage stage, CSVParser csv) {
    final Set<String> header = csv.getHeaderMap().keySet();
    checkArgument(!Sets.intersection(header, Sets.newHashSet(HEADER)).isEmpty(), "Unknown CSV header: %s",
            String.join(",", header));

    return StreamSupport.stream(csv.spliterator(), false).map(row -> {
        final String id = row.isSet("id") ? row.get("id") : null;
        final String[] tags = row.isSet("tags") && !StringUtils.isEmpty(row.get("tags"))
                ? row.get("tags").split("\\|")
                : new String[0];
        final String type = row.isSet("type") ? row.get("type") : null;
        final String workerId = row.get("worker_id");
        final String taskId = row.get("task_id");
        final String[] answers = row.isSet("answers") && !StringUtils.isEmpty(row.get("answers"))
                ? row.get("answers").split("\\|")
                : new String[0];
        final String datetime = row.isSet("datetime") ? row.get("datetime") : null;

        return new Answer.Builder().setId(StringUtils.isEmpty(id) ? null : Integer.valueOf(id))
                .setStage(stage.getId()).addAllTags(Arrays.asList(tags))
                .setDateTime(new Timestamp(StringUtils.isEmpty(datetime) ? System.currentTimeMillis()
                        : Long.parseLong(datetime) * 1000L))
                .setType(StringUtils.defaultIfEmpty(type, AnswerDAO.ANSWER_TYPE_DEFAULT))
                .setWorkerId(Integer.valueOf(workerId)).setTaskId(Integer.valueOf(taskId))
                .addAllAnswers(Arrays.asList(answers)).build();
    }).iterator();//from w w w. j a va2s. c o  m
}

From source file:com.paolodragone.wsn.util.LexicalContexts.java

public static Set<String> getLexicalContextParts(String lexicalContext) {
    return filterNotEmpty(trimAll(toLowerCaseAll(Sets.newHashSet(lexicalContext.split(";")).stream())))
            .collect(Collectors.toSet());
}

From source file:edu.emory.clir.clearnlp.qa.structure.Entity.java

public Entity(Instance... instances) {
    s_instances = Sets.newHashSet(instances);
}

From source file:com.facebook.buck.ide.intellij.IjProjectBuckConfig.java

public static IjProjectConfig create(BuckConfig buckConfig, @Nullable AggregationMode aggregationMode,
        @Nullable String generatedFilesListFilename, boolean isCleanerEnabled, boolean removeUnusedLibraries,
        boolean excludeArtifacts) {
    Optional<String> excludedResourcePathsOption = buckConfig.getValue(INTELLIJ_BUCK_CONFIG_SECTION,
            "excluded_resource_paths");

    Iterable<String> excludedResourcePaths;
    if (excludedResourcePathsOption.isPresent()) {
        excludedResourcePaths = Sets.newHashSet(
                Splitter.on(',').omitEmptyStrings().trimResults().split(excludedResourcePathsOption.get()));
    } else {//from ww  w  .  java 2s.co m
        excludedResourcePaths = Collections.emptyList();
    }

    Optional<String> generatedSourcesMap = buckConfig.getValue(INTELLIJ_BUCK_CONFIG_SECTION,
            "generated_srcs_map");

    Map<String, String> depToGeneratedSourcesMap = generatedSourcesMap
            .map(value -> Splitter.on(',').omitEmptyStrings().trimResults()
                    .withKeyValueSeparator(Splitter.on("=>").trimResults()).split(value))
            .orElse(Collections.emptyMap());

    Optional<String> generatedSourcesLabelMap = buckConfig.getValue(INTELLIJ_BUCK_CONFIG_SECTION,
            "generated_sources_label_map");

    Map<String, String> labelToGeneratedSourcesMap = generatedSourcesLabelMap
            .map(value -> Splitter.on(',').omitEmptyStrings().trimResults()
                    .withKeyValueSeparator(Splitter.on("=>").trimResults()).split(value))
            .orElse(Collections.emptyMap());

    Optional<Path> androidManifest = buckConfig.getPath(INTELLIJ_BUCK_CONFIG_SECTION,
            "default_android_manifest_path", false);

    return IjProjectConfig.builder()
            .setAutogenerateAndroidFacetSourcesEnabled(!buckConfig.getBooleanValue(PROJECT_BUCK_CONFIG_SECTION,
                    "disable_r_java_idea_generator", false))
            .setJavaBuckConfig(buckConfig.getView(JavaBuckConfig.class)).setBuckConfig(buckConfig)
            .setProjectJdkName(buckConfig.getValue(INTELLIJ_BUCK_CONFIG_SECTION, "jdk_name"))
            .setProjectJdkType(buckConfig.getValue(INTELLIJ_BUCK_CONFIG_SECTION, "jdk_type"))
            .setAndroidModuleSdkName(
                    buckConfig.getValue(INTELLIJ_BUCK_CONFIG_SECTION, "android_module_sdk_name"))
            .setAndroidModuleSdkType(
                    buckConfig.getValue(INTELLIJ_BUCK_CONFIG_SECTION, "android_module_sdk_type"))
            .setIntellijModuleSdkName(
                    buckConfig.getValue(INTELLIJ_BUCK_CONFIG_SECTION, "intellij_module_sdk_name"))
            .setIntellijPluginLabels(
                    buckConfig.getListWithoutComments(INTELLIJ_BUCK_CONFIG_SECTION, "intellij_plugin_labels"))
            .setJavaModuleSdkName(buckConfig.getValue(INTELLIJ_BUCK_CONFIG_SECTION, "java_module_sdk_name"))
            .setJavaModuleSdkType(buckConfig.getValue(INTELLIJ_BUCK_CONFIG_SECTION, "java_module_sdk_type"))
            .setProjectLanguageLevel(buckConfig.getValue(INTELLIJ_BUCK_CONFIG_SECTION, "language_level"))
            .setExcludedResourcePaths(excludedResourcePaths)
            .setDepToGeneratedSourcesMap(depToGeneratedSourcesMap)
            .setLabelToGeneratedSourcesMap(labelToGeneratedSourcesMap).setAndroidManifest(androidManifest)
            .setCleanerEnabled(isCleanerEnabled)
            .setRemovingUnusedLibrariesEnabled(
                    isRemovingUnusedLibrariesEnabled(removeUnusedLibraries, buckConfig))
            .setExcludeArtifactsEnabled(isExcludingArtifactsEnabled(excludeArtifacts, buckConfig))
            .setAggregationMode(getAggregationMode(aggregationMode, buckConfig))
            .setGeneratedFilesListFilename(Optional.ofNullable(generatedFilesListFilename))
            .setIgnoredTargetLabels(
                    buckConfig.getListWithoutComments(INTELLIJ_BUCK_CONFIG_SECTION, "ignored_target_labels"))
            .build();
}

From source file:cuchaz.enigma.convert.ClassMatch.java

public ClassMatch(Collection<ClassEntry> sourceClasses, Collection<ClassEntry> destClasses) {
    this.sourceClasses = Sets.newHashSet(sourceClasses);
    this.destClasses = Sets.newHashSet(destClasses);
}