当前位置: 首页>>代码示例>>Java>>正文


Java SetView.isEmpty方法代码示例

本文整理汇总了Java中com.google.common.collect.Sets.SetView.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java SetView.isEmpty方法的具体用法?Java SetView.isEmpty怎么用?Java SetView.isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.collect.Sets.SetView的用法示例。


在下文中一共展示了SetView.isEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createRegistry

import com.google.common.collect.Sets.SetView; //导入方法依赖的package包/类
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);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:17,代码来源:PersistentRegistryManager.java

示例2: logChange

import com.google.common.collect.Sets.SetView; //导入方法依赖的package包/类
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());
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:22,代码来源:ServerSetImpl.java

示例3: validatePeerClusterConflict

import com.google.common.collect.Sets.SetView; //导入方法依赖的package包/类
/**
 * 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", clusterName,
                                conflictPeerClusters, replicationClusters));
            }
        }
    } catch (RestException re) {
        throw re;
    } catch (Exception e) {
        log.warn("[{}] Failed to get cluster-data for {}", clientAppId(), clusterName, e);
    }
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:30,代码来源:Namespaces.java

示例4: syncListenedChannels

import com.google.common.collect.Sets.SetView; //导入方法依赖的package包/类
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);
  }
}
 
开发者ID:google,项目名称:binnavi,代码行数:23,代码来源:PostgreSQLNotificationProvider.java

示例5: validateRequest

import com.google.common.collect.Sets.SetView; //导入方法依赖的package包/类
/** 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;
}
 
开发者ID:WeAreWizards,项目名称:passopolis-server,代码行数:24,代码来源:CreateOrganization.java

示例6: equals

import com.google.common.collect.Sets.SetView; //导入方法依赖的package包/类
/**
 * 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();
}
 
开发者ID:52North,项目名称:movingcode,代码行数:21,代码来源:PackageInventory.java

示例7: add

import com.google.common.collect.Sets.SetView; //导入方法依赖的package包/类
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;
}
 
开发者ID:google,项目名称:error-prone,代码行数:19,代码来源:WellKnownMutability.java

示例8: getSelectedEdges

import com.google.common.collect.Sets.SetView; //导入方法依赖的package包/类
@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;
}
 
开发者ID:rma350,项目名称:kidneyExchange,代码行数:21,代码来源:AllHeavyEdgesConstructionHeuristic.java

示例9: isLazilyInitialized

import com.google.common.collect.Sets.SetView; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:56,代码来源:JavaPerformanceDetector.java

示例10: validateKeys

import com.google.common.collect.Sets.SetView; //导入方法依赖的package包/类
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);
    }
}
 
开发者ID:AlexLandau,项目名称:ggp-tournament,代码行数:8,代码来源:YamlUtils.java

示例11: WorkspaceRuntimes

import com.google.common.collect.Sets.SetView; //导入方法依赖的package包/类
@Inject
public WorkspaceRuntimes(
    EventService eventService,
    Map<String, 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);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:29,代码来源:WorkspaceRuntimes.java

示例12: buildDifferences

import com.google.common.collect.Sets.SetView; //导入方法依赖的package包/类
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;
}
 
开发者ID:orange-cloudfoundry,项目名称:elpaaso-core,代码行数:16,代码来源:VerifyCredentialsPropertiesFilesIT.java

示例13: addListDetail

import com.google.common.collect.Sets.SetView; //导入方法依赖的package包/类
private static void addListDetail(
    StringBuilder sb, String key, Iterable<Artifact> valueA, Iterable<Artifact> valueB) {
  Set<Artifact> setA = ImmutableSet.copyOf(valueA);
  Set<Artifact> setB = ImmutableSet.copyOf(valueB);
  SetView<Artifact> diffA = Sets.difference(setA, setB);
  SetView<Artifact> diffB = Sets.difference(setB, setA);

  sb.append(key).append(": ");
  if (diffA.isEmpty() && diffB.isEmpty()) {
    sb.append("are equal\n");
  } else {
    if (!diffA.isEmpty()) {
      sb.append(
          "Attempted action contains artifacts not in previous action (first "
              + MAX_DIFF_ARTIFACTS_TO_REPORT
              + "): \n");
      prettyPrintArtifactDiffs(sb, diffA);
    }

    if (!diffB.isEmpty()) {
      sb.append(
          "Previous action contains artifacts not in attempted action (first "
              + MAX_DIFF_ARTIFACTS_TO_REPORT
              + "): \n");
      prettyPrintArtifactDiffs(sb, diffB);
    }
  }
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:29,代码来源:MutableActionGraph.java

示例14: openNewWindow

import com.google.common.collect.Sets.SetView; //导入方法依赖的package包/类
/**
 * Opens a new window and switches to it. The window to switch to is determined by diffing
 * the given {@code existingWindowHandles} with the current ones. The difference must be
 * exactly one window handle which is then used to switch to.
 *
 * @param openCommand
 *            logic for opening the new window
 * @param timeoutSeconds
 *            the timeout in seconds to wait for the new window to open
 * @return the handle of the window that opened the new window
 */
public String openNewWindow(final Runnable openCommand, final long timeoutSeconds) {
	String oldHandle = webDriver.getWindowHandle();
	final Set<String> existingWindowHandles = webDriver.getWindowHandles();

	openCommand.run();

	Function<WebDriver, String> function = new Function<WebDriver, String>() {
		@Override
		public String apply(final WebDriver input) {
			Set<String> newWindowHandles = webDriver.getWindowHandles();
			SetView<String> newWindows = difference(newWindowHandles, existingWindowHandles);
			if (newWindows.isEmpty()) {
				throw new NotFoundException("No new window found.");
			}
			return getOnlyElement(newWindows);
		}

		@Override
		public String toString() {
			return "new window to open";
		}
	};

	String newHandle = waitFor(function, timeoutSeconds);
	webDriver.switchTo().window(newHandle);
	return oldHandle;
}
 
开发者ID:mgm-tp,项目名称:jfunk,代码行数:39,代码来源:WebDriverTool.java

示例15: matchClass

import com.google.common.collect.Sets.SetView; //导入方法依赖的package包/类
@Override
public Description matchClass(ClassTree tree, VisitorState state) {
  ImmutableAnalysis analysis = new ImmutableAnalysis(this, state, wellKnownMutability);
  if (tree.getSimpleName().length() == 0) {
    // anonymous classes have empty names
    // TODO(cushon): once Java 8 happens, require @Immutable on anonymous classes
    return handleAnonymousClass(tree, state, analysis);
  }

  AnnotationInfo annotation = analysis.getImmutableAnnotation(tree, state);
  if (annotation == null) {
    // If the type isn't annotated we don't check for immutability, but we do
    // report an error if it extends/implements any @Immutable-annotated types.
    return checkSubtype(tree, state);
  }

  // Special-case visiting declarations of known-immutable types; these uses
  // of the annotation are "trusted".
  if (wellKnownMutability.getKnownImmutableClasses().containsValue(annotation)) {
    return NO_MATCH;
  }

  // Check that the types in containerOf actually exist
  Map<String, TypeVariableSymbol> typarams = new HashMap<>();
  for (TypeParameterTree typaram : tree.getTypeParameters()) {
    typarams.put(
        typaram.getName().toString(), (TypeVariableSymbol) ASTHelpers.getSymbol(typaram));
  }
  SetView<String> difference = Sets.difference(annotation.containerOf(), typarams.keySet());
  if (!difference.isEmpty()) {
    return buildDescription(tree)
        .setMessage(
            String.format(
                "could not find type(s) referenced by containerOf: %s",
                Joiner.on("', '").join(difference)))
        .build();
  }
  ImmutableSet<String> immutableAndContainer =
      typarams
          .entrySet()
          .stream()
          .filter(
              e ->
                  annotation.containerOf().contains(e.getKey())
                      && analysis.isImmutableTypeParameter(e.getValue()))
          .map(Entry::getKey)
          .collect(toImmutableSet());
  if (!immutableAndContainer.isEmpty()) {
    return buildDescription(tree)
        .setMessage(
            String.format(
                "using both @ImmutableTypeParameter and containerOf is redundant: %s",
                Joiner.on("', '").join(immutableAndContainer)))
        .build();
  }

  // Main path for @Immutable-annotated types:
  //
  // Check that the fields (including inherited fields) are immutable, and
  // validate the type hierarchy superclass.

  ClassSymbol sym = ASTHelpers.getSymbol(tree);

  Violation info =
      analysis.checkForImmutability(
          Optional.of(tree),
          immutableTypeParametersInScope(ASTHelpers.getSymbol(tree), state, analysis),
          ASTHelpers.getType(tree),
          (Tree matched, Violation violation) ->
              describeClass(matched, sym, annotation, violation));

  if (!info.isPresent()) {
    return NO_MATCH;
  }

  return describeClass(tree, sym, annotation, info).build();
}
 
开发者ID:google,项目名称:error-prone,代码行数:78,代码来源:ImmutableChecker.java


注:本文中的com.google.common.collect.Sets.SetView.isEmpty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。