private static void cacheMethod(Map<Class<? extends Annotation>, Method> cache, Method[] methods, Class<? extends Annotation> filter) { List<Method> methodList = Stream.of(methods) .filter(method -> method.isAnnotationPresent(filter)) .collect(Collectors.toList()); if (methodList.size() == 1) { cache.put(filter, methodList.get(0)); } else if (methodList.size() > 1) { throw new RuntimeException("Duplicate annotation @" + filter.getSimpleName() + " in class: " + methodList.get(0).getDeclaringClass().getName()); } }
/** * Returns the topmost interface that extends Remote for a given * class - if one exists. * @param testClass the class to be tested * @return the topmost interface that extends Remote, or null if there * is none. */ public Class<?> getRemoteInterface(Class<?> testClass) { return Stream.of(testClass.getInterfaces()) .filter(Remote.class::isAssignableFrom).findFirst().orElse(null); }
@SuppressWarnings("unchecked") @Override public Optional<? extends ExecutableMethod<?, ?>> findFirst() { return Stream.of(functions, suppliers, consumers, biFunctions) .map(all -> { Collection<ExecutableMethod<?, ?>> values = all.values(); return values.stream().findFirst(); }).filter(Optional::isPresent) .map(Optional::get) .findFirst(); }
@Override public Result apply(SemiJoinNode semiJoinNode, Captures captures, Context context) { Set<Symbol> requiredFilteringSourceInputs = Streams.concat( Stream.of(semiJoinNode.getFilteringSourceJoinSymbol()), semiJoinNode.getFilteringSourceHashSymbol().map(Stream::of).orElse(Stream.empty())) .collect(toImmutableSet()); return restrictOutputs(context.getIdAllocator(), semiJoinNode.getFilteringSource(), requiredFilteringSourceInputs) .map(newFilteringSource -> semiJoinNode.replaceChildren(ImmutableList.of(semiJoinNode.getSource(), newFilteringSource))) .map(Result::ofPlanNode) .orElse(Result.empty()); } }
private static void cacheMethod(Map<Class<? extends Annotation>, Method> cache, Method[] methods, Class<? extends Annotation> filter) { List<Method> methodList = Stream.of(methods) .filter(method -> method.isAnnotationPresent(filter)) .collect(Collectors.toList()); if (methodList.size() == 1) { cache.put(filter, methodList.get(0)); } else if (methodList.size() > 1) { throw new RuntimeException("Duplicate annotation @" + filter.getSimpleName() + " in class: " + methodList.get(0).getDeclaringClass().getName()); } }
@Override public List<SchemaTableName> listTables(ConnectorSession session, String schemaNameOrNull) { if (schemaNameOrNull == null) { return Stream.of(AtopTable.values()) .map(table -> new SchemaTableName(environment, table.getName())) .collect(Collectors.toList()); } if (!listSchemaNames(session).contains(schemaNameOrNull)) { return ImmutableList.of(); } return Stream.of(AtopTable.values()) .map(table -> new SchemaTableName(schemaNameOrNull, table.getName())) .collect(Collectors.toList()); }
private static String buildDirectoryProjectRelativePath(Map<String, String> pathByModuleKey, ComponentDto c, ComponentDto parentModule) { String moduleProjectRelativePath = buildModuleProjectRelativePath(pathByModuleKey, parentModule); return Stream.of(moduleProjectRelativePath, c.path()) .map(StringUtils::trimToNull) .filter(s -> s != null && !"/".equals(s)) .collect(Collectors.joining("/")); }
private Stream<CompilationMessage> validateConstructor( Element extensionClass ) { Optional<ExecutableElement> publicNoArgConstructor = constructorsIn( extensionClass.getEnclosedElements() ).stream() .filter( c -> c.getModifiers().contains( Modifier.PUBLIC ) ) .filter( c -> c.getParameters().isEmpty() ).findFirst(); if ( !publicNoArgConstructor.isPresent() ) { return Stream.of( new ExtensionMissingPublicNoArgConstructor( extensionClass, "Extension class %s should contain a public no-arg constructor, none found.", extensionClass ) ); } return Stream.empty(); } }
private void validatePullRequestParamsWhenPluginAbsent(List<String> validationMessages) { Stream.of(PULL_REQUEST_KEY, PULL_REQUEST_BRANCH, PULL_REQUEST_BASE) .filter(param -> nonNull(settings.get(param).orElse(null))) .forEach(param -> validationMessages.add(format("To use the property \"%s\", the branch plugin is required but not installed. " + "See the documentation of branch support: %s.", param, BRANCHES_DOC_LINK))); }