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


Java Collections2类代码示例

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


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

示例1: selectProperties

import com.google.common.collect.Collections2; //导入依赖的package包/类
private Iterable<ModelPropertyExtractionContext> selectProperties(final ModelSchemaExtractionContext<?> context, CandidateMethods candidateMethods) {
    Map<String, ModelPropertyExtractionContext> propertiesMap = Maps.newTreeMap();
    for (Map.Entry<Wrapper<Method>, Collection<Method>> entry : candidateMethods.allMethods().entrySet()) {
        Method method = entry.getKey().get();
        PropertyAccessorType propertyAccessorType = PropertyAccessorType.of(method);
        Collection<Method> methodsWithEqualSignature = entry.getValue();
        if (propertyAccessorType != null) {
            String propertyName = propertyAccessorType.propertyNameFor(method);
            ModelPropertyExtractionContext propertyContext = propertiesMap.get(propertyName);
            if (propertyContext == null) {
                propertyContext = new ModelPropertyExtractionContext(propertyName);
                propertiesMap.put(propertyName, propertyContext);
            }
            propertyContext.addAccessor(new PropertyAccessorExtractionContext(propertyAccessorType, methodsWithEqualSignature));
        }
    }
    return Collections2.filter(propertiesMap.values(), new Predicate<ModelPropertyExtractionContext>() {
        @Override
        public boolean apply(ModelPropertyExtractionContext property) {
            return property.isReadable();
        }
    });
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:24,代码来源:StructSchemaExtractionStrategySupport.java

示例2: loadUserByUsername

import com.google.common.collect.Collections2; //导入依赖的package包/类
@Override
public AttributedUserDetails loadUserByUsername(String login) throws UsernameNotFoundException {
    login = login.toLowerCase(Locale.ROOT);

    final SmartiUser smartiUser = getSmaritUser(login);

    if (smartiUser == null) {
        log.debug("User {} not found", login);
        throw new UsernameNotFoundException(String.format("Unknown user: '%s'", login));
    }

    final MongoUserDetails userDetails = new MongoUserDetails(
            smartiUser.getLogin(),
            smartiUser.getPassword(),
            Collections2.transform(smartiUser.getRoles(),
                    role -> new SimpleGrantedAuthority("ROLE_" + StringUtils.upperCase(role, Locale.ROOT))
            )
    );
    userDetails.addAttributes(smartiUser.getProfile());
    return userDetails;
}
 
开发者ID:redlink-gmbh,项目名称:smarti,代码行数:22,代码来源:MongoUserDetailsService.java

示例3: unPackSipNode

import com.google.common.collect.Collections2; //导入依赖的package包/类
private Object unPackSipNode(Object object) {
    if (object == null) {
        return null;
    }
    if (object instanceof SIPNode) {
        return handleSingleSipNode((SIPNode) object);
    }
    if (object instanceof Collection) {
        return Collections2.transform((Collection) object, new Function<Object, Object>() {
            @Override
            public Object apply(Object input) {
                if (!(input instanceof SIPNode)) {
                    return input;
                }
                return handleSingleSipNode((SIPNode) input);
            }
        });
    }
    return object;
}
 
开发者ID:virjar,项目名称:vscrawler,代码行数:21,代码来源:FetchTaskProcessor.java

示例4: getSeverity

import com.google.common.collect.Collections2; //导入依赖的package包/类
@Override
public String getSeverity() {
    if (hasVulnerabilities()) {
        Collection<Double> scores = Collections2.transform(
                software.getVulnerabilities(), new Function<Vulnerability, Double>() {
                    @Override
                    public Double apply(Vulnerability vulnerability) {
                        return vulnerability.getCvssScore();
                    }
                }
        );
        Double maxValue = Ordering.natural().max(scores);

        if (maxValue > 7) {
            return ScanIssueSeverity.HIGH.getName();
        } else if (maxValue > 4) {
            return ScanIssueSeverity.MEDIUM.getName();
        }
        return ScanIssueSeverity.LOW.getName();
    }

    return ScanIssueSeverity.INFO.getName();
}
 
开发者ID:vulnersCom,项目名称:burp-vulners-scanner,代码行数:24,代码来源:SoftwareIssue.java

示例5: getSeverity

import com.google.common.collect.Collections2; //导入依赖的package包/类
@Override
public String getSeverity() {
    Collection<Double> scores = Collections2.transform(
            vulnerabilities, new Function<Vulnerability, Double>() {
                @Override
                public Double apply(Vulnerability vulnerability) {
                    return vulnerability.getCvssScore();
                }
            }
    );
    Double maxValue = Ordering.natural().max(scores);

    if (maxValue > 7) {
        return ScanIssueSeverity.HIGH.getName();
    } else if (maxValue > 4) {
        return ScanIssueSeverity.MEDIUM.getName();
    }
    return ScanIssueSeverity.LOW.getName();
}
 
开发者ID:vulnersCom,项目名称:burp-vulners-scanner,代码行数:20,代码来源:PathIssue.java

示例6: findChildren

import com.google.common.collect.Collections2; //导入依赖的package包/类
/**
 * Finds all children runtime beans, same properties and values as current root
 * + any number of additional properties.
 */
private Set<ObjectName> findChildren(ObjectName innerRootBean, Set<ObjectName> childRbeOns) {
    final Map<String, String> wantedProperties = innerRootBean.getKeyPropertyList();

    return Sets.newHashSet(Collections2.filter(childRbeOns, on -> {
        Map<String, String> localProperties = on.getKeyPropertyList();
        for (Entry<String, String> propertyEntry : wantedProperties.entrySet()) {
            if (!localProperties.containsKey(propertyEntry.getKey())) {
                return false;
            }
            if (!localProperties.get(propertyEntry.getKey()).equals(propertyEntry.getValue())) {
                return false;
            }
            if (localProperties.size() <= wantedProperties.size()) {
                return false;
            }
        }
        return true;
    }));
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:24,代码来源:InstanceRuntime.java

示例7: genYailFilesIfNecessary

import com.google.common.collect.Collections2; //导入依赖的package包/类
private void genYailFilesIfNecessary(List<String> sourceFiles)
    throws IOException, YailGenerationException {
  // Filter out the files that aren't really source files (i.e. that don't end in .scm or .yail)
  Collection<String> formAndYailSourceFiles = Collections2.filter(
      sourceFiles,
      new Predicate<String>() {
        @Override
        public boolean apply(String input) {
          return input.endsWith(FORM_PROPERTIES_EXTENSION) || input.endsWith(YAIL_EXTENSION);
        }
      });
  for (String sourceFile : formAndYailSourceFiles) {
    if (sourceFile.endsWith(FORM_PROPERTIES_EXTENSION)) {
      String rootPath = sourceFile.substring(0, sourceFile.length()
                                                - FORM_PROPERTIES_EXTENSION.length());
      String yailFilePath = rootPath + YAIL_EXTENSION;
      // Note: Famous last words: The following contains() makes this method O(n**2) but n should
      // be pretty small.
      if (!sourceFiles.contains(yailFilePath)) {
        generateYail(rootPath);
      }
    }
  }
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:25,代码来源:ProjectBuilder.java

示例8: QuotaConfig

import com.google.common.collect.Collections2; //导入依赖的package包/类
@Inject QuotaConfig(Configuration root) {
    this.config = root.getConfigurationSection("match-quotas");
    if(config == null) {
        quotas = new TreeSet<>();
    } else {
        quotas = new TreeSet<>(Collections2.transform(
            config.getKeys(false),
            new Function<String, Entry>() {
                @Override
                public Entry apply(@Nullable String key) {
                    return new Entry(config.getConfigurationSection(key));
                }
            }
        ));
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:17,代码来源:QuotaConfig.java

示例9: loadFromDataStore

import com.google.common.collect.Collections2; //导入依赖的package包/类
@VisibleForTesting
void loadFromDataStore() {
    try {
        Date date = new Date();
        int version = commonModelFacade.getNextNamespacedListsVersion();
        log.info("Start getting NamespacedList(listVersion={}) from WS - startTime={}", version, date.getTime());
        NamespacedListsBatch namespacedListsBatch = new NamespacedListsBatch();
        namespacedListsBatch.setDataNodeVersion(version);
        for (NamespacedList item : commonModelFacade.getAllNamespacedLists()) {
            namespacedListsBatch.addValues(item.getName(), Collections2.transform(item.getValueSet(),
                    item.getType().equals(NamespacedListType.ENCODED) ? NamespacedListValueForWS::getEncodedValue : NamespacedListValueForWS::getValue));
        }
        setNamespacedListsBatch(namespacedListsBatch);

        Long endTime = (new Date()).getTime();
        log.info("End getting NamespacedList from WS - endTime=" + endTime + ", total duration=" + (endTime - date.getTime()) + " millis");
    } catch (Exception e) {
        log.error("Failed to load NamespacedList from commonModelFacade: {}", e.getMessage());
        throw e;
    }
}
 
开发者ID:Comcast,项目名称:redirector,代码行数:22,代码来源:NamespacedListsHolder.java

示例10: getCurrentSelectedUsers

import com.google.common.collect.Collections2; //导入依赖的package包/类
@Override
public List<SelectedUser> getCurrentSelectedUsers(SectionInfo info)
{
	return Lists.newArrayList(
		Collections2.transform(ParentViewItemSectionUtils.getItemInfo(info).getItem().getNotifications(),
			new Function<String, SelectedUser>()
			{
				@Override
				public SelectedUser apply(String uuidOrEmail)
				{
					final UserBean userBean = userService.getInformationForUser(uuidOrEmail);
					final String displayName;
					if( userBean == null )
					{
						displayName = uuidOrEmail;
					}
					else
					{
						displayName = Format.format(userBean);
					}
					return new SelectedUser(uuidOrEmail, displayName);
				}
			}));
}
 
开发者ID:equella,项目名称:Equella,代码行数:25,代码来源:ShareWithOthersContentSection.java

示例11: getCurrentSelectedUsers

import com.google.common.collect.Collections2; //导入依赖的package包/类
@Override
public List<SelectedUser> getCurrentSelectedUsers(SectionInfo info)
{
	return Lists.newArrayList(
		Collections2.transform(ParentViewItemSectionUtils.getItemInfo(info).getItem().getCollaborators(),
			new Function<String, SelectedUser>()
			{
				@Override
				public SelectedUser apply(final String uuidOrEmail)
				{
					final UserBean userBean = userService.getInformationForUser(uuidOrEmail);
					final String displayName;
					if( userBean == null )
					{
						displayName = uuidOrEmail;
					}
					else
					{
						displayName = Format.format(userBean);
					}
					return new SelectedUser(uuidOrEmail, displayName);
				}
			}));
}
 
开发者ID:equella,项目名称:Equella,代码行数:25,代码来源:ChangeOwnershipContentSection.java

示例12: setGroupFilter

import com.google.common.collect.Collections2; //导入依赖的package包/类
/**
 * Must be set before registering the dialog
 * 
 * @param groupFilter
 */
public void setGroupFilter(Set<String> groupFilter)
{
	if( !Check.isEmpty(groupFilter) )
	{
		this.groupFilter = groupFilter;

		final Collection<GroupBean> groupBeans = userService.getInformationForGroups(groupFilter).values();
		final Collection<String> gn = Collections2.transform(groupBeans, new Function<GroupBean, String>()
		{
			@Override
			public String apply(GroupBean group)
			{
				return group.getName();
			}
		});
		groupFilterNames = Lists.newArrayList(gn);
		Collections.sort(groupFilterNames);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:25,代码来源:AbstractSelectGroupSection.java

示例13: listAll

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

    for (String countryCode : Locale.getISOCountries()) {
        Country country = getCountry(countryCode, context);

        list.add(country);
    }

    sortList(list);

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

示例14: 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

示例15: 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


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