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


Java CollectionUtils类代码示例

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


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

示例1: generatePCHFile

import org.gradle.util.CollectionUtils; //导入依赖的package包/类
public static void generatePCHFile(List<String> headers, File headerFile) {
    if (!headerFile.getParentFile().exists()) {
        headerFile.getParentFile().mkdirs();
    }

    try {
        FileUtils.writeLines(headerFile, CollectionUtils.collect(headers, new Transformer<String, String>() {
            @Override
            public String transform(String header) {
                if (header.startsWith("<")) {
                    return "#include ".concat(header);
                } else {
                    return "#include \"".concat(header).concat("\"");
                }
            }
        }));
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:21,代码来源:PCHUtils.java

示例2: toInputBuilder

import org.gradle.util.CollectionUtils; //导入依赖的package包/类
private UnboundRuleInput.Builder toInputBuilder(ModelBinding binding) {
    ModelReference<?> reference = binding.getPredicate().getReference();
    UnboundRuleInput.Builder builder = UnboundRuleInput.type(reference.getType());
    ModelPath path;
    if (binding.isBound()) {
        builder.bound();
        path = binding.getNode().getPath();
    } else {
        path = reference.getPath();
        if (path != null) {
            builder.suggestions(CollectionUtils.stringize(suggestionsProvider.transform(path)));
        }
        ModelPath scope = reference.getScope();
        if (scope != null && !scope.equals(ModelPath.ROOT)) {
            builder.scope(scope.toString());
        }
    }
    if (path != null) {
        builder.path(path);
    }
    builder.description(reference.getDescription());
    return builder;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:24,代码来源:UnboundRulesProcessor.java

示例3: getContainerTypeDescription

import org.gradle.util.CollectionUtils; //导入依赖的package包/类
private String getContainerTypeDescription(Class<?> containerType, Collection<? extends Class<?>> creatableTypes) {
    StringBuilder sb = new StringBuilder(containerType.getName());
    if (creatableTypes.size() == 1) {
        @SuppressWarnings("ConstantConditions")
        String onlyType = Iterables.getFirst(creatableTypes, null).getName();
        sb.append("<").append(onlyType).append(">");
    } else {
        sb.append("<T>; where T is one of [");
        Joiner.on(", ").appendTo(sb, CollectionUtils.sort(Iterables.transform(creatableTypes, new Function<Class<?>, String>() {
            public String apply(Class<?> input) {
                return input.getName();
            }
        })));
        sb.append("]");
    }
    return sb.toString();
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:18,代码来源:ModelMapModelProjection.java

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

示例5: resolveAsRelativePath

import org.gradle.util.CollectionUtils; //导入依赖的package包/类
public String resolveAsRelativePath(Object path) {
    List<String> basePath = Arrays.asList(StringUtils.split(baseDir.getAbsolutePath(), "/" + File.separator));
    File targetFile = resolve(path);
    List<String> targetPath = new ArrayList<String>(Arrays.asList(StringUtils.split(targetFile.getAbsolutePath(),
            "/" + File.separator)));

    // Find and remove common prefix
    int maxDepth = Math.min(basePath.size(), targetPath.size());
    int prefixLen = 0;
    while (prefixLen < maxDepth && basePath.get(prefixLen).equals(targetPath.get(prefixLen))) {
        prefixLen++;
    }
    basePath = basePath.subList(prefixLen, basePath.size());
    targetPath = targetPath.subList(prefixLen, targetPath.size());

    for (int i = 0; i < basePath.size(); i++) {
        targetPath.add(0, "..");
    }
    if (targetPath.isEmpty()) {
        return ".";
    }
    return CollectionUtils.join(File.separator, targetPath);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:24,代码来源:BaseDirFileResolver.java

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

示例7: checkExpiration

import org.gradle.util.CollectionUtils; //导入依赖的package包/类
@Override
public DaemonExpirationResult checkExpiration() {
    Spec<DaemonInfo> spec = new Spec<DaemonInfo>() {
        @Override
        public boolean isSatisfiedBy(DaemonInfo daemonInfo) {
            return compatibilitySpec.isSatisfiedBy(daemonInfo.getContext());
        }
    };
    Collection<DaemonInfo> compatibleIdleDaemons = CollectionUtils.filter(daemon.getDaemonRegistry().getIdle(), spec);

    if (compatibleIdleDaemons.size() > 1) {
        return new DaemonExpirationResult(DaemonExpirationStatus.GRACEFUL_EXPIRE, EXPIRATION_REASON);
    } else {
        return DaemonExpirationResult.NOT_TRIGGERED;
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:17,代码来源:CompatibleDaemonExpirationStrategy.java

示例8: transform

import org.gradle.util.CollectionUtils; //导入依赖的package包/类
public ClassLoaderDetails transform(ClassLoader classLoader) {
    ClassLoaderSpecVisitor visitor = new ClassLoaderSpecVisitor(classLoader);
    visitor.visit(classLoader);

    if (visitor.spec == null) {
        if (visitor.classPath == null) {
            visitor.spec = SystemClassLoaderSpec.INSTANCE;
        } else {
            visitor.spec = new VisitableURLClassLoader.Spec(CollectionUtils.toList(visitor.classPath));
        }
    }

    UUID uuid = UUID.randomUUID();
    ClassLoaderDetails details = new ClassLoaderDetails(uuid, visitor.spec);
    for (ClassLoader parent : visitor.parents) {
        details.parents.add(getDetails(parent));
    }
    return details;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:20,代码来源:DefaultPayloadClassLoaderRegistry.java

示例9: toProviderInternalJvmTestRequest

import org.gradle.util.CollectionUtils; //导入依赖的package包/类
private static List<InternalJvmTestRequest> toProviderInternalJvmTestRequest(Collection<InternalJvmTestRequest> internalJvmTestRequests, Collection<String> testClassNames) {
    // handle consumer < 2.7
    if(internalJvmTestRequests.isEmpty()){
        return CollectionUtils.collect(testClassNames, new Transformer<InternalJvmTestRequest, String>() {
            @Override
            public InternalJvmTestRequest transform(String testClass) {
                return new ProviderInternalJvmTestRequest(testClass, null);
            }
        });
    } else {
        return CollectionUtils.collect(internalJvmTestRequests, new Transformer<InternalJvmTestRequest, InternalJvmTestRequest>() {
            @Override
            public InternalJvmTestRequest transform(InternalJvmTestRequest internalTestMethod) {
                return new ProviderInternalJvmTestRequest(internalTestMethod.getClassName(), internalTestMethod.getMethodName());
            }
        });
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:19,代码来源:TestExecutionRequestAction.java

示例10: configureCompileTaskCommon

import org.gradle.util.CollectionUtils; //导入依赖的package包/类
private void configureCompileTaskCommon(AbstractNativeCompileTask task, final NativeBinarySpecInternal binary, final LanguageSourceSetInternal sourceSet) {
    task.setToolChain(binary.getToolChain());
    task.setTargetPlatform(binary.getTargetPlatform());
    task.setPositionIndependentCode(binary instanceof SharedLibraryBinarySpec);

    task.includes(((HeaderExportingSourceSet) sourceSet).getExportedHeaders().getSourceDirectories());
    task.includes(new Callable<List<FileCollection>>() {
        public List<FileCollection> call() {
            Collection<NativeDependencySet> libs = binary.getLibs((DependentSourceSet) sourceSet);
            return CollectionUtils.collect(libs, new Transformer<FileCollection, NativeDependencySet>() {
                public FileCollection transform(NativeDependencySet original) {
                    return original.getIncludeRoots();
                }
            });
        }
    });

    for (String toolName : languageTransform.getBinaryTools().keySet()) {
        Tool tool = binary.getToolByName(toolName);
        if (tool instanceof PreprocessingTool) {
            task.setMacros(((PreprocessingTool) tool).getMacros());
        }

        task.setCompilerArgs(tool.getArgs());
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:27,代码来源:CompileTaskConfig.java

示例11: resolveAndFilterSourceFiles

import org.gradle.util.CollectionUtils; //导入依赖的package包/类
private void resolveAndFilterSourceFiles(final GroovyJavaJointCompileSpec spec) {
    final List<String> fileExtensions = CollectionUtils.collect(spec.getGroovyCompileOptions().getFileExtensions(), new Transformer<String, String>() {
        @Override
        public String transform(String extension) {
            return '.' + extension;
        }
    });
    FileCollection filtered = spec.getSource().filter(new Spec<File>() {
        public boolean isSatisfiedBy(File element) {
            for (String fileExtension : fileExtensions) {
                if (hasExtension(element, fileExtension)) {
                    return true;
                }
            }
            return false;
        }
    });

    spec.setSource(new SimpleFileCollection(filtered.getFiles()));
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:21,代码来源:NormalizingGroovyCompiler.java

示例12: visitTasks

import org.gradle.util.CollectionUtils; //导入依赖的package包/类
private static <P, T> List<T> visitTasks(Visitor<P, T> visitor, ProjectAndTaskFilter filter, ProjectView project,
                                         int startingIndex, P userProjectObject, Comparator<TaskView> taskSorter) {
    List<T> taskObjects = new ArrayList<T>();
    List<TaskView> tasks = CollectionUtils.sort(project.getTasks(), taskSorter); //make a copy because we're going to sort them

    Iterator<TaskView> iterator = tasks.iterator();
    int index = startingIndex;
    while (iterator.hasNext()) {
        TaskView task = iterator.next();
        if (filter.doesAllowTask(task)) {
            T taskObject = visitor.visitTask(task, index, project, userProjectObject);
            taskObjects.add(taskObject);
        }
        index++;
    }

    return taskObjects;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:19,代码来源:TaskTreePopulationVisitor.java

示例13: listPluginRequests

import org.gradle.util.CollectionUtils; //导入依赖的package包/类
public List<PluginRequest> listPluginRequests() {
    List<PluginRequest> pluginRequests = collect(specs, new Transformer<PluginRequest, DependencySpecImpl>() {
        public PluginRequest transform(DependencySpecImpl original) {
            return new DefaultPluginRequest(original.id, original.version, original.apply, original.lineNumber, scriptSource);
        }
    });

    ListMultimap<PluginId, PluginRequest> groupedById = CollectionUtils.groupBy(pluginRequests, new Transformer<PluginId, PluginRequest>() {
        public PluginId transform(PluginRequest pluginRequest) {
            return pluginRequest.getId();
        }
    });

    // Check for duplicates
    for (PluginId key : groupedById.keySet()) {
        List<PluginRequest> pluginRequestsForId = groupedById.get(key);
        if (pluginRequestsForId.size() > 1) {
            PluginRequest first = pluginRequests.get(0);
            PluginRequest second = pluginRequests.get(1);

            InvalidPluginRequestException exception = new InvalidPluginRequestException(second, "Plugin with id '" + key + "' was already requested at line " + first.getLineNumber());
            throw new LocationAwareException(exception, second.getScriptDisplayName(), second.getLineNumber());
        }
    }
    return pluginRequests;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:27,代码来源:PluginRequestCollector.java

示例14: populateProperties

import org.gradle.util.CollectionUtils; //导入依赖的package包/类
private Map<String, String> populateProperties() {
    HashMap<String, String> properties = new HashMap<String, String>();
    String baseDir = new File(".").getAbsolutePath();
    properties.put("ivy.default.settings.dir", baseDir);
    properties.put("ivy.basedir", baseDir);

    Set<String> propertyNames = CollectionUtils.collect(System.getProperties().entrySet(), new Transformer<String, Map.Entry<Object, Object>>() {
        public String transform(Map.Entry<Object, Object> entry) {
            return entry.getKey().toString();
        }
    });

    for (String property : propertyNames) {
        properties.put(property, System.getProperty(property));
    }
    return properties;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:18,代码来源:IvyXmlModuleDescriptorParser.java

示例15: methodMissing

import org.gradle.util.CollectionUtils; //导入依赖的package包/类
public Object methodMissing(String name, Object args) {
    Object[] argsArray = (Object[]) args;
    Configuration configuration = configurationContainer.findByName(name);
    if (configuration == null) {
        throw new MissingMethodException(name, this.getClass(), argsArray);
    }

    List<?> normalizedArgs = CollectionUtils.flattenCollections(argsArray);
    if (normalizedArgs.size() == 2 && normalizedArgs.get(1) instanceof Closure) {
        return doAdd(configuration, normalizedArgs.get(0), (Closure) normalizedArgs.get(1));
    } else if (normalizedArgs.size() == 1) {
        return doAdd(configuration, normalizedArgs.get(0), null);
    } else {
        for (Object arg : normalizedArgs) {
            doAdd(configuration, arg, null);
        }
        return null;
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:20,代码来源:DefaultDependencyHandler.java


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