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() 

Source Link

Document

Creates a mutable, initially empty HashSet instance.

Usage

From source file:cc.recommenders.evaluation.optimization.EvaluationOptionsSearcher.java

public Set<EvaluationOptions> getDefaultStartValues() {
    Set<EvaluationOptions> defaultOpts = Sets.newHashSet();
    defaultOpts.add(new EvaluationOptions(new MiningOptions(), new QueryOptions()));
    return defaultOpts;
}

From source file:br.edu.utfpr.cm.JGitMinerWeb.services.matrix.auxiliary.AuxNumberOfDevUser.java

public AuxNumberOfDevUser(Integer issueNumber, String url, Integer commentsCount, EntityUser autor) {
    this.issueNumber = issueNumber;
    this.url = url;
    this.commentsCount = commentsCount;
    this.numberOfAttendees = 0;
    this.numberOfDevs = 0;
    this.numberOfUsers = 0;
    this.commentsAuthorsList = Sets.newHashSet();
    this.autor = autor;
}

From source file:com.google.idea.blaze.base.sync.libraries.LibraryEditor.java

public static void updateProjectLibraries(Project project, BlazeContext context,
        BlazeProjectData blazeProjectData, Collection<BlazeLibrary> libraries) {
    Set<LibraryKey> intelliJLibraryState = Sets.newHashSet();
    for (Library library : ProjectLibraryTable.getInstance(project).getLibraries()) {
        String name = library.getName();
        if (name != null) {
            intelliJLibraryState.add(LibraryKey.fromIntelliJLibraryName(name));
        }/*w ww . jav a2s. c o  m*/
    }
    context.output(PrintOutput.log(String.format("Workspace has %d libraries", libraries.size())));

    LibraryTable libraryTable = ProjectLibraryTable.getInstance(project);
    LibraryTable.ModifiableModel libraryTableModel = libraryTable.getModifiableModel();
    try {
        for (BlazeLibrary library : libraries) {
            updateLibrary(project, blazeProjectData.artifactLocationDecoder, libraryTable, libraryTableModel,
                    library);
        }

        // Garbage collect unused libraries
        List<LibrarySource> librarySources = Lists.newArrayList();
        for (BlazeSyncPlugin syncPlugin : BlazeSyncPlugin.EP_NAME.getExtensions()) {
            LibrarySource librarySource = syncPlugin.getLibrarySource(blazeProjectData);
            if (librarySource != null) {
                librarySources.add(librarySource);
            }
        }
        Predicate<Library> gcRetentionFilter = librarySources.stream().map(LibrarySource::getGcRetentionFilter)
                .filter(Objects::nonNull).reduce(Predicate::or).orElse(o -> false);

        Set<LibraryKey> newLibraryKeys = libraries.stream().map((blazeLibrary) -> blazeLibrary.key)
                .collect(Collectors.toSet());
        for (LibraryKey libraryKey : intelliJLibraryState) {
            String libraryIntellijName = libraryKey.getIntelliJLibraryName();
            if (!newLibraryKeys.contains(libraryKey)) {
                Library library = libraryTable.getLibraryByName(libraryIntellijName);
                if (!gcRetentionFilter.test(library)) {
                    if (library != null) {
                        libraryTableModel.removeLibrary(library);
                    }
                }
            }
        }
    } finally {
        libraryTableModel.commit();
    }
}

From source file:com.amitinside.java8.practice.AlbumRefactoringExample.java

/**
 * First version of refactoring//from   w w w  . j av a 2s.c o  m
 */
public Set<String> findLongTracks1(final List<Album> albums) {
    final Set<String> trackNames = Sets.newHashSet();
    albums.stream().forEach(album -> {
        album.getTracks().forEach(track -> {
            if (track.getLength() > 60) {
                trackNames.add(track.getName());
            }
        });
    });
    return trackNames;
}

From source file:com.yahoo.pulsar.websocket.stats.ProxyTopicStat.java

public ProxyTopicStat() {
    this.producerStats = Sets.newHashSet();
    this.consumerStats = Sets.newHashSet();
}

From source file:com.fruit.model.AccessToken.java

public void updateImToken(String token, String imToken) {
    // TODO Auto-generated method stub 
    Set<Condition> conditions = Sets.newHashSet();
    conditions.add(new Condition("token", Operators.EQ, token));
    Map<String, Object> newValues = Maps.newHashMap();
    newValues.put("im_token", imToken);
    this.update(conditions, newValues);
}

From source file:org.eclipse.wb.internal.core.utils.ast.SetGatherer.java

@Override
protected final Collection<T> createCollection() {
    return Sets.newHashSet();
}

From source file:org.sonatype.nexus.capability.support.validator.DefaultValidationResult.java

public DefaultValidationResult() {
    violations = Sets.newHashSet();
}

From source file:com.facebook.buck.distributed.BuildTargetsQueue.java

public static BuildTargetsQueue newQueue(BuildRuleResolver resolver, Iterable<BuildTarget> targetsToBuild) {
    // Build the reverse dependency graph by traversing the action graph Top-Down.
    Map<String, Set<String>> allReverseDeps = new HashMap<>();
    Map<String, Integer> numberOfDependencies = new HashMap<>();
    Set<String> visitedTargets = Sets.newHashSet();
    Queue<BuildRule> buildRulesToProcess = Lists
            .newLinkedList(FluentIterable.from(targetsToBuild).transform(x -> {
                BuildRule rule = resolver.getRule(x);
                visitedTargets.add(ruleToTarget(rule));
                return rule;
            }));//from  ww  w  . j  av a  2s .c o m
    while (!buildRulesToProcess.isEmpty()) {
        BuildRule rule = buildRulesToProcess.remove();
        String target = ruleToTarget(rule);
        numberOfDependencies.put(target, rule.getBuildDeps().size());
        for (BuildRule dependencyRule : rule.getBuildDeps()) {
            String dependencyTarget = ruleToTarget(dependencyRule);
            if (!allReverseDeps.containsKey(dependencyTarget)) {
                allReverseDeps.put(dependencyTarget, Sets.newHashSet());
            }
            allReverseDeps.get(dependencyTarget).add(target);

            if (!visitedTargets.contains(dependencyTarget)) {
                visitedTargets.add(dependencyTarget);
                buildRulesToProcess.add(dependencyRule);
            }
        }
    }

    // Do the reference counting and create the EnqueuedTargets.
    List<EnqueuedTarget> zeroDependencyTargets = new ArrayList<>();
    Map<String, EnqueuedTarget> allEnqueuedTargets = new HashMap<>();
    for (String target : visitedTargets) {
        Iterable<String> currentRevDeps = null;
        if (allReverseDeps.containsKey(target)) {
            currentRevDeps = allReverseDeps.get(target);
        } else {
            currentRevDeps = new ArrayList<>();
        }

        EnqueuedTarget enqueuedTarget = new EnqueuedTarget(target, ImmutableList.copyOf(currentRevDeps),
                Preconditions.checkNotNull(numberOfDependencies.get(target)));
        allEnqueuedTargets.put(target, enqueuedTarget);

        if (enqueuedTarget.areAllDependenciesResolved()) {
            zeroDependencyTargets.add(enqueuedTarget);
        }
    }

    return new BuildTargetsQueue(zeroDependencyTargets, allEnqueuedTargets);
}

From source file:org.eclipse.viatra.query.runtime.localsearch.planner.util.CompilerHelper.java

public static Map<PVariable, Integer> createVariableMapping(SubPlan plan) {
    Map<PVariable, Integer> variableMapping = Maps.newHashMap();

    int variableNumber = 0;

    // Important note: this list might contain duplications when parameters are made equal inside the pattern
    // This is the expected and normal behavior
    List<PVariable> symbolicParameterVariables = plan.getBody().getSymbolicParameterVariables();
    for (PVariable pVariable : symbolicParameterVariables) {
        if (!variableMapping.containsKey(pVariable)) {
            variableMapping.put(pVariable, variableNumber++);
        }/* www  . j av a2s  .  c  o  m*/
    }

    // Reason for complexity here: not all variables were given back for call plan.getAllDeducedVariables();
    Set<PVariable> allVariables = Sets.newHashSet();
    Set<PConstraint> allEnforcedConstraints = plan.getAllEnforcedConstraints();
    for (PConstraint pConstraint : allEnforcedConstraints) {
        allVariables.addAll(pConstraint.getAffectedVariables());
    }
    for (PVariable pVariable : allVariables) {
        if (!variableMapping.containsKey(pVariable)) {
            variableMapping.put(pVariable, variableNumber++);
        }
    }

    return variableMapping;
}