public static boolean parameterTypesMatch(Class<?>[] candidateParamTypes, Class<?>... desiredParameterTypes) { boolean match = candidateParamTypes.length == desiredParameterTypes.length; for (int i = 0; i < candidateParamTypes.length && match; i++) { Class<?> candidateType = candidateParamTypes[i].isPrimitive() && !desiredParameterTypes[i].isPrimitive() ? PRIMATIVES_TO_WRAPPERS.get(candidateParamTypes[i]) : candidateParamTypes[i]; match = candidateType.isAssignableFrom(desiredParameterTypes[i]); } return match; }
@Override public MutableMap<K, RichIterable<V>> toMap() { return (MutableMap<K, RichIterable<V>>) (MutableMap<?, ?>) this.map.toMap(); }
@Override public Map<String,URLAccessRule> urlAccessRules() { return urlAccessRules.castToMap(); }
private Pair<String, Procedure<String[]>> getDeployCommand(String[] args, Runnable exitFailureMethod) { if (args.length == 0) { usage(); exitFailureMethod.run(); } Procedure<String[]> command = commandMap.get(args[0]); if (command == null) { System.out.println("No command w/ name " + args[0] + " has been defined in this distribution: " + commandMap.keysView().makeString("[", ", ", "]")); System.out.println("See the usage for more details"); usage(); exitFailureMethod.run(); } return Tuples.pair(args[0], command); }
public void mergeAttributes(TextMarkupDocumentSection other) { if (other == null) { return; } this.attrs = this.attrs.toMap() .withAllKeyValues(other.attrs.select(new Predicate2<String, String>() { @Override public boolean accept(String key, String value) { return !TextMarkupDocumentSection.this.attrs.contains(key); } }).keyValuesView()) .toImmutable(); this.toggles = this.toggles.newWithAll(other.toggles.select(new Predicate<String>() { @Override public boolean accept(String key) { return !TextMarkupDocumentSection.this.toggles.contains(key); } })); }
@Override public void value(T each) { this.intStatisticsMap.forEachKeyValue((key, value) -> value.accept(this.intFunctionsMap.get(key).intValueOf(each))); this.longStatisticsMap.forEachKeyValue((key, value) -> value.accept(this.longFunctionsMap.get(key).longValueOf(each))); this.doubleStatisticsMap.forEachKeyValue((key, value) -> value.accept(this.doubleFunctionsMap.get(key).doubleValueOf(each))); }
public static <K, V> Pair<K, V> detect( Map<K, V> map, Predicate2<? super K, ? super V> predicate) { if (map == null) { throw new IllegalArgumentException("Cannot perform a detect on null"); } if (map instanceof ImmutableMap || map instanceof MutableMap) { RichIterable<Pair<K, V>> entries; if (map instanceof ImmutableMap) { entries = ((ImmutableMap<K, V>) map).keyValuesView(); } else { entries = LazyIterate.adapt(map.entrySet()).collect(AbstractImmutableEntry.getPairFunction()); } return entries.detect(each -> predicate.accept(each.getOne(), each.getTwo())); } for (Map.Entry<K, V> entry : map.entrySet()) { if (predicate.accept(entry.getKey(), entry.getValue())) { return Tuples.pairFrom(entry); } } return null; }
@Override public <R> ImmutableBiMap<K, R> collectValues(Function2<? super K, ? super V, ? extends R> function) { ImmutableMap<K, R> result = this.delegate.collectValues(function); return BiMaps.immutable.withAll(result); }
@Override public <VV> ImmutableBag<VV> flatCollect(Function<? super V, ? extends Iterable<VV>> function) { return this.delegate.flatCollect(function); }
@Override public ImmutableSet<V> select(Predicate<? super V> predicate) { return this.delegate.select(predicate, Sets.mutable.empty()).toImmutable(); }
public Platform valueOf(String dbPlatformStr) { try { ImmutableHierarchicalConfiguration platformConfig = platformConfigs.get(dbPlatformStr); String resolvedDbPlatformClass = null; if (platformConfig != null) { resolvedDbPlatformClass = platformConfig.getString("class"); } if (resolvedDbPlatformClass == null) { resolvedDbPlatformClass = dbPlatformStr; } return (Platform) Class.forName(resolvedDbPlatformClass).newInstance(); } catch (InstantiationException e) { throw new DeployerRuntimeException(e); } catch (IllegalAccessException e) { throw new DeployerRuntimeException(e); } catch (ClassNotFoundException e) { throw new DeployerRuntimeException("Could not find platform named " + dbPlatformStr + "; no class found and name was not in the list of default platform strings: " + platformConfigs.keysView()); } }
public void mergeAttributes(TextMarkupDocumentSection other) { if (other == null) { return; } this.attrs = this.attrs.toMap() .withAllKeyValues(other.attrs.select(new Predicate2<String, String>() { @Override public boolean accept(String key, String value) { return !TextMarkupDocumentSection.this.attrs.contains(key); } }).keyValuesView()) .toImmutable(); this.toggles = this.toggles.newWithAll(other.toggles.select(new Predicate<String>() { @Override public boolean accept(String key) { return !TextMarkupDocumentSection.this.toggles.contains(key); } })); }
public static <K, V> Pair<K, V> detect( Map<K, V> map, Predicate2<? super K, ? super V> predicate) { if (map == null) { throw new IllegalArgumentException("Cannot perform a detect on null"); } if (map instanceof ImmutableMap || map instanceof MutableMap) { RichIterable<Pair<K, V>> entries; if (map instanceof ImmutableMap) { entries = ((ImmutableMap<K, V>) map).keyValuesView(); } else { entries = LazyIterate.adapt(map.entrySet()).collect(AbstractImmutableEntry.getPairFunction()); } return entries.detect(each -> predicate.accept(each.getOne(), each.getTwo())); } for (Map.Entry<K, V> entry : map.entrySet()) { if (predicate.accept(entry.getKey(), entry.getValue())) { return Tuples.pairFrom(entry); } } return null; }
@Override public <R> ImmutableBiMap<K, R> collectValues(Function2<? super K, ? super V, ? extends R> function) { ImmutableMap<K, R> result = this.delegate.collectValues(function); return BiMaps.immutable.withAll(result); }
@Override public <VV> ImmutableBag<VV> flatCollect(Function<? super V, ? extends Iterable<VV>> function) { return this.delegate.flatCollect(function); }
@Override public ImmutableSet<V> select(Predicate<? super V> predicate) { return this.delegate.select(predicate, Sets.mutable.empty()).toImmutable(); }
public static boolean parameterTypesMatch(Class<?>[] candidateParamTypes, Class<?>... desiredParameterTypes) { boolean match = candidateParamTypes.length == desiredParameterTypes.length; for (int i = 0; i < candidateParamTypes.length && match; i++) { Class<?> candidateType = candidateParamTypes[i].isPrimitive() && !desiredParameterTypes[i].isPrimitive() ? PRIMATIVES_TO_WRAPPERS.get(candidateParamTypes[i]) : candidateParamTypes[i]; match = candidateType.isAssignableFrom(desiredParameterTypes[i]); } return match; }
@Override public MutableMap<K, RichIterable<V>> toMap() { return (MutableMap<K, RichIterable<V>>) (MutableMap<?, ?>) this.map.toMap(); }
@Override public Collection<V> values() { return this.delegate.castToMap().values(); }
public Platform valueOf(String dbPlatformStr) { try { ImmutableHierarchicalConfiguration platformConfig = platformConfigs.get(dbPlatformStr); String resolvedDbPlatformClass = null; if (platformConfig != null) { resolvedDbPlatformClass = platformConfig.getString("class"); } if (resolvedDbPlatformClass == null) { resolvedDbPlatformClass = dbPlatformStr; } return (Platform) Class.forName(resolvedDbPlatformClass).newInstance(); } catch (InstantiationException e) { throw new DeployerRuntimeException(e); } catch (IllegalAccessException e) { throw new DeployerRuntimeException(e); } catch (ClassNotFoundException e) { throw new DeployerRuntimeException("Could not find platform named " + dbPlatformStr + "; no class found and name was not in the list of default platform strings: " + platformConfigs.keysView()); } }