微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

com.google.common.collect.Sets.SetView的实例源码

项目:jsf-core    文件PathCache.java   
private static Map<String,Set<String>> diffMap(Map<String,Byte[]> oldNodeData,Map<String,Byte[]> nodeWithData) {
    Set<String> oldChildNode = oldNodeData.keySet();
    Set<String> newChildNode = nodeWithData.keySet();
    SetView<String> view1 = Sets.difference(oldChildNode,newChildNode);// 下线的
    SetView<String> view2 = Sets.difference(newChildNode,oldChildNode);// 上线的
    Map<String,Set<String>> resultMap = new ConcurrentHashMap<String,Set<String>>();
    Set<String> offlineset = new HashSet<String>();
    Set<String> onlineset = new HashSet<String>();
    long before = System.currentTimeMillis();
    offlineset = view1.copyInto(offlineset);
    onlineset = view2.copyInto(onlineset);
    long after = System.currentTimeMillis();

    //Long[] longList = new Long[]{after-before,new Long(onlineset.size()),new Long(offlineset.size())};
    //logger.debug("SAF diff set spend time:{},online node MAP size:{} offlien node MAP size:{}",longList);
    resultMap.put(PathCache.OFFLInesET,offlineset);
    resultMap.put(PathCache.ONLInesET,onlineset);
    return resultMap;

}
项目:CustomWorldGen    文件PersistentRegistryManager.java   
private <T extends IForgeRegistryEntry<T>> FMLControllednamespacedRegistry<T> createRegistry(ResourceLocation registryName,Class<T> type,ResourceLocation defaultObjectKey,int minId,int maxId,IForgeRegistry.AddCallback<T> addCallback,IForgeRegistry.ClearCallback<T> clearCallback,IForgeRegistry.CreateCallback<T> createCallback,IForgeRegistry.SubstitutionCallback<T> substitutionCallback)
{
    Set<Class<?>> parents = Sets.newHashSet();
    findSuperTypes(type,parents);
    SetView<Class<?>> overlappedTypes = Sets.intersection(parents,registrySuperTypes.keySet());
    if (!overlappedTypes.isEmpty())
    {
        Class<?> foundType = overlappedTypes.iterator().next();
        FMLLog.severe("Found existing registry of type %1s named %2s,you cannot create a new registry (%3s) with type %4s,as %4s has a parent of that type",foundType,registrySuperTypes.get(foundType),registryName,type);
        throw new IllegalArgumentException("Duplicate registry parent type found - you can only have one registry for a particular super type");
    }
    FMLControllednamespacedRegistry<T> fmlControllednamespacedRegistry = new FMLControllednamespacedRegistry<T>(defaultObjectKey,minId,maxId,type,registries,addCallback,clearCallback,createCallback,substitutionCallback);
    registries.put(registryName,fmlControllednamespacedRegistry);
    registrySuperTypes.put(type,registryName);
    return getRegistry(registryName,type);
}
项目:Mastering-Mesos    文件ServerSetImpl.java   
private synchronized void notifyGroupChange(Iterable<String> memberIds) {
  ImmutableSet<String> newMemberIds = ImmutableSortedSet.copyOf(memberIds);
  Set<String> existingMemberIds = servicesByMemberId.asMap().keySet();

  // Ignore no-op state changes except for the 1st when we've seen no group yet.
  if ((serverSet == null) || !newMemberIds.equals(existingMemberIds)) {
    SetView<String> deletedMemberIds = Sets.difference(existingMemberIds,newMemberIds);
    // Implicit removal from servicesByMemberId.
    existingMemberIds.removeAll(ImmutableSet.copyOf(deletedMemberIds));

    Iterable<ServiceInstance> serviceInstances = Iterables.filter(
        Iterables.transform(newMemberIds,MAYBE_FETCH_NODE),Predicates.notNull());

    notifyServerSetChange(ImmutableSet.copyOf(serviceInstances));
  }
}
项目:Mastering-Mesos    文件ServerSetImpl.java   
private void logChange(ImmutableSet<ServiceInstance> newServerSet) {
  StringBuilder message = new StringBuilder("server set " + group.getPath() + " change: ");
  if (serverSet.size() != newServerSet.size()) {
    message.append("from ").append(serverSet.size())
        .append(" members to ").append(newServerSet.size());
  }

  Joiner joiner = Joiner.on("\n\t\t");

  SetView<ServiceInstance> left = Sets.difference(serverSet,newServerSet);
  if (!left.isEmpty()) {
    message.append("\n\tleft:\n\t\t").append(joiner.join(left));
  }

  SetView<ServiceInstance> joined = Sets.difference(newServerSet,serverSet);
  if (!joined.isEmpty()) {
    message.append("\n\tjoined:\n\t\t").append(joiner.join(joined));
  }

  LOG.info(message.toString());
}
项目:zeppelin-impala-interpreter    文件ImpalaInterpreter.java   
private sqlCompleter createsqlCompleter(Connection jdbcConnection) {

        sqlCompleter completer = null;
        try {
            Set<String> keywordsCompletions = sqlCompleter.getsqlKeywordsCompletions(jdbcConnection);
            Set<String> dataModelCompletions =
                    sqlCompleter.getDataModelMetadataCompletions(jdbcConnection);
            SetView<String> allCompletions = Sets.union(keywordsCompletions,dataModelCompletions);
            completer = new sqlCompleter(allCompletions,dataModelCompletions);

        } catch (IOException | sqlException e) {
            logger.error("Cannot create sql completer",e);
        }

        return completer;
    }
项目:zeppelin-impala-interpreter    文件sqlCompleter.java   
public void updateDataModelMetaData(Connection connection) {

    try {
      Set<String> newModelCompletions = getDataModelMetadataCompletions(connection);
      logger.debug("New model Metadata is:" + Joiner.on(',').join(newModelCompletions));

      // Sets.difference(set1,set2) - returned set contains all elements that are contained by set1
      // and not contained by set2. set2 may also contain elements not present in set1; these are
      // simply ignored.
      SetView<String> removedCompletions = Sets.difference(modelCompletions,newModelCompletions);
      logger.debug("Removed Model Completions: " + Joiner.on(',').join(removedCompletions));
      this.getStrings().removeAll(removedCompletions);

      SetView<String> newCompletions = Sets.difference(newModelCompletions,modelCompletions);
      logger.debug("New Completions: " + Joiner.on(',').join(newCompletions));
      this.getStrings().addAll(newCompletions);

      modelCompletions = newModelCompletions;

    } catch (sqlException e) {
      logger.error("Failed to update the Metadata conmpletions",e);
    }
  }
项目:incubator-pulsar    文件Namespaces.java   
/**
 * It validates that peer-clusters can't coexist in replication-clusters
 * 
 * @param clusterName:
 *            given cluster whose peer-clusters can't be present into replication-cluster list
 * @param clusters:
 *            replication-cluster list
 */
private void validatePeerClusterConflict(String clusterName,Set<String> replicationClusters) {
    try {
        ClusterData clusterData = clustersCache().get(path("clusters",clusterName)).orElseThrow(
                () -> new RestException(Status.PRECONDITION_Failed,"Invalid replication cluster " + clusterName));
        Set<String> peerClusters = clusterData.getPeerClusterNames();
        if (peerClusters != null && !peerClusters.isEmpty()) {
            SetView<String> conflictPeerClusters = Sets.intersection(peerClusters,replicationClusters);
            if (!conflictPeerClusters.isEmpty()) {
                log.warn("[{}] {}'s peer cluster can't be part of replication clusters {}",clientAppId(),clusterName,conflictPeerClusters);
                throw new RestException(Status.CONFLICT,String.format("%s's peer-clusters %s can't be part of replication-clusters %s",conflictPeerClusters,replicationClusters));
            }
        }
    } catch (RestException re) {
        throw re;
    } catch (Exception e) {
        log.warn("[{}] Failed to get cluster-data for {}",e);
    }
}
项目:incubator-zeppelin-druid    文件PostgresqlInterpreter.java   
private sqlCompleter createsqlCompleter(Connection jdbcConnection) {

    sqlCompleter completer = null;
    try {
      Set<String> keywordsCompletions = sqlCompleter.getsqlKeywordsCompletions(jdbcConnection);
      Set<String> dataModelCompletions =
          sqlCompleter.getDataModelMetadataCompletions(jdbcConnection);
      SetView<String> allCompletions = Sets.union(keywordsCompletions,dataModelCompletions);
      completer = new sqlCompleter(allCompletions,dataModelCompletions);

    } catch (IOException | sqlException e) {
      logger.error("Cannot create sql completer",e);
    }

    return completer;
  }
项目:incubator-zeppelin-druid    文件sqlCompleter.java   
public void updateDataModelMetaData(Connection connection) {

    try {
      Set<String> newModelCompletions = getDataModelMetadataCompletions(connection);
      logger.debug("New model Metadata is:" + Joiner.on(',e);
    }
  }
项目:FinanceAnalytics    文件DbCreatetool.java   
@Override
protected void doRun(boolean write,File outputFile) throws Exception {
  boolean dropExisting = getCommandLine().hasOption(DROP_EXISTING_OPTION);
  if (getCommandLine().hasOption(SCHEMA_NAME_FILTER)) {
    String[] nameArgs = getCommandLine().getoptionValues(SCHEMA_NAME_FILTER);
    Set<String> includeNames = ImmutableSet.copyOf(nameArgs);
    Set<String> allNames = getDbToolContext().getSchemaNames();
    SetView<String> filterednames = Sets.intersection(allNames,includeNames);
    if (write) {
      System.out.println("Filtered " + allNames + " to " + filterednames);
    }
    getDbToolContext().setSchemaNames(filterednames);
  }
  if (getDbToolContext().getSchemaNames().isEmpty()) {
    System.out.println("No schemas specified,or all filtered out");
  } else {
    new DbCreateOperation(getDbToolContext(),write,outputFile,dropExisting).execute();
    if (write) {
      System.out.println("Database objects created successfully");
    }
  }
}
项目:Twitteranalyzer    文件Main.java   
public void analyze() {
    log.info("Starting analyzing for user: " + twitterUser);

    //Create the CSVFormat object
    createFileIfNotExisting(filenameFollowerIDsDelta());
    createFileIfNotExisting(filenameFollowerIDsCurrent());

    Set<String> currentIDsFromFile = readAllIDsFromCurrentFile(); 
    currentIDsFromTwitter = getAllFollwerIDsFromTwitter();

    SetView<String> symmetricDifference = Sets.symmetricDifference(currentIDsFromFile,currentIDsFromTwitter);

    if (symmetricDifference.size() == 0) {
        log.info("No new followers were found.");
    } else {
        processSyncDifferences(currentIDsFromFile,symmetricDifference);

        deleteAndRecreateFile(filenameFollowerIDsCurrent());
        writeCurrentFollowerIDFile(currentIDsFromTwitter);
    }
}
项目:binnavi    文件PostgresqlNotificationProvider.java   
private void syncListenedChannels() {
  if (m_channels.equals(m_currentListenedChannels)) {
    return;
  }

  final Set<NotificationChannel> channels = Sets.newHashSet(m_channels);
  final SetView<NotificationChannel> toUnlisten =
      Sets.difference(m_currentListenedChannels,channels);
  final SetView<NotificationChannel> toListen =
      Sets.difference(channels,m_currentListenedChannels);

  if (!toUnlisten.isEmpty()) {
    sendUnlistens(toUnlisten);
  }
  if (!toListen.isEmpty()) {
    sendListens(toListen);
  }
  if (!toUnlisten.isEmpty() || !toListen.isEmpty()) {
    m_currentListenedChannels.clear();
    m_currentListenedChannels.addAll(channels);
  }
}
项目:presto    文件DynamicclassLoader.java   
public Map<String,Class<?>> defineClasses(Map<String,byte[]> newClasses)
{
    SetView<String> conflicts = Sets.intersection(pendingClasses.keySet(),newClasses.keySet());
    Preconditions.checkArgument(conflicts.isEmpty(),"The classes %s have already been defined",conflicts);

    pendingClasses.putAll(newClasses);
    try {
        Map<String,Class<?>> classes = new HashMap<>();
        for (String className : newClasses.keySet()) {
            try {
                Class<?> clazz = loadClass(className);
                classes.put(className,clazz);
            }
            catch (ClassNotFoundException e) {
                // this should never happen
                throw Throwables.propagate(e);
            }
        }
        return classes;
    }
    finally {
        pendingClasses.keySet().removeAll(newClasses.keySet());
    }
}
项目:onboard    文件UserServiceImpltest.java   
/**
 * @author 胡天翔
 */
@Test
public void testFilterProjectMembers() {
    List<User> list1 = new ArrayList<User>(),list2 = new ArrayList<User>();
    list1.add(getASampleUser(0));
    list1.add(getASampleUser(1));
    list1.add(getASampleUser(2));
    list2.add(getASampleUser(1));
    list2.add(getASampleUser(2));
    list2.add(getASampleUser(3));
    SetView<User> intersection = Sets.intersection(new HashSet<User>(list1),new HashSet<User>(list2));

    UserServiceImpl spyUserServiceImpl = Mockito.spy(testedUserServiceImpl);
    Mockito.doReturn(list2).when(spyUserServiceImpl).getUserByProjectId(ModuleHelper.projectId);

    List<User> user = spyUserServiceImpl.filterProjectMembers(list1,ModuleHelper.projectId);

    Mockito.verify(spyUserServiceImpl).filterProjectMembers(list1,ModuleHelper.projectId);
    Mockito.verify(spyUserServiceImpl).getUserByProjectId(ModuleHelper.projectId);
    Mockito.verifyNoMoreInteractions(spyUserServiceImpl);

    assertEquals(intersection.size(),Sets.intersection(intersection,new HashSet<User>(user)).size());
}
项目:passopolis-server    文件CreateOrganization.java   
/** Returns an error message if request is not valid. Checks basic request formatting. */
static String validateRequest(RPC.CreateOrganizationRequest request) {
  if (Strings.isNullOrEmpty(request.name)) {
    return "name cannot be empty";
  }
  if (Strings.isNullOrEmpty(request.publicKey)) {
    return "publicKey cannot be empty";
  }
  if (request.adminencryptedKeys == null || request.adminencryptedKeys.isEmpty()) {
    return "adminencryptedKeys cannot be empty";
  }
  if (request.memberGroupKeys == null || request.memberGroupKeys.isEmpty()) {
    return "memberGroupKeys cannot be empty";
  }

  // ensure that every admin is also a member
  SetView<String> adminsnotinMembers = Sets.difference(
      request.adminencryptedKeys.keySet(),request.memberGroupKeys.keySet());
  if (!adminsnotinMembers.isEmpty()) {
    return "each admin must be a member";
  }
  return null;
}
项目:movingcode    文件PackageInventory.java   
/**
 * Two instances of {@link PackageInventory} are identical if they
 * contain the same set packages.
 */
@Override
public boolean equals(Object obj) {
    if (!(obj instanceof PackageInventory)){
        return false;
    }
    PackageInventory ref = (PackageInventory) obj;
    // comparison of the PIDs is sufficient
    SetView<PID> symmDiff;
    // synchronized access to the underlying maps
    synchronized (packagesByIdMap){
        synchronized (ref.packagesByIdMap) {
            symmDiff = Sets.symmetricDifference(ref.packagesByIdMap.keySet(),this.packagesByIdMap.keySet());
        }
    }
    return symmDiff.isEmpty();
}
项目:error-prone    文件WellKNownMutability.java   
public Builder add(Class<?> clazz,String... containerOf) {
  ImmutableSet<String> containerTyParams = ImmutableSet.copyOf(containerOf);
  HashSet<String> actualTyParams = new HashSet<>();
  for (TypeVariable<?> x : clazz.getTypeParameters()) {
    actualTyParams.add(x.getName());
  }
  SetView<String> difference = Sets.difference(containerTyParams,actualTyParams);
  if (!difference.isEmpty()) {
    throw new AssertionError(
        String.format(
            "For %s,please update the type parameter(s) from %s to %s",clazz,difference,actualTyParams));
  }
  mapBuilder.put(
      clazz.getName(),AnnotationInfo.create(clazz.getName(),ImmutableList.copyOf(containerOf)));
  return this;
}
项目:kidneyExchange    文件AllHeavyEdgesConstructionHeuristic.java   
@Deprecated
private Set<E> getSelectedEdges(Map<E,Double> filteredEdgeValues) {
  Set<E> potentialEdges = filteredEdgeValues.keySet();
  Set<E> actualEdges = Sets.newHashSet();
  for (V root : kepInstance.getRootNodes()) {
    V head = root;
    while (head != null) {
      SetView<E> outEdge = Sets.intersection(potentialEdges,Sets.newHashSet(kepInstance.getGraph().getoutEdges(head)));
      if (outEdge.isEmpty()) {
        head = null;
      } else {
        E inUse = outEdge.iterator().next();
        actualEdges.add(inUse);
        head = kepInstance.getGraph().getDest(inUse);
      }
    }
  }
  return actualEdges;
}
项目:GedcomCreator    文件GedcomCreatorStructureStorage.java   
/**
 * 
 * 
 * <b>Note:</b> Depends on the collection of @R_577_4045@ion through {@link #buildFamilyRelations()}. 
 * Calls {@link #buildFamilyRelations()} before returning the 
 * result if any structures have been added or removed after the last call 
 * to {@link #buildFamilyRelations()},thus calling this method repeatedly 
 * after adding/removing structures is very inefficient.
 * 
 * @param parent1Id
 * @param parent2Id
 * @return
 */
public GedcomFamily getFamilyOfParents(String parent1Id,String parent2Id) {
    if (structuresModified) {
        buildFamilyRelations();
    }

    if (parent1Id == null && parent2Id == null) {
        return null;
    }

    Set<GedcomFamily> families1 = getFamiliesOfParent(parent1Id);
    Set<GedcomFamily> families2 = getFamiliesOfParent(parent2Id);

    //A comment in the guava docs: 
    //"I can use intersection as a Set directly,but copying it can be more 
    //efficient if I use it a lot."
    SetView<GedcomFamily> view = Sets.intersection(families1,families2);

    if (view.size() > 1) {
        throw new GedcomCreatorError("The parents " + parent1Id + " and " + parent2Id + 
                " have been found as parent in more than one (" + view.size() + ") family: " + view);
    }

    //Returns the first family,or null if there is none
    return Iterables.getFirst(view,null);
}
项目:fluo    文件ObserversV2.java   
public ObserversV2(Environment env,JsonObservers jco,Set<Column> strongColumns,Set<Column> weakColumns) {

  ObserverProvider obsProvider =
      ObserverStoreV2.newObserverProvider(jco.getobserverProviderClass());

  ObserverProviderContextImpl ctx = new ObserverProviderContextImpl(env);

  ObserverRegistry or = new ObserverRegistry(strongColumns,weakColumns);
  obsProvider.provide(or,ctx);

  this.observers = or.observers;
  this.aliases = or.aliases;
  this.observers.forEach((k,v) -> aliases.computeIfAbsent(k,col -> Hex.encNonAscii(col,":")));

  // the following check ensures observers are provided for all prevIoUsly configured columns
  SetView<Column> diff =
      Sets.difference(observers.keySet(),Sets.union(strongColumns,weakColumns));
  if (diff.size() > 0) {
    throw new FluoException("ObserverProvider " + jco.getobserverProviderClass()
        + " did not provide observers for columns " + diff);
  }
}
项目:BigSemanticsJava    文件MetaMetadataJavaTranslator.java   
@Override
protected void appendSuperClassGenericTypeVariables(Appendable appendable,ClassDescriptor inputClass)
    throws IOException
{
  MetadataClassDescriptor mdInputClass = (MetadataClassDescriptor) inputClass;
  MetaMetadata mmd = mdInputClass.getDefiningMmd();
  Map<String,MmdGenericTypeVar> gtvs = mmd.getGenericTypeVars();
  MetaMetadata superMmd = mmd.getSuperMmd();
  Map<String,MmdGenericTypeVar> superGtvs = superMmd.getGenericTypeVars();

  List<MmdGenericTypeVar> involvedGtvs = new ArrayList<MmdGenericTypeVar>();
  if (gtvs != null && superGtvs != null)
  {
    SetView<String> gtvNames = Sets.intersection(gtvs.keySet(),superGtvs.keySet());
    for (String gtvName : gtvNames)
    {
      involvedGtvs.add(gtvs.get(gtvName));
    }
    MetaMetadataRepository repository = mmd.getRepository();
    appendGenericTypeVarParameterizations(appendable,involvedGtvs,repository);
  }
}
项目:denominator    文件GeoResourceRecordSetCommands.java   
static void validateRegions(Map<String,Collection<String>> regionsToAdd,Collection<String>> supportedRegions) {
  MapDifference<String,Collection<String>>
      comparison =
      Maps.difference(regionsToAdd,supportedRegions);
  checkArgument(comparison.entriesOnlyOnLeft().isEmpty(),"unsupported regions: %s",comparison
      .entriesOnlyOnLeft().keySet());
  for (Entry<String,Collection<String>> entry : regionsToAdd.entrySet()) {
    ImmutableSet<String> toAdd = ImmutableSet.copyOf(entry.getValue());
    SetView<String> intersection = Sets.intersection(toAdd,ImmutableSet.copyOf(
                                                         supportedRegions.get(entry.getKey())));
    SetView<String> unsupported = Sets.difference(toAdd,intersection);
    checkArgument(unsupported.isEmpty(),"unsupported territories in %s:",entry.getKey(),unsupported);
  }
}
项目:hue    文件disjointPlan.java   
/**
 * This will mark the submitted dimensions as Cross_Join and all
 * other dimensions as Suppressed.
 *
 * @param xj - Set of Dimensions
 * @return List of Dimensions that are cross joined and can be planned
 *      by this disjointPlan.  The resolver can use this to pick a plan.
 */
public List<Dimension> setResolvedCrossJoins(SetView<Dimension> xj) {
    List<Dimension> plannedXj = Lists.newArrayList();
    getPlanDimensions().stream().forEach((d) -> {
        if(xj.contains(d)){
            disjointMap.put(d,disjointType.CROSS_JOIN);
            plannedXj.add(d);
        }else{
            disjointMap.put(d,disjointType.SUPpressed);
        }
    });
    return plannedXj;
}
项目:de.flapdoodle.solid    文件Tree.java   
@Lazy
protected ImmutableList<Node> asNodeTree() {
    ImmutableMap<String,String> childParentMap = childParentMap();
    SetView<String> roots = Sets.difference(relation().keySet(),childParentMap.keySet());
    return roots.stream()
        .map(s -> nodeOf(s,relation()))
        .collect(ImmutableList.toImmutableList());
}
项目:CustomWorldGen    文件TopologicalSort.java   
public static <T> void explore(T node,DirectedGraph<T> graph,List<T> sortedResult,Set<T> visitednodes,Set<T> expandednodes)
{
    // Have we been here before?
    if (visitednodes.contains(node))
    {
        // And have completed this node before
        if (expandednodes.contains(node))
        {
            // Then we're fine
            return;
        }

        FMLLog.severe("Mod Sorting Failed.");
        FMLLog.severe("Visiting node %s",node);
        FMLLog.severe("Current sorted list : %s",sortedResult);
        FMLLog.severe("Visited set for this node : %s",visitednodes);
        FMLLog.severe("Explored node set : %s",expandednodes);
        SetView<T> cycleList = Sets.difference(visitednodes,expandednodes);
        FMLLog.severe("Likely cycle is in : %s",cycleList);
        throw new ModSortingException("There was a cycle detected in the input graph,sorting is not possible",node,cycleList);
    }

    // Visit this node
    visitednodes.add(node);

    // Recursively explore inbound edges
    for (T inbound : graph.edgesFrom(node))
    {
        explore(inbound,graph,sortedResult,visitednodes,expandednodes);
    }

    // Add ourselves Now
    sortedResult.add(node);
    // And mark ourselves as explored
    expandednodes.add(node);
}
项目:Squirrel    文件InMemorySink.java   
/**
 * Returns the status of the sink.
 * 
 * @return the status of the sink.
 */
public boolean isSinkHealthy() {
    SetView<String> unclosedSinks = Sets.difference(rdfData.keySet(),closedSinks);
    if (unclosedSinks.size() > 0) {
        LOGGER.error("Some sinks have not been closed: " + unclosedSinks.toString());
        healthyness = false;
    }
    return healthyness;
}
项目:TRHS_Club_Mod_2016    文件TopologicalSort.java   
public static <T> void explore(T node,Set<T> expandednodes)
{
    // Have we been here before?
    if (visitednodes.contains(node))
    {
        // And have completed this node before
        if (expandednodes.contains(node))
        {
            // Then we're fine
            return;
        }

        FMLLog.severe("Mod Sorting Failed.");
        FMLLog.severe("Visting node %s",expandednodes);
    }

    // Add ourselves Now
    sortedResult.add(node);
    // And mark ourselves as explored
    expandednodes.add(node);
}
项目:google-cloud-eclipse    文件LaunchHelper.java   
/**
 * Look for servers that may match.
 * 
 * @param modules the web modules to search for
 * @param exact if true,look for exact module match
 * @return an existing server
 */
@VisibleForTesting
public Collection<IServer> findExistingServers(IModule[] modules,boolean exact,SubMonitor progress) {
  if (modules.length == 1) {
    IServer defaultServer = ServerCore.getDefaultServer(modules[0]);
    if (defaultServer != null && LocalAppEngineserverDelegate.SERVER_TYPE_ID
        .equals(defaultServer.getServerType().getId())) {
      return Collections.singletonList(defaultServer);
    }
  }
  Set<IModule> myModules = ImmutableSet.copyOf(modules);
  List<IServer> matches = new ArrayList<>();
  // Look for servers that contain these modules
  // Could prioritize servers that have *exactly* these modules,// or that have the smallest overlap
  for (IServer server : ServerCore.getServers()) {
    // obsolete or unavailable server deFinitions have serverType == null
    if (server.getServerType() == null
        || !LocalAppEngineserverDelegate.SERVER_TYPE_ID.equals(server.getServerType().getId())) {
      continue;
    }
    Set<IModule> serverModules = ImmutableSet.copyOf(server.getModules());
    SetView<IModule> overlap = Sets.intersection(myModules,serverModules);
    if (overlap.size() == myModules.size()
        && (!exact || overlap.size() == serverModules.size())) {
      matches.add(server);
    }
  }
  return matches;
}
项目:maven-cdi-plugin-utils    文件ParallelWorkflowStep.java   
@Override
public boolean equals(Object other) {
  if (other instanceof ParallelWorkflowStep) {
    ParallelWorkflowStep otherStep = (ParallelWorkflowStep) other;
    SetView<SimpleWorkflowStep> intersection = Sets.intersection(this.steps,otherStep.steps);
    return intersection.size() == this.steps.size();
  }
  return false;
}
项目:nbone    文件SetsTest.java   
public static void guava() {

    HashSet<Integer> setA = Sets.newHashSet(1,2,3,4,5);
    HashSet<Integer> setB = Sets.newHashSet(4,5,6,7,8);
     /**
      * 合集
      */
    SetView<Integer> union = Sets.union(setA,setB);
    System.out.println("union:" + union);

     /**
      * 取第二个参数的补集
      */
    SetView<Integer> difference = Sets.difference(setA,setB);
    System.out.println("difference:" + difference);

    /**
     * 取第二个参数的补集
     */
    SetView<Integer> difference1 = Sets.difference(setB,setA);
    System.out.println("difference1:" + difference1);

    /**
     * 交集
     */
    SetView<Integer> intersection = Sets.intersection(setA,setB);
    System.out.println("intersection:" +intersection);

    /**
     * 交集的补集
     */
    SetView<Integer> differences = Sets.symmetricDifference(setA,setB);
    System.out.println("differences:" +differences);


}
项目:intellij-ce-playground    文件JavaPerformanceDetector.java   
/**
 * Check whether the given invocation is done as a lazy initialization,* e.g. {@code if (foo == null) foo = new Foo();}.
 * <p>
 * This tries to also handle the scenario where the check is on some
 * <b>other</b> variable - e.g.
 * <pre>
 *    if (foo == null) {
 *        foo == init1();
 *        bar = new Bar();
 *    }
 * </pre>
 * or
 * <pre>
 *    if (!initialized) {
 *        initialized = true;
 *        bar = new Bar();
 *    }
 * </pre>
 */
private static boolean isLazilyInitialized(Node node) {
    Node curr = node.getParent();
    while (curr != null) {
        if (curr instanceof MethodDeclaration) {
            return false;
        } else if (curr instanceof If) {
            If ifNode = (If) curr;
            // See if the if block represents a lazy initialization:
            // compute all variable names seen in the condition
            // (e.g. for "if (foo == null || bar != foo)" the result is "foo,bar"),// and then compute all variables assigned to in the if body,// and if there is an overlap,we'll consider the whole if block
            // guarded (so lazily initialized and an allocation we won't complain
            // about.)
            List<String> assignments = new ArrayList<String>();
            AssignmentTracker visitor = new AssignmentTracker(assignments);
            ifNode.astStatement().accept(visitor);
            if (!assignments.isEmpty()) {
                List<String> references = new ArrayList<String>();
                addReferencedVariables(references,ifNode.astCondition());
                if (!references.isEmpty()) {
                    SetView<String> intersection = Sets.intersection(
                            new HashSet<String>(assignments),new HashSet<String>(references));
                    return !intersection.isEmpty();
                }
            }
            return false;

        }
        curr = curr.getParent();
    }

    return false;
}
项目:Twitteranalyzer    文件Main.java   
private void processSyncDifferences(Set<String> currentIDsFromFile,SetView<String> symmetricDifference) {

    File file = new File(filenameFollowerIDsDelta());
    try (CSVPrinter printer = new CSVPrinter(new FileWriter(file,true),csvFormat);){
    for (String id : symmetricDifference) {
        User userDetails = twitterClient.getUserDetails(id);
        if (currentIDsFromFile.contains(id)) {
            log.info("UNFOLLOW: Follower " + id + " unfollowed you!");
            printer.printRecord("DROP",DateTime.Now().getMillis(),id,currentIDsFromTwitter.size(),(userDetails != null ) ? userDetails.getProfileImageURL() : "",(userDetails != null ) ? userDetails.getScreenName() : "",(userDetails != null ) ? userDetails.getName() : ""
                    );
        } else {
            log.info("FOLLOW: Follower " + id + " followed you!");
            printer.printRecord("ADD",(userDetails != null ) ? userDetails.getName() : ""
                    );
        }
    }

} catch (IOException e) {
    log.error(e.getMessage());
}

}
项目:binnavi    文件BreakpointManager.java   
/**
 * This function enforces the type hierarchy of breakpoints.
 *
 * @param addresses The set of addresses for the breakpoints to be added.
 * @param type The type of the breakpoints to be added.
 *
 * @return The Set of breakpoints which has been set.
 */
private Set<BreakpointAddress> enforceBreakpointHierarchy(
    final Set<BreakpointAddress> addresses,final BreakpointType type) {
  final SetView<BreakpointAddress> alreadyRegularBreakpoints =
      Sets.intersection(addresses,indexedBreakpointStorage.getBreakPointAddresses());
  final SetView<BreakpointAddress> alreadySteppingBreakpoints =
      Sets.intersection(addresses,stepBreakpointStorage.getBreakPointAddresses());
  final SetView<BreakpointAddress> alreadyEchoBreakpoints =
      Sets.intersection(addresses,echoBreakpointStorage.getBreakPointAddresses());

  Set<BreakpointAddress> addressesSet = null;

  switch (type) {
    case REGULAR:
      final SetView<BreakpointAddress> notinRegularBreakpoints =
          Sets.difference(addresses,indexedBreakpointStorage.getBreakPointAddresses());
      removeBreakpoints(alreadySteppingBreakpoints,stepBreakpointStorage);
      removeBreakpoints(alreadyEchoBreakpoints,echoBreakpointStorage);
      addressesSet = notinRegularBreakpoints;
      break;

    case STEP:
      final SetView<BreakpointAddress> notinSteppingBreakpoints =
          Sets.difference(addresses,stepBreakpointStorage.getBreakPointAddresses());
      removeBreakpoints(alreadyEchoBreakpoints,echoBreakpointStorage);
      addressesSet = Sets.difference(notinSteppingBreakpoints,alreadyRegularBreakpoints);
      break;

    case ECHO:
      final SetView<BreakpointAddress> notinEchoBreakPoints =
          Sets.difference(addresses,echoBreakpointStorage.getBreakPointAddresses());
      addressesSet = Sets.difference(notinEchoBreakPoints,Sets.union(alreadySteppingBreakpoints,alreadyRegularBreakpoints));
      break;
    default:
      throw new IllegalStateException("IE00722: Breakpoint of invalid type");

  }
  return addressesSet;
}
项目:CauldronGit    文件TopologicalSort.java   
public static <T> void explore(T node,expandednodes);
    }

    // Add ourselves Now
    sortedResult.add(node);
    // And mark ourselves as explored
    expandednodes.add(node);
}
项目:ggp-tournament    文件YamlUtils.java   
public static void validateKeys(Map<String,?> map,String specType,Set<String> allowedKeys) {
    SetView<String> unrecognizedKeys = Sets.difference(map.keySet(),allowedKeys);
    if (!unrecognizedKeys.isEmpty()) {
        throw new RuntimeException("Did not recognize keys in the " + specType + " configuration: "
                + unrecognizedKeys);
    }
}
项目:che    文件WorkspaceRuntimes.java   
@Inject
public WorkspaceRuntimes(
    EventService eventService,InternalEnvironmentFactory> envFactories,RuntimeInfrastructure infra,WorkspaceSharedPool sharedPool,WorkspaceDao workspaceDao,@SuppressWarnings("unused") DBInitializer ignored,ProbeScheduler probeScheduler) {
  this.probeScheduler = probeScheduler;
  this.runtimes = new ConcurrentHashMap<>();
  this.eventService = eventService;
  this.sharedPool = sharedPool;
  this.workspaceDao = workspaceDao;
  this.isstartRefused = new AtomicBoolean(false);
  this.infrastructure = infra;
  this.environmentFactories = ImmutableMap.copyOf(envFactories);

  LOG.info("Configured factories for environments: '{}'",envFactories.keySet());
  LOG.info("Registered infrastructure '{}'",infra.getName());
  SetView<String> notSupportedByInfra =
      Sets.difference(envFactories.keySet(),infra.getRecipeTypes());
  if (!notSupportedByInfra.isEmpty()) {
    LOG.warn(
        "Configured environment(s) are not supported by infrastructure: '{}'",notSupportedByInfra);
  }
}
项目:onboard    文件UserServiceImpl.java   
@Override
public List<User> filterProjectMembers(List<User> users,int projectId) {
    List<User> members = getUserByProjectId(projectId);
    SetView<User> intersection = Sets.intersection(new HashSet<User>(users),new HashSet<User>(members));
    List<User> legalUsers = Lists.newArrayList();
    for (User user : intersection)
        legalUsers.add(user);
    return legalUsers;
}
项目:elpaaso-core    文件ElPaaSoLogicalModelCatalogTest.java   
public PropertyDiff diff(ElPaaSoLogicalTestModelCatalog catalog,String fileName) throws InvalidConfigServiceException {
    // Load properties from a reference properties file
    Set<String> releasePropertiesKeys = configServiceUtils.loadKeysFromFile(fileName);

    Set<String> actualPropertiesKeys = getReferencePropertiesKeys(catalog);

    // evict all development properties from comparison
    releasePropertiesKeys.removeAll(developmentSpecificPropertiesKeys);

    SetView<String> addedProperties = Sets.difference(actualPropertiesKeys,releasePropertiesKeys);
    SetView<String> removedProperties = Sets.difference(releasePropertiesKeys,actualPropertiesKeys);

    // Return a diff properties containing new and removed properties
    return new PropertyDiff(addedProperties,removedProperties);
}
项目:elpaaso-core    文件VerifyCredentialsPropertiesFilesIT.java   
@Test
public void reference_and_hudson_keys_are_identical() throws IOException {

    Set<String> referenceKeys = PropertiesHelper.loadKeys(REFERENCE_PROPERTIES_FILE,this.getClass().getResourceAsstream(REFERENCE_PROPERTIES_FILE));
    Set<String> hudsonKeys = PropertiesHelper.loadKeys(HUDSON_PROPERTIES_FILE,new ClassPathResource(HUDSON_PROPERTIES_FILE).getInputStream());

    SetView<String> jenkinsKeysNotPresentInHudsonKeys = Sets.difference(referenceKeys,hudsonKeys);
    SetView<String> hudsonKeysNotPresentInJenkinsKeys = Sets.difference(hudsonKeys,referenceKeys);

    assertTrue(buildDifferences("jenkins","hudson",jenkinsKeysNotPresentInHudsonKeys,hudsonKeysNotPresentInJenkinsKeys),jenkinsKeysNotPresentInHudsonKeys.isEmpty() && hudsonKeysNotPresentInJenkinsKeys.isEmpty());
}
项目:elpaaso-core    文件VerifyCredentialsPropertiesFilesIT.java   
private String buildDifferences(String file1,String file2,SetView<String> keysFile1NotPresentInFile2,SetView<String> keysFile2NotPresentInFile1) {
    String message = "they are differences:";

    if(!keysFile1NotPresentInFile2.isEmpty()) {
        message += "\n"+file1+ " keys declared for "+file2+ ": ";
        message += listValues(keysFile1NotPresentInFile2);
    }
    if(!keysFile2NotPresentInFile1.isEmpty()) {
        message += "\n"+file2+  " keys declared for "+file1+ ": ";
        message += listValues(keysFile2NotPresentInFile1);
    }
    return message;
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。