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


Java Collections2.filter方法代码示例

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


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

示例1: SimpleHelpMap

import com.google.common.collect.Collections2; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public SimpleHelpMap(CraftServer server) {
    this.helpTopics = new TreeMap<String, HelpTopic>(HelpTopicComparator.topicNameComparatorInstance()); // Using a TreeMap for its explicit sorting on key
    this.topicFactoryMap = new HashMap<Class, HelpTopicFactory<Command>>();
    this.server = server;
    this.yaml = new HelpYamlReader(server);

    Predicate indexFilter = Predicates.not(Predicates.instanceOf(CommandAliasHelpTopic.class));
    if (!yaml.commandTopicsInMasterIndex()) {
        indexFilter = Predicates.and(indexFilter, Predicates.not(new IsCommandTopicPredicate()));
    }

    this.defaultTopic = new IndexHelpTopic("Index", null, null, Collections2.filter(helpTopics.values(), indexFilter), "Use /help [n] to get page n of help.");

    registerHelpTopicFactory(MultipleCommandAlias.class, new MultipleCommandAliasHelpTopicFactory());
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:17,代码来源:SimpleHelpMap.java

示例2: listAll

import com.google.common.collect.Collections2; //导入方法依赖的package包/类
public static ArrayList<Currency> listAll(Context context, final String filter) {
    ArrayList<Currency> list = new ArrayList<>();

    for (java.util.Currency currency : java.util.Currency.getAvailableCurrencies()) {
        list.add(getCurrency(currency, context));
    }

    sortList(list);

    if (filter != null && filter.length() > 0) {
        return new ArrayList<>(Collections2.filter(list, new Predicate<Currency>() {
            @Override
            public boolean apply(Currency input) {
                return input.getName().toLowerCase().contains(filter.toLowerCase()) ||
                        input.getSymbol().toLowerCase().contains(filter.toLowerCase());
            }
        }));
    } else {
        return list;
    }
}
 
开发者ID:Scrounger,项目名称:CountryCurrencyPicker,代码行数:22,代码来源:Currency.java

示例3: getSourceFiles

import com.google.common.collect.Collections2; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private static Collection<String> getSourceFiles(String extraActionFile) {

  ExtraActionInfo info = ExtraActionUtils.getExtraActionInfo(extraActionFile);
  CppCompileInfo cppInfo = info.getExtension(CppCompileInfo.cppCompileInfo);

  return Collections2.filter(
          cppInfo.getSourcesAndHeadersList(),
          Predicates.and(
                  Predicates.not(Predicates.containsPattern("third_party/")),
                  Predicates.not(Predicates.containsPattern("config/heron-config.h")),
                  Predicates.not(Predicates.containsPattern(".*pb.h$")),
                  Predicates.not(Predicates.containsPattern(".*cc_wrapper.sh$")),
                  Predicates.not(Predicates.containsPattern(".*pb.cc$"))
          )
  );
}
 
开发者ID:DSC-SPIDAL,项目名称:twister2,代码行数:18,代码来源:CppCheckstyle.java

示例4: setResolvers

import com.google.common.collect.Collections2; //导入方法依赖的package包/类
/**
 * Set the registered client information resolvers.
 * 
 * @param newResolvers the client information resolvers to use
 * 
 * @throws ResolverException thrown if there is a problem adding the client information resolvers
 */
public void setResolvers(@Nonnull @NonnullElements final List<? extends ClientInformationResolver> newResolvers)
        throws ResolverException {
    ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
    ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);

    if (newResolvers == null || newResolvers.isEmpty()) {
        resolvers = Collections.emptyList();
        return;
    }

    resolvers = new ArrayList<>(Collections2.filter(newResolvers, Predicates.notNull()));
}
 
开发者ID:CSCfi,项目名称:shibboleth-idp-oidc-extension,代码行数:20,代码来源:ChainingClientInformationResolver.java

示例5: setDefaultAuthenticationMethods

import com.google.common.collect.Collections2; //导入方法依赖的package包/类
/**
 * Set the default authentication contexts to use, expressed as custom principals.
 * 
 * @param contexts default authentication contexts to use
 */
public void setDefaultAuthenticationMethods(
        @Nonnull @NonnullElements final List<Principal> contexts) {
    Constraint.isNotNull(contexts, "List of contexts cannot be null");

    defaultAuthenticationContexts = new ArrayList<>(Collections2.filter(contexts, Predicates.notNull()));
}
 
开发者ID:CSCfi,项目名称:shibboleth-idp-oidc-extension,代码行数:12,代码来源:OIDCCoreProtocolConfiguration.java

示例6: NameNodeResourceChecker

import com.google.common.collect.Collections2; //导入方法依赖的package包/类
/**
 * Create a NameNodeResourceChecker, which will check the edits dirs and any
 * additional dirs to check set in <code>conf</code>.
 */
public NameNodeResourceChecker(Configuration conf) throws IOException {
  this.conf = conf;
  volumes = new HashMap<String, CheckedVolume>();

  duReserved = conf.getLong(DFSConfigKeys.DFS_NAMENODE_DU_RESERVED_KEY,
      DFSConfigKeys.DFS_NAMENODE_DU_RESERVED_DEFAULT);
  
  Collection<URI> extraCheckedVolumes = Util.stringCollectionAsURIs(conf
      .getTrimmedStringCollection(DFSConfigKeys.DFS_NAMENODE_CHECKED_VOLUMES_KEY));
  
  Collection<URI> localEditDirs = Collections2.filter(
      FSNamesystem.getNamespaceEditsDirs(conf),
      new Predicate<URI>() {
        @Override
        public boolean apply(URI input) {
          if (input.getScheme().equals(NNStorage.LOCAL_URI_SCHEME)) {
            return true;
          }
          return false;
        }
      });

  // Add all the local edits dirs, marking some as required if they are
  // configured as such.
  for (URI editsDirToCheck : localEditDirs) {
    addDirToCheck(editsDirToCheck,
        FSNamesystem.getRequiredNamespaceEditsDirs(conf).contains(
            editsDirToCheck));
  }

  // All extra checked volumes are marked "required"
  for (URI extraDirToCheck : extraCheckedVolumes) {
    addDirToCheck(extraDirToCheck, true);
  }
  
  minimumRedundantVolumes = conf.getInt(
      DFSConfigKeys.DFS_NAMENODE_CHECKED_VOLUMES_MINIMUM_KEY,
      DFSConfigKeys.DFS_NAMENODE_CHECKED_VOLUMES_MINIMUM_DEFAULT);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:44,代码来源:NameNodeResourceChecker.java

示例7: getNearbyEntities

import com.google.common.collect.Collections2; //导入方法依赖的package包/类
public static <T extends Entity> Collection<? extends T> getNearbyEntities(Location location, Vector range, final Class<T> type) {
    Collection<Entity> filtered =  Collections2.filter(location.getWorld().getNearbyEntities(location, range.getX(), range.getY(), range.getZ()), new Predicate<Entity>() {
        @Override
        public boolean apply(Entity entity) {
            return type.isInstance(entity);
        }
    });
    return (Collection<? extends T>) filtered;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:10,代码来源:EntityUtils.java

示例8: getRewards

import com.google.common.collect.Collections2; //导入方法依赖的package包/类
private Collection<KillReward> getRewards(@Nullable Event event, ParticipantState victim, DamageInfo damageInfo) {
    final DamageQuery query = DamageQuery.attackerDefault(event, victim, damageInfo);
    return Collections2.filter(killRewards, new Predicate<KillReward>() {
        @Override
        public boolean apply(KillReward killReward) {
            return killReward.filter.query(query).isAllowed();
        }
    });
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:10,代码来源:KillRewardMatchModule.java

示例9: FilteredSchema

import com.google.common.collect.Collections2; //导入方法依赖的package包/类
/**
 * Construct a new {@link FilteredSchema} identical to the <var>baseSchema</var>
 * in all respects save the removal of the named tables. Note that tables are
 * removed regardless of the case of their names.
 *
 * @param baseSchema base schema to adapt.
 * @param removedTables names of tables to remove.
 */
public FilteredSchema(final Schema baseSchema, final String... removedTables) {
  super(Collections2.filter(baseSchema.tables(), not(new Predicate<Table>() {
    @Override
    public boolean apply(Table table) {
      // String.CASE_INSENSITIVE_ORDER lets you use case-insensitive .contains(Object)
      Set<String> caseInsensitiveSet = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
      Collections.addAll(caseInsensitiveSet, removedTables);
      return caseInsensitiveSet.contains(table.getName());
    }
  })));
}
 
开发者ID:alfasoftware,项目名称:morf,代码行数:20,代码来源:FilteredSchema.java

示例10: execute

import com.google.common.collect.Collections2; //导入方法依赖的package包/类
@Override
protected void execute() {
    MeterService service = get(MeterService.class);

    Collection<Meter> meters = service.getAllMeters();
    if (uri != null) {
        DeviceId deviceId = DeviceId.deviceId(uri);
        Collection<Meter> devMeters = Collections2.filter(meters,
                                                          m -> m.deviceId().equals(deviceId));
        printMeters(devMeters);
    } else {
        printMeters(meters);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:15,代码来源:Meters.java

示例11: syncSGRules

import com.google.common.collect.Collections2; //导入方法依赖的package包/类
private void syncSGRules(SecurityGroup sg, Openstack4JNeutron neutron) throws Exception {
    final List<? extends SecurityGroupRule> rules = sg.getRules();

    List<SecurityGroupRule> expectedList = new ArrayList<>();
    expectedList.add(Builders.securityGroupRule().protocol(null).ethertype(CreateOsSecurityGroupTask.IPV4)
            .direction(CreateOsSecurityGroupTask.INGRESS).build());
    expectedList.add(Builders.securityGroupRule().protocol(null).ethertype(CreateOsSecurityGroupTask.IPV4)
            .direction(CreateOsSecurityGroupTask.EGRESS).build());
    expectedList.add(Builders.securityGroupRule().protocol(null).ethertype(CreateOsSecurityGroupTask.IPV6)
            .direction(CreateOsSecurityGroupTask.INGRESS).build());
    expectedList.add(Builders.securityGroupRule().protocol(null).ethertype(CreateOsSecurityGroupTask.IPV6)
            .direction(CreateOsSecurityGroupTask.EGRESS).build());
    ImmutableList.<SecurityGroupRule>builder().addAll(expectedList);

    // Filter the missing rules from the expected SG rules
    Collection<SecurityGroupRule> missingRules = Collections2.filter(expectedList, expRule -> {
        for (SecurityGroupRule osRule : rules) {
            if (expRule != null && osRule.getDirection().equals(expRule.getDirection())
                    && osRule.getEtherType().equals(expRule.getEtherType()) && osRule.getProtocol() == null) {
                return false;
            }
        }
        return true;
    });
    if (!missingRules.isEmpty()) {
        neutron.addSecurityGroupRules(sg, this.ds.getRegion(), missingRules);
    }
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:29,代码来源:OsSecurityGroupCheckMetaTask.java

示例12: execute

import com.google.common.collect.Collections2; //导入方法依赖的package包/类
@Override
public void execute(final JobExecutionContext jobExecutionContext) throws JobExecutionException {
    SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);

    try {
        logger.info("Beginning ticket cleanup...");
        final Collection<Ticket> ticketsToRemove = Collections2.filter(this.getTickets(), new Predicate<Ticket>() {
            @Override
            public boolean apply(@Nullable final Ticket ticket) {
                if (ticket.isExpired()) {
                    if (ticket instanceof TicketGrantingTicket) {
                        logger.debug("Cleaning up expired ticket-granting ticket [{}]", ticket.getId());
                        logoutManager.performLogout((TicketGrantingTicket) ticket);
                        deleteTicket(ticket.getId());
                    } else if (ticket instanceof ServiceTicket) {
                        logger.debug("Cleaning up expired service ticket [{}]", ticket.getId());
                        deleteTicket(ticket.getId());
                    } else {
                        logger.warn("Unknown ticket type [{} found to clean", ticket.getClass().getSimpleName());
                    }
                    return true;
                }
                return false;
            }
        });
        logger.info("{} expired tickets found and removed.", ticketsToRemove.size());
    } catch (final Exception e) {
        logger.error(e.getMessage(), e);
    }
}
 
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:31,代码来源:DefaultTicketRegistry.java

示例13: getSourceFiles

import com.google.common.collect.Collections2; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private static Collection<String> getSourceFiles(String extraActionFile) {

  ExtraActionInfo info = ExtraActionUtils.getExtraActionInfo(extraActionFile);
  SpawnInfo spawnInfo = info.getExtension(SpawnInfo.spawnInfo);

  return Collections2.filter(spawnInfo.getInputFileList(),
      Predicates.and(
          Predicates.containsPattern(".*/src/.+\\.py[c]{0,1}$"),
          Predicates.not(Predicates.containsPattern("third_party/"))
      )
  );
}
 
开发者ID:DSC-SPIDAL,项目名称:twister2,代码行数:14,代码来源:PythonCheckstyle.java

示例14: tokenizeToFilteredMultiset

import com.google.common.collect.Collections2; //导入方法依赖的package包/类
@Override
Collection<String> tokenizeToFilteredMultiset(String input) {
	return Collections2.filter(
			tokenizer.tokenizeToTransformedMultiset(input),
			predicate);
}
 
开发者ID:janmotl,项目名称:linkifier,代码行数:7,代码来源:Tokenizers.java

示例15: getContent

import com.google.common.collect.Collections2; //导入方法依赖的package包/类
public String getContent() {
  final TableBuilder builder = new TableBuilder(FRAGMENT_COLUMNS);

  // Use only minor fragments that have complete profiles
  // Complete iff the fragment profile has at least one operator profile, and start and end times.
  final List<MinorFragmentProfile> complete = new ArrayList<>(
    Collections2.filter(major.getMinorFragmentProfileList(), Filters.hasOperatorsAndTimes));
  final List<MinorFragmentProfile> incomplete = new ArrayList<>(
    Collections2.filter(major.getMinorFragmentProfileList(), Filters.missingOperatorsOrTimes));

  Collections.sort(complete, Comparators.minorId);
  for (final MinorFragmentProfile minor : complete) {
    final ArrayList<OperatorProfile> ops = new ArrayList<>(minor.getOperatorProfileList());

    long biggestIncomingRecords = 0;
    long biggestBatches = 0;
    for (final OperatorProfile op : ops) {
      long incomingRecords = 0;
      long batches = 0;
      for (final StreamProfile sp : op.getInputProfileList()) {
        incomingRecords += sp.getRecords();
        batches += sp.getBatches();
      }
      biggestIncomingRecords = Math.max(biggestIncomingRecords, incomingRecords);
      biggestBatches = Math.max(biggestBatches, batches);
    }

    builder.appendCell(new OperatorPathBuilder().setMajor(major).setMinor(minor).build(), null);
    builder.appendCell(minor.getEndpoint().getAddress(), null);
    builder.appendMillis(minor.getStartTime() - start, null);
    builder.appendMillis(minor.getEndTime() - start, null);
    builder.appendMillis(minor.getEndTime() - minor.getStartTime(), null);

    builder.appendFormattedInteger(biggestIncomingRecords, null);
    builder.appendFormattedInteger(biggestBatches, null);

    builder.appendTime(minor.getLastUpdate(), null);
    builder.appendTime(minor.getLastProgress(), null);

    builder.appendBytes(minor.getMaxMemoryUsed(), null);
    builder.appendCell(minor.getState().name(), null);
  }

  for (final MinorFragmentProfile m : incomplete) {
    builder.appendCell(major.getMajorFragmentId() + "-" + m.getMinorFragmentId(), null);
    builder.appendRepeated(m.getState().toString(), null, NUM_NULLABLE_FRAGMENTS_COLUMNS);
  }
  return builder.build();
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:50,代码来源:FragmentWrapper.java


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