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


Java CollectionUtils.findFirst方法代码示例

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


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

示例1: determineGcStrategy

import org.gradle.util.CollectionUtils; //导入方法依赖的package包/类
private static GarbageCollectorMonitoringStrategy determineGcStrategy() {
    JVMStrategy jvmStrategy = JVMStrategy.current();

    final List<String> garbageCollectors = CollectionUtils.collect(ManagementFactory.getGarbageCollectorMXBeans(), new Transformer<String, GarbageCollectorMXBean>() {
        @Override
        public String transform(GarbageCollectorMXBean garbageCollectorMXBean) {
            return garbageCollectorMXBean.getName();
        }
    });
    GarbageCollectorMonitoringStrategy gcStrategy = CollectionUtils.findFirst(jvmStrategy.getGcStrategies(), new Spec<GarbageCollectorMonitoringStrategy>() {
        @Override
        public boolean isSatisfiedBy(GarbageCollectorMonitoringStrategy strategy) {
            return garbageCollectors.contains(strategy.getGarbageCollectorName());
        }
    });

    if (gcStrategy == null) {
        LOGGER.info("Unable to determine a garbage collection monitoring strategy for " + jvmStrategy.toString());
        return GarbageCollectorMonitoringStrategy.UNKNOWN;
    } else {
        return gcStrategy;
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:24,代码来源:GarbageCollectionMonitor.java

示例2: run

import org.gradle.util.CollectionUtils; //导入方法依赖的package包/类
@Override
public void run() {
    List<GarbageCollectorMXBean> garbageCollectorMXBeans = ManagementFactory.getGarbageCollectorMXBeans();
    GarbageCollectorMXBean garbageCollectorMXBean = CollectionUtils.findFirst(garbageCollectorMXBeans, new Spec<GarbageCollectorMXBean>() {
        @Override
        public boolean isSatisfiedBy(GarbageCollectorMXBean mbean) {
            return mbean.getName().equals(garbageCollector);
        }
    });

    List<MemoryPoolMXBean> memoryPoolMXBeans = ManagementFactory.getMemoryPoolMXBeans();
    for (MemoryPoolMXBean memoryPoolMXBean : memoryPoolMXBeans) {
        String pool = memoryPoolMXBean.getName();
        if (memoryPools.contains(pool)) {
            GarbageCollectionEvent event = new GarbageCollectionEvent(System.currentTimeMillis(), memoryPoolMXBean.getCollectionUsage(), garbageCollectorMXBean.getCollectionCount());
            events.get(pool).slideAndInsert(event);
        }
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:20,代码来源:GarbageCollectionCheck.java

示例3: convert

import org.gradle.util.CollectionUtils; //导入方法依赖的package包/类
@Override
public void convert(CharSequence notation, NotationConvertResult<? super T> result) throws TypeConversionException {
    final String enumString = notation.toString();
    List<? extends T> enumConstants = Arrays.asList(type.getEnumConstants());
    T match = CollectionUtils.findFirst(enumConstants, new Spec<T>() {
        public boolean isSatisfiedBy(T enumValue) {
            return enumValue.name().equalsIgnoreCase(enumString);
        }
    });
    if (match == null) {
        throw new TypeConversionException(
                String.format("Cannot convert string value '%s' to an enum value of type '%s' (valid case insensitive values: %s)",
                        enumString, type.getName(), Joiner.on(", ").join(CollectionUtils.collect(Arrays.asList(type.getEnumConstants()), new Transformer<String, T>() {
                            @Override
                            public String transform(T t) {
                                return t.name();
                            }
                        }))
                )
        );
    }
    result.converted(match);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:24,代码来源:EnumFromCharSequenceNotationParser.java

示例4: resolveFromContainer

import org.gradle.util.CollectionUtils; //导入方法依赖的package包/类
private <T extends Platform> T resolveFromContainer(Class<T> type, PlatformRequirement platformRequirement) {
    final String target = platformRequirement.getPlatformName();

    NamedDomainObjectSet<T> allWithType = platforms.withType(type);
    T matching = CollectionUtils.findFirst(allWithType, new Spec<T>() {
        public boolean isSatisfiedBy(T element) {
            return element.getName().equals(target);
        }
    });

    if (matching == null) {
        throw new InvalidUserDataException(String.format("Invalid %s: %s", type.getSimpleName(), target));
    }
    return matching;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:16,代码来源:DefaultPlatformResolvers.java

示例5: findAllMethodsInternal

import org.gradle.util.CollectionUtils; //导入方法依赖的package包/类
private static List<Method> findAllMethodsInternal(Class<?> target, Spec<Method> predicate, MultiMap<String, Method> seen, List<Method> collector, boolean stopAtFirst) {
    for (final Method method : target.getDeclaredMethods()) {
        List<Method> seenWithName = seen.get(method.getName());
        Method override = CollectionUtils.findFirst(seenWithName, new Spec<Method>() {
            public boolean isSatisfiedBy(Method potentionOverride) {
                return potentionOverride.getName().equals(method.getName())
                        && Arrays.equals(potentionOverride.getParameterTypes(), method.getParameterTypes());
            }
        });


        if (override == null) {
            seenWithName.add(method);
            if (predicate.isSatisfiedBy(method)) {
                collector.add(method);
                if (stopAtFirst) {
                    return collector;
                }
            }
        }
    }

    Class<?> parent = target.getSuperclass();
    if (parent != null) {
        return findAllMethodsInternal(parent, predicate, seen, collector, stopAtFirst);
    }

    return collector;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:30,代码来源:JavaReflectionUtil.java

示例6: resolve

import org.gradle.util.CollectionUtils; //导入方法依赖的package包/类
@Override
public NativePlatform resolve(final PlatformRequirement platformRequirement) {
    return CollectionUtils.findFirst(nativePlatforms.defaultPlatformDefinitions(), new Spec<NativePlatform>() {
        @Override
        public boolean isSatisfiedBy(NativePlatform element) {
            return element.getName().equals(platformRequirement.getPlatformName());
        }
    });
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:10,代码来源:NativePlatformResolver.java

示例7: findEclipseProject

import org.gradle.util.CollectionUtils; //导入方法依赖的package包/类
private DefaultEclipseProject findEclipseProject(final Project project) {
    return CollectionUtils.findFirst(eclipseProjects, new Spec<DefaultEclipseProject>() {
        @Override
        public boolean isSatisfiedBy(DefaultEclipseProject element) {
            return element.getGradleProject().getPath().equals(project.getPath());
        }
    });
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:9,代码来源:EclipseModelBuilder.java

示例8: findEclipseProjectByName

import org.gradle.util.CollectionUtils; //导入方法依赖的package包/类
private DefaultEclipseProject findEclipseProjectByName(final String eclipseProjectName) {
    return CollectionUtils.findFirst(eclipseProjects, new Spec<DefaultEclipseProject>() {
        @Override
        public boolean isSatisfiedBy(DefaultEclipseProject element) {
            return element.getName().equals(eclipseProjectName);
        }
    });
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:9,代码来源:EclipseModelBuilder.java


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