Java Code Examples for org.gradle.api.specs.Spec#isSatisfiedBy()
The following examples show how to use
org.gradle.api.specs.Spec#isSatisfiedBy() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JavaReflectionUtil.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
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; }
Example 2
Source File: DexSplitTools.java From DexKnifePlugin with Apache License 2.0 | 5 votes |
private static boolean isAtMainDex( Map<String, Boolean> mainCls, String sMapCls, ClassFileTreeElement treeElement, Spec<FileTreeElement> asSpec, boolean logFilter) { boolean isRecommend = false; // adt推荐 if (mainCls != null) { Boolean value = mainCls.get(sMapCls); if (value != null) { isRecommend = value; } } // 全局过滤 boolean inGlobalFilter = asSpec != null && asSpec.isSatisfiedBy(treeElement); if (logFilter) { String ret; if (isRecommend && inGlobalFilter) { ret = "true"; } else if (isRecommend) { ret = "Recommend"; } else if (inGlobalFilter) { ret = "Global"; } else { ret = "false"; } String s = "AtMainDex: " + treeElement.getPath() + " [" + ret + "]"; if (isRecommend || inGlobalFilter) { System.err.println(s); } else { System.out.println(s); } } // 合并结果 return isRecommend || inGlobalFilter; }
Example 3
Source File: DefaultProjectRegistry.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public Set<T> findAll(Spec<? super T> constraint) { Set<T> matches = new HashSet<T>(); for (T project : projects.values()) { if (constraint.isSatisfiedBy(project)) { matches.add(project); } } return matches; }
Example 4
Source File: DefaultLenientConfiguration.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public Set<ResolvedDependency> getFirstLevelModuleDependencies(Spec<? super Dependency> dependencySpec) { Set<ResolvedDependency> matches = new LinkedHashSet<ResolvedDependency>(); for (Map.Entry<ModuleDependency, ResolvedDependency> entry : results.more().getFirstLevelDependencies().entrySet()) { if (dependencySpec.isSatisfiedBy(entry.getKey())) { matches.add(entry.getValue()); } } return matches; }
Example 5
Source File: EmbeddedDaemonRegistry.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private List<DaemonInfo> daemonInfosOfEntriesMatching(Spec<DaemonInfo> spec) { List<DaemonInfo> matches = new ArrayList<DaemonInfo>(); for (DaemonInfo daemonInfo : daemonInfos.values()) { if (spec.isSatisfiedBy(daemonInfo)) { matches.add(daemonInfo); } } return matches; }
Example 6
Source File: CollectionUtils.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public static <T> boolean every(Iterable<? extends T> things, Spec<? super T> predicate) { for (T thing : things) { if (!predicate.isSatisfiedBy(thing)) { return false; } } return true; }
Example 7
Source File: CollectionUtils.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public static <E> boolean replace(List<E> list, Spec<? super E> filter, Transformer<? extends E, ? super E> transformer) { boolean replaced = false; int i = 0; for (E it : list) { if (filter.isSatisfiedBy(it)) { list.set(i, transformer.transform(it)); replaced = true; } ++i; } return replaced; }
Example 8
Source File: CollectionUtils.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public static <T> T findFirst(Iterable<? extends T> source, Spec<? super T> filter) { for (T item : source) { if (filter.isSatisfiedBy(item)) { return item; } } return null; }
Example 9
Source File: JavaReflectionUtil.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
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; }
Example 10
Source File: DefaultProjectRegistry.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public Set<T> findAll(Spec<? super T> constraint) { Set<T> matches = new HashSet<T>(); for (T project : projects.values()) { if (constraint.isSatisfiedBy(project)) { matches.add(project); } } return matches; }
Example 11
Source File: DefaultLenientConfiguration.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public Set<ResolvedDependency> getFirstLevelModuleDependencies(Spec<? super Dependency> dependencySpec) { Set<ResolvedDependency> matches = new LinkedHashSet<ResolvedDependency>(); for (Map.Entry<ModuleDependency, ResolvedDependency> entry : results.more().getFirstLevelDependencies().entrySet()) { if (dependencySpec.isSatisfiedBy(entry.getKey())) { matches.add(entry.getValue()); } } return matches; }
Example 12
Source File: PersistentCachingPluginResolutionServiceClient.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private <K, V extends Response<?>> V maybeFetch(String operationName, final PersistentIndexedCache<K, V> cache, final K key, Factory<V> factory, Spec<? super V> shouldFetch) { V cachedValue = cacheAccess.useCache(operationName + " - read", new Factory<V>() { public V create() { return cache.get(key); } }); boolean fetch = cachedValue == null || shouldFetch.isSatisfiedBy(cachedValue); if (fetch) { return fetch(operationName, cache, key, factory); } else { return cachedValue; } }
Example 13
Source File: EmbeddedDaemonRegistry.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private List<DaemonInfo> daemonInfosOfEntriesMatching(Spec<DaemonInfo> spec) { List<DaemonInfo> matches = new ArrayList<DaemonInfo>(); for (DaemonInfo daemonInfo : daemonInfos.values()) { if (spec.isSatisfiedBy(daemonInfo)) { matches.add(daemonInfo); } } return matches; }
Example 14
Source File: CollectionUtils.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public static <T> boolean every(Iterable<? extends T> things, Spec<? super T> predicate) { for (T thing : things) { if (!predicate.isSatisfiedBy(thing)) { return false; } } return true; }
Example 15
Source File: CollectionUtils.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public static <E> boolean replace(List<E> list, Spec<? super E> filter, Transformer<? extends E, ? super E> transformer) { boolean replaced = false; int i = 0; for (E it : list) { if (filter.isSatisfiedBy(it)) { list.set(i, transformer.transform(it)); replaced = true; } ++i; } return replaced; }
Example 16
Source File: CollectionUtils.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public static <T> T findFirst(T[] source, Spec<? super T> filter) { for (T thing : source) { if (filter.isSatisfiedBy(thing)) { return thing; } } return null; }
Example 17
Source File: CollectionUtils.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public static <T> T findFirst(Iterable<? extends T> source, Spec<? super T> filter) { for (T item : source) { if (filter.isSatisfiedBy(item)) { return item; } } return null; }
Example 18
Source File: DirectoryFileTree.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
boolean isAllowed(FileTreeElement element, Spec<FileTreeElement> spec) { return spec.isSatisfiedBy(element); }
Example 19
Source File: DexSplitTools.java From DexKnifePlugin with Apache License 2.0 | 4 votes |
/** * get the maindexlist of android gradle plugin. * if enable ProGuard, return the mapped class. */ private static Map<String, Boolean> getRecommendMainDexClasses( File adtMainDexList, PatternSet mainDexPattern, boolean logFilter) throws Exception { if (adtMainDexList == null || !adtMainDexList.exists()) { System.err.println("DexKnife Warning: Android recommend Main dex is no exist."); return null; } HashMap<String, Boolean> mainCls = new HashMap<>(); BufferedReader reader = new BufferedReader(new FileReader(adtMainDexList)); ClassFileTreeElement treeElement = new ClassFileTreeElement(); Spec<FileTreeElement> asSpec = mainDexPattern != null ? getMaindexSpec(mainDexPattern) : null; String line, clsPath; while ((line = reader.readLine()) != null) { line = line.trim(); int clsPos = line.lastIndexOf(CLASS_SUFFIX); if (clsPos != -1) { boolean satisfiedBy = true; if (asSpec != null) { clsPath = line.substring(0, clsPos).replace('.', '/') + CLASS_SUFFIX; treeElement.setClassPath(clsPath); satisfiedBy = asSpec.isSatisfiedBy(treeElement); if (logFilter) { System.out.println("DexKnife-Suggest: [" + (satisfiedBy ? "Keep" : "Split") + "] " + clsPath); } } mainCls.put(line, satisfiedBy); } } reader.close(); if (mainCls.size() == 0) { mainCls = null; } return mainCls; }
Example 20
Source File: DirectoryFileTree.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
boolean isAllowed(FileTreeElement element, Spec<FileTreeElement> spec) { return spec.isSatisfiedBy(element); }