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();
}
});
}
java类com.google.common.collect.Collections2的实例源码
StructSchemaExtractionStrategySupport.java 文件源码
项目:Reer
阅读 43
收藏 0
点赞 0
评论 0
MongoUserDetailsService.java 文件源码
项目:smarti
阅读 42
收藏 0
点赞 0
评论 0
@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;
}
FetchTaskProcessor.java 文件源码
项目:vscrawler
阅读 36
收藏 0
点赞 0
评论 0
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;
}
SoftwareIssue.java 文件源码
项目:burp-vulners-scanner
阅读 28
收藏 0
点赞 0
评论 0
@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();
}
PathIssue.java 文件源码
项目:burp-vulners-scanner
阅读 39
收藏 0
点赞 0
评论 0
@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();
}
InstanceRuntime.java 文件源码
项目:hashsdn-controller
阅读 32
收藏 0
点赞 0
评论 0
/**
* 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;
}));
}
ProjectBuilder.java 文件源码
项目:appinventor-extensions
阅读 42
收藏 0
点赞 0
评论 0
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);
}
}
}
}
QuotaConfig.java 文件源码
项目:ProjectAres
阅读 37
收藏 0
点赞 0
评论 0
@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));
}
}
));
}
}
NamespacedListsHolder.java 文件源码
项目:redirector
阅读 22
收藏 0
点赞 0
评论 0
@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;
}
}
ShareWithOthersContentSection.java 文件源码
项目:Equella
阅读 33
收藏 0
点赞 0
评论 0
@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);
}
}));
}
ChangeOwnershipContentSection.java 文件源码
项目:Equella
阅读 27
收藏 0
点赞 0
评论 0
@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);
}
}));
}
AbstractSelectGroupSection.java 文件源码
项目:Equella
阅读 29
收藏 0
点赞 0
评论 0
/**
* 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);
}
}
Country.java 文件源码
项目:CountryCurrencyPicker
阅读 37
收藏 0
点赞 0
评论 0
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;
}
}
Currency.java 文件源码
项目:CountryCurrencyPicker
阅读 39
收藏 0
点赞 0
评论 0
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;
}
}
CppCheckstyle.java 文件源码
项目:twister2
阅读 34
收藏 0
点赞 0
评论 0
@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$"))
)
);
}
TOAttribute.java 文件源码
项目:hashsdn-controller
阅读 41
收藏 0
点赞 0
评论 0
@Override
public CompositeType getOpenType() {
final String description = getNullableDescription() == null ? getAttributeYangName() : getNullableDescription();
final FunctionImpl functionImpl = new FunctionImpl();
final Map<String, AttributeIfc> jmxPropertiesToTypesMap = getJmxPropertiesToTypesMap();
final OpenType<?>[] itemTypes = Collections2.transform(
jmxPropertiesToTypesMap.entrySet(), functionImpl).toArray(
new OpenType<?>[] {});
final String[] itemNames = functionImpl.getItemNames();
try {
// TODO add package name to create fully qualified name for this
// type
final CompositeType compositeType = new CompositeType(
getUpperCaseCammelCase(), description, itemNames,
itemNames, itemTypes);
return compositeType;
} catch (final OpenDataException e) {
throw new RuntimeException("Unable to create CompositeType for "
+ this, e);
}
}
EventLoop.java 文件源码
项目:vscrawler
阅读 30
收藏 0
点赞 0
评论 0
public void offerEvent(final Event event) {
if (!isRunning.get()) {
log.warn("程序已停止");
return;
}
if (!allHandlers.containsKey(event.getTopic()) || allHandlers.get(event.getTopic()).size() < 0) {
log.debug("cannot find handle for event:{}", event.getTopic());
return;
}
if (event.isSync()) {
disPatch(event);
return;
}
if (event.isCleanExpire()) {
eventQueue.removeAll(Collections2.filter(eventQueue, new Predicate<Event>() {
@Override
public boolean apply(Event input) {
return StringUtils.equals(input.getTopic(), event.getTopic());
}
}));
}
eventQueue.put(event);
}
MapSideDataCollectOperation.java 文件源码
项目:Elasticsearch
阅读 26
收藏 0
点赞 0
评论 0
private Collection<Runnable> collectors2Runnables(Collection<CrateCollector> collectors) {
return Collections2.transform(collectors, new Function<CrateCollector, Runnable>() {
@Override
public Runnable apply(final CrateCollector collector) {
return new Runnable() {
@Override
public void run() {
collector.doCollect();
}
};
}
});
}
StacksService.java 文件源码
项目:redirector
阅读 34
收藏 0
点赞 0
评论 0
List<PathItem> getFlavorsPathItems(Map<XreStackPath, Integer> stackToNodesCount, Map<XreStackPath, Integer> whitelistedStackToNodesCount) {
Map<String, Integer> flavorToCount = getFlavorToCountMap(stackToNodesCount);
final Map<String, Integer> flavorToWhitelistedCount = getFlavorToCountMap(whitelistedStackToNodesCount);
return Lists.newArrayList(Collections2.transform(flavorToCount.entrySet(), new Function<Map.Entry<String, Integer>, PathItem>() {
@Override
public PathItem apply(Map.Entry<String, Integer> input) {
String flavor = input.getKey();
int count = input.getValue();
int whitelistedCount = flavorToWhitelistedCount.containsKey(flavor) ? flavorToWhitelistedCount.get(flavor) : 0;
return new PathItem(flavor, count, whitelistedCount);
}
}));
}
AbstractTask.java 文件源码
项目:Reer
阅读 31
收藏 0
点赞 0
评论 0
private Collection<ContextAwareTaskAction> transformToContextAwareTaskActions(Collection<Object> c) {
return Collections2.transform(c, new Function<Object, ContextAwareTaskAction>() {
public ContextAwareTaskAction apply(@Nullable Object input) {
return wrap((Action<? super Task>) input);
}
});
}
ViewChanges.java 文件源码
项目:morf
阅读 30
收藏 0
点赞 0
评论 0
/**
* Construct a description of view changes based on the supplied drop and deploy requirements
* together with some dependency analysis.
*
* <p>The drop set is expanded based on dependency analysis: any view that depends on a dropped
* view will also be dropped.</p>
*
* <p>The deployment set is expanded only to include the items that are added to the drop set -
* i.e. if we determine that a view needs to be recreated because a dependencies is dropped,
* then it will be added to both the drop and deploy sets. Views will not be added to the
* deploy set based on dependency analysis - it is assumed that all missing views will
* already be in the deploy set.</p>
*
* <p>All parameters may be immutable.</p>
*
* @param allViews all the views as defined in the codeset and bound in to the application. This is the 'source of truth' as to which views are available.
* @param viewsToDrop Views which should be dropped from the current schema. Caller must ensure names are unique within the collection.
* @param viewsToDeploy Views which should be deployed from the target schema. Caller must ensure names are unique within the collection.
*/
public ViewChanges(Collection<View> allViews, Collection<View> viewsToDrop, Collection<View> viewsToDeploy) {
super();
// -- Store our dependency information as we may need to pass it on...
//
this.allViews = allViews;
// -- Work with sets of strings internally, we switch back to views when we return ordered lists...
//
this.knownSet = newHashSet(Collections2.transform(allViews, viewToName()));
this.dropSet = newHashSet(correctCase(Collections2.transform(viewsToDrop, viewToName())));
this.deploySet = newHashSet(Collections2.transform(viewsToDeploy, viewToName()));
// -- Maintain an index of name to view so we can convert back. Must contain allViews + viewsToDrop for obsolete views...
//
viewIndex.putAll(uniqueIndex(viewsToDrop, viewToName()));
viewIndex.putAll(uniqueIndex(allViews, viewToName())); // known views take precedence as we have more complete info
// -- Perform a topological sort of all dependent views (based on bound in views, not the contents of the DB)...
//
viewCreationOrder = topoSortViews(allViews, viewIndex);
// -- Add any obsolete views back into the order in an arbitrary position (they need to be dropped
// but we have no dependency information to indicate where)...
//
viewCreationOrder.addAll(Sets.difference(newHashSet(this.dropSet), newHashSet(this.knownSet)));
}
SurfacesOffsetsExtractor.java 文件源码
项目:empiria.player
阅读 30
收藏 0
点赞 0
评论 0
public Collection<Integer> extractTopOffsets(ConnectionItems items) {
return Collections2.transform(items.getAllItems(), new Function<ConnectionItem, Integer>() {
@Override
@Nullable
public Integer apply(@Nullable ConnectionItem ci) {
return ci.getOffsetTop();
}
});
}
SurfacesOffsetsExtractor.java 文件源码
项目:empiria.player
阅读 27
收藏 0
点赞 0
评论 0
public Collection<Integer> extractBottomOffsets(ConnectionItems items) {
return Collections2.transform(items.getAllItems(), new Function<ConnectionItem, Integer>() {
@Override
@Nullable
public Integer apply(@Nullable ConnectionItem ci) {
return ci.getOffsetTop() + ci.getHeight();
}
});
}
SurfacesOffsetsExtractor.java 文件源码
项目:empiria.player
阅读 37
收藏 0
点赞 0
评论 0
public Collection<Integer> extractRightOffsets(ConnectionItems items) {
return Collections2.transform(items.getAllItems(), new Function<ConnectionItem, Integer>() {
@Override
@Nullable
public Integer apply(@Nullable ConnectionItem ci) {
return ci.getOffsetLeft() + ci.getWidth();
}
});
}
ResponseAnswerGrouper.java 文件源码
项目:empiria.player
阅读 82
收藏 0
点赞 0
评论 0
private Collection<GroupedAnswer> findAllGroupedAnswersByValue(final String value) {
Collection<GroupedAnswer> answersWithValue = Collections2.filter(groupedAnswers, new Predicate<GroupedAnswer>() {
@Override
public boolean apply(GroupedAnswer groupedAnswer) {
return value.equals(groupedAnswer.getValue());
}
});
return answersWithValue;
}
StoragePartition.java 文件源码
项目:athena
阅读 35
收藏 0
点赞 0
评论 0
/**
* Attempts to join the partition as a new member.
* @return future that is completed after the operation is complete
*/
private CompletableFuture<Void> joinCluster() {
Set<NodeId> otherMembers = partition.getMembers()
.stream()
.filter(nodeId -> !nodeId.equals(localNodeId))
.collect(Collectors.toSet());
StoragePartitionServer server = new StoragePartitionServer(toAddress(localNodeId),
this,
serializer,
() -> new CopycatTransport(CopycatTransport.Mode.SERVER,
partition.getId(),
messagingService),
logFolder);
return server.join(Collections2.transform(otherMembers, this::toAddress)).thenRun(() -> this.server = server);
}
ViewChanges.java 文件源码
项目:morf
阅读 28
收藏 0
点赞 0
评论 0
/**
* @param extraViewsToDeploy Additional views to deploy
* @return a new {@link ViewChanges} which also deploys the specified views.
*/
public ViewChanges deployingAlso(Collection<View> extraViewsToDeploy) {
Set<String> extraViewNames = ImmutableSet.copyOf(Collections2.transform(extraViewsToDeploy, viewToName()));
return new ViewChanges(allViews,
dropSet,
Sets.union(deploySet, extraViewNames),
viewIndex);
}
IdentityProviderResource.java 文件源码
项目:verify-hub
阅读 37
收藏 0
点赞 0
评论 0
@GET
@Path(Urls.ConfigUrls.ENABLED_IDENTITY_PROVIDERS_PARAM_PATH)
@Timed
@Deprecated
public Collection<String> getEnabledIdentityProviderEntityIdsPathParam(
@PathParam(Urls.ConfigUrls.ENTITY_ID_PATH_PARAM) final Optional<String> transactionEntityId) {
Collection<IdentityProviderConfigEntityData> matchingIdps = getIdentityProviderConfigEntityData(transactionEntityId);
return Collections2.transform(matchingIdps, new IdpEntityIdExtractor());
}
IdpPredicateFactoryTest.java 文件源码
项目:verify-hub
阅读 32
收藏 0
点赞 0
评论 0
@Test
public void createPredicatesForTransactionEntityAndLoA_shouldNotIncludeExtraPredicate() throws Exception {
Set<Predicate<IdentityProviderConfigEntityData>> predicates = idpPredicateFactory.createPredicatesForTransactionEntityAndLoa(TRANSACTION_ENTITY, LEVEL_OF_ASSURANCE);
Predicate<Predicate> findEnabled = input -> input instanceof EnabledIdpPredicate;
Predicate<Predicate> findOnboarding = input -> input instanceof OnboardingIdpPredicate;
Predicate<Predicate> supportedLoa = input -> input instanceof SupportedLoaIdpPredicate;
assertThat(predicates).hasSize(3);
assertThat(Collections2.filter(predicates, findEnabled)).hasSize(1);
assertThat(Collections2.filter(predicates, findOnboarding)).hasSize(1);
assertThat(Collections2.filter(predicates, supportedLoa)).hasSize(1);
}
IdpPredicateFactoryTest.java 文件源码
项目:verify-hub
阅读 31
收藏 0
点赞 0
评论 0
@Test
public void createPredicatesForTransactionEntity_shouldIncludeTransactionEntityPredicateWhenTransactionEntityIdIsProvided() throws Exception {
Set<Predicate<IdentityProviderConfigEntityData>> predicates =
idpPredicateFactory.createPredicatesForTransactionEntity(ofNullable(TRANSACTION_ENTITY));
Predicate<Predicate> findEnabled = input -> {
if(!(input instanceof OnboardingForTransactionEntityPredicate)){
return false;
}
return ((OnboardingForTransactionEntityPredicate)input).getTransactionEntity().equals(TRANSACTION_ENTITY);
};
assertThat(Collections2.filter(predicates, findEnabled)).hasSize(1);
}