當前位置: 首頁>>代碼示例>>Java>>正文


Java Stream.anyMatch方法代碼示例

本文整理匯總了Java中java.util.stream.Stream.anyMatch方法的典型用法代碼示例。如果您正苦於以下問題:Java Stream.anyMatch方法的具體用法?Java Stream.anyMatch怎麽用?Java Stream.anyMatch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.stream.Stream的用法示例。


在下文中一共展示了Stream.anyMatch方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: connectionExists

import java.util.stream.Stream; //導入方法依賴的package包/類
private boolean connectionExists(
        final Stream<ConnectionEntity> connectionEntities,
        final ConnectionEntity connectionEntity) {
  return connectionEntities.anyMatch(item ->
          item.getComponent().getSource().getGroupId().equals(
                  connectionEntity.getComponent().getSource().getGroupId())
                  && item.getComponent().getSource().getId().equals(
                  connectionEntity.getComponent().getSource().getId())
                  && item.getComponent().getSource().getName().trim().equals(
                  connectionEntity.getComponent().getSource().getName().trim())
                  && item.getComponent().getSource().getType().equals(
                  connectionEntity.getComponent().getSource().getType())
                  && item.getComponent().getDestination().getGroupId().equals(
                  connectionEntity.getComponent().getDestination().getGroupId())
                  && item.getComponent().getDestination().getId().equals(
                  connectionEntity.getComponent().getDestination().getId())
                  && item.getComponent().getDestination().getName().trim().equals(
                  connectionEntity.getComponent().getDestination().getName().trim())
                  && item.getComponent().getDestination().getType().equals(
                  connectionEntity.getComponent().getDestination().getType())
  );
}
 
開發者ID:hermannpencole,項目名稱:nifi-config,代碼行數:23,代碼來源:CreateRouteService.java

示例2: loadConfig

import java.util.stream.Stream; //導入方法依賴的package包/類
@Override
public Map<String, ConfigProperty> loadConfig() {
  Properties properties = System.getProperties();
  Map<String, ConfigProperty> result = new TreeMap<>();
  Stream<String> namespaces1 = namespaces.stream();

  for (Enumeration<?> e = properties.propertyNames(); e.hasMoreElements();) {
    String propName = (String) e.nextElement();
    if (namespaces.isEmpty() || namespaces1.anyMatch(propName::startsWith)) {
      result.put(propName, LoadedConfigProperty.forNameAndValue(propName, properties.getProperty(propName)));
    }
  }
  return result;
}
 
開發者ID:scalecube,項目名稱:config,代碼行數:15,代碼來源:SystemPropertiesConfigSource.java

示例3: loadConfig

import java.util.stream.Stream; //導入方法依賴的package包/類
@Override
public Map<String, ConfigProperty> loadConfig() {
  Map<String, String> env = System.getenv();
  Map<String, ConfigProperty> result = new TreeMap<>();
  Stream<String> namespaces1 = namespaces.stream();

  for (Map.Entry<String, String> entry : env.entrySet()) {
    String propName = entry.getKey();
    if (namespaces.isEmpty() || namespaces1.anyMatch(propName::startsWith)) {
      result.put(propName, LoadedConfigProperty.forNameAndValue(propName, entry.getValue()));
    }
  }
  return result;
}
 
開發者ID:scalecube,項目名稱:config,代碼行數:15,代碼來源:SystemEnvironmentConfigSource.java

示例4: doHealthCheck

import java.util.stream.Stream; //導入方法依賴的package包/類
@Override
protected void doHealthCheck(Builder builder) throws Exception
{
    final MBeanServer server = getMBeanServer();

    if (server != null)
    {
        final ObjectName on = new ObjectName("Q2:type=qbean,service=*");
        final Set<ObjectName> names = server.queryNames(on, null);
        final Stream<ObjectName> s = names.stream();

        final long muxInTransitCount = getMuxInTransitCount(server, names);
        final long tmInTransitCount = getTmInTransitCount(server, names);

        builder.withDetail("mux.in-transit", String.valueOf(muxInTransitCount));
        builder.withDetail("tm.in-transit", String.valueOf(tmInTransitCount));
        builder.withDetail("in-transit", String.valueOf(Math.max(muxInTransitCount, tmInTransitCount)));

        if (s.allMatch(name -> getStatus(server, name) == QBean.STARTED))
        {
            builder.up();
        }
        else if (s.anyMatch(name -> getStatus(server, name) == QBean.FAILED))
        {
            long cnt = s.filter(name -> getStatus(server, name) == QBean.FAILED).count();

            Set<String> objs = s.filter(name -> getStatus(server, name) == QBean.FAILED)
                .map(ObjectName::getCanonicalName)
                .collect(Collectors.toSet());

            String failedServices = StringUtils.collectionToCommaDelimitedString(objs);
            builder.withDetail("failed-count", String.valueOf(cnt));
            builder.withDetail("failed-services", failedServices);
            builder.status("failed");
        }
        else if (s.allMatch(name -> getStatus(server, name) == QBean.DESTROYED))
        {
            builder.outOfService();
        }
        else if (s.allMatch(name -> getStatus(server, name) == QBean.STOPPED))
        {
            builder.down();
        }
        else
        {
            builder.unknown();
        }
    }
    else
    {
        builder.unknown();
    }
}
 
開發者ID:vmantek,項目名稱:chimera,代碼行數:54,代碼來源:Q2DeploymentsHealthIndicator.java

示例5: any_internal

import java.util.stream.Stream; //導入方法依賴的package包/類
/**
 * Implementation of any().
 *
 * @param <T> The stream member type.
 * @param stream The {@code Stream} to test.
 * @param predicate The {@code Predicate} to test with.
 * @return True if any member passes the predicate test.
 */
private static <T> boolean any_internal(Stream<T> stream,
                                        Predicate<? super T> predicate) {
    return stream.anyMatch(predicate);
}
 
開發者ID:FreeCol,項目名稱:freecol,代碼行數:13,代碼來源:CollectionUtils.java


注:本文中的java.util.stream.Stream.anyMatch方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。