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:pw.swordfish.prefs.Sources.java

public static Sources of(Iterable<Source> sources) {
    return of(Sets.newHashSet(sources));
}

From source file:org.opendaylight.restconf.restful.utils.ParametersUtil.java

/**
 * Check if URI does not contain not allowed parameters for specified operation
 *
 * @param operationType//from  w  w w  .  ja  va2 s . c  o  m
 *            - type of operation (READ, POST, PUT, DELETE...)
 * @param usedParameters
 *            - parameters used in URI request
 * @param allowedParameters
 *            - allowed parameters for operation
 */
static void checkParametersTypes(@Nonnull final String operationType, @Nonnull final Set<String> usedParameters,
        @Nonnull final String... allowedParameters) {
    final Set<String> notAllowedParameters = Sets.newHashSet(usedParameters);
    notAllowedParameters.removeAll(Sets.newHashSet(allowedParameters));

    if (!notAllowedParameters.isEmpty()) {
        throw new RestconfDocumentedException(
                "Not allowed parameters for " + operationType + " operation: " + notAllowedParameters,
                RestconfError.ErrorType.PROTOCOL, RestconfError.ErrorTag.INVALID_VALUE);
    }
}

From source file:com.tfr.microbrew.config.CostsConfig.java

@Bean(name = "FixedCosts")
public List<FixedCost> fixedCosts() {
    return Lists.newArrayList(new FixedCost("Rent", 5000.0, Sets.newHashSet(1)),
            new FixedCost("Brewery License", 105.0, Sets.newHashSet(1)),
            new FixedCost("Insurance", 333.00, Sets.newHashSet(1)),
            new FixedCost("Internet/Phone/TV", 100.0, Sets.newHashSet(15)),
            new FixedCost("Gas/Electric", 1200.0, Sets.newHashSet(15)),
            new FixedCost("Logistics", 200.0, Sets.newHashSet(1)),
            new FixedCost("Water/Sewer", 200.0, Sets.newHashSet(15)),
            new FixedCost("Accountant", 250.0, Sets.newHashSet(1)),
            new FixedCost("Loan/Credit Payment", 1200.0, Sets.newHashSet(22)));
}

From source file:org.obiba.mica.dataset.search.rest.harmonization.ContingencyUtils.java

public static List<String> getTermsHeaders(DatasetVariable variable, Mica.DatasetVariableContingenciesDto dto) {
    List<String> dtoTerms = Lists.newArrayList(dto.getContingenciesList().stream()
            .flatMap(c -> c.getAggregationsList().stream()).map(a -> a.getTerm()).collect(toSet()));
    List<String> terms = variable.getCategories() != null
            ? variable.getCategories().stream().map(c -> c.getName()).collect(toList())
            : Lists.newArrayList();/*from  w  w w  .ja  v a2 s. c o  m*/
    terms.addAll(Sets.difference(Sets.newHashSet(dtoTerms), Sets.newHashSet(terms)));

    return terms;
}

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

public static IjProjectConfig create(BuckConfig buckConfig) {
    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  w ww .j ava 2  s.c om
        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());

    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"))
            .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).build();
}

From source file:org.ow2.proactive.connector.iaas.fixtures.NetworkFixtures.java

public static Network getNetwork(String publicAddress, String privateAddress) {
    return new Network(Sets.newHashSet("netowrkId"), Sets.newHashSet(publicAddress),
            Sets.newHashSet(privateAddress));
}

From source file:io.sidecar.ModelTestUtils.java

public static Event createSampleEvent() {
    Reading reading = new Reading("ABC", DateTime.now(DateTimeZone.UTC), 42);
    return new Event.Builder().id(UUID.randomUUID()).deviceId(UUID.randomUUID().toString())
            .timestamp(DateTime.now(DateTimeZone.UTC)).stream("wowza").tags(ImmutableSet.<String>of())
            .location(new Location(47.6014, -122.33)).readings(ImmutableList.of(reading))
            .keytags(ImmutableList.of(new KeyTag("key", Sets.newHashSet("keytag")))).build();
}

From source file:com.francetelecom.clara.cloud.coremodel.MiddlewareProfile.java

/**
 * Filter a collection of MiddlewareProfile to collect only visible ones
 * (based on user parameter)//ww  w .  j av a  2s . c o  m
 * 
 * @param user
 * @param profiles
 * @return
 */
public static Set<MiddlewareProfile> filter(final PaasUser user, Collection<MiddlewareProfile> profiles) {
    return Sets.newHashSet(Iterables.filter(profiles, new Predicate<MiddlewareProfile>() {
        @Override
        public boolean apply(MiddlewareProfile profile) {
            return profile.getStatus().isAllowedFor(user.getPaasUserRole());
        }
    }));
}

From source file:org.thiesen.collections.set.impl.MutableHashSet.java

public static <T> MutableHashSet<T> copyOf(final Iterable<T> elements) {
    return new MutableHashSet<T>(Sets.newHashSet(elements));
}

From source file:com.citytechinc.cq.clientlibs.core.domain.library.ClientLibraries.java

public static ClientLibrary forResource(Resource clientLibraryResource) {

    ValueMap clientLibraryValueMap = clientLibraryResource.adaptTo(ValueMap.class);
    Set<String> clientLibraryCategories = Sets
            .newHashSet(clientLibraryValueMap.get(Properties.CLIENT_LIBRARY_CATEGORIES, new String[0]));
    List<String> clientLibraryEmbeds = Lists
            .newArrayList(clientLibraryValueMap.get(Properties.CLIENT_LIBRARY_EMBED, new String[0]));
    List<String> clientLibraryDependencies = Lists
            .newArrayList(clientLibraryValueMap.get(Properties.CLIENT_LIBRARY_DEPENDENCIES, new String[0]));
    List<String> clientLibraryConditionalDependencies = Lists.newArrayList(
            clientLibraryValueMap.get(Properties.CLIENT_LIBRARY_CONDITIONAL_DEPENDENCIES, new String[0]));
    Set<String> clientLibrarySlingRunModes = Sets
            .newHashSet(clientLibraryValueMap.get(Properties.CLIENT_LIBRARY_RUN_MODES, new String[0]));
    Set<String> clientLibraryBrands = Sets
            .newHashSet(clientLibraryValueMap.get(Properties.CLIENT_LIBRARY_BRANDS, new String[0]));

    Set<SlingRunModeGroup> slingRunModeGroupSet = Sets.newHashSet();

    for (String currentCompositeRunMode : clientLibrarySlingRunModes) {
        slingRunModeGroupSet.add(SlingRunModeGroups.forCompositeRunMode(currentCompositeRunMode));
    }//from ww w  .  j  ava 2 s  .  c o m

    return new DefaultClientLibrary(clientLibraryCategories, clientLibraryResource, clientLibraryEmbeds,
            clientLibraryDependencies, clientLibraryConditionalDependencies, slingRunModeGroupSet,
            clientLibraryBrands);

}