當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。