Refine search
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(); } }
public Stream<CompilationMessage> validateReturnType( ExecutableElement method ) { TypeMirror returnType = method.getReturnType(); if ( !allowedTypesValidator.test( returnType ) ) { return Stream.of( new ReturnTypeError( method, "Unsupported return type <%s> of function defined in <%s#%s>.", returnType, method.getEnclosingElement(), method.getSimpleName() ) ); } return Stream.empty(); }
private Stream<CompilationMessage> validateParameters( ExecutableElement resultMethod, Class<? extends Annotation> annotation ) { if ( !isValidAggregationSignature( resultMethod ) ) { return Stream.of( new AggregationError( resultMethod, "@%s usage error: method should be public, non-static and without parameters.", annotation.getSimpleName() ) ); } return Stream.empty(); }
/** * Returns a {@link Stream} wrapper for the value. The resulting stream contains either the value if a this value * {@link #hasValue() has a value} or it is empty if the value is empty. * * @return {@link Stream} wrapper for the value. */ public Stream<V> stream() { if (hasValue()) { return Stream.of(value); } return Stream.empty(); } }
public static Stream<Field> traverseFields(Class<?> clazz) { final Class<?> parent = clazz.getSuperclass(); final Stream<Field> inherited; if (parent != null) { inherited = traverseFields(parent); } else { inherited = Stream.empty(); } return Stream.concat(inherited, Stream.of(clazz.getDeclaredFields())); }
private static Stream<CompilationMessage> validateNonContextField( VariableElement field ) { Set<Modifier> modifiers = field.getModifiers(); if ( !modifiers.contains( Modifier.STATIC ) ) { return Stream.of( new FieldError( field, "Field %s#%s should be static", field.getEnclosingElement().getSimpleName(), field.getSimpleName() ) ); } return Stream.empty(); }
private String guessResponseType(String path, String action) { return guessResponseOuterClassName(path).flatMap( potentialClassName -> guessResponseInnerClassName(action).flatMap(potentialInnerClassName -> { try { String guess = "org.sonarqube.ws." + potentialClassName + "$" + potentialInnerClassName; Helper.class.forName(guess); return Stream.of(guess.replaceFirst("\\$", ".")); } catch (ClassNotFoundException e) { } return Stream.empty(); })).findFirst().orElseGet(() -> { return "String"; }); }
public static List<Class<?>> getAllInterfaces(final Class<?> cls) { return Stream.concat( Arrays.stream(cls.getInterfaces()).flatMap(intf -> Stream.concat(Stream.of(intf), getAllInterfaces(intf).stream())), cls.getSuperclass() == null ? Stream.empty() : getAllInterfaces(cls.getSuperclass()).stream() ).distinct().collect(Collectors.toList()); }
@Override public Stream<M> receiveMessages(MessageScope messageScope) { if (messageScope instanceof MessageScope.Global) { return super.receiveMessages(messageScope); } else { final MessageScope.Local<M> localMessageScope = (MessageScope.Local) messageScope; M aggregateMsg = vertexMemory.getAggregateMessage(vertexId,localMessageScope); if (aggregateMsg==null) return Stream.empty(); else return Stream.of(aggregateMsg); } }
public Stream<CompilationMessage> validateName( ExecutableElement method ) { Optional<String> customName = customNameExtractor.apply( method.getAnnotation( annotationType ) ); if ( customName.isPresent() ) { if ( isInRootNamespace( customName.get() ) ) { return Stream.of( rootNamespaceError( method, customName.get() ) ); } return Stream.empty(); } PackageElement namespace = elements.getPackageOf( method ); if ( namespace == null ) { return Stream.of( rootNamespaceError( method ) ); } return Stream.empty(); }
private Stream<CompilationMessage> validateModifiers( VariableElement field ) { if ( !hasValidModifiers( field ) ) { return Stream.of( new ContextFieldError( field, "@%s usage error: field %s should be public, non-static and non-final", Context.class.getName(), fieldFullName( field ) ) ); } return Stream.empty(); }
private Stream<CompilationMessage> validateAggregationUpdateMethod( ExecutableElement aggregationFunction, Element returnType, List<ExecutableElement> updateMethods ) { if ( updateMethods.size() != 1 ) { return Stream.of( missingAnnotation( aggregationFunction, returnType, updateMethods, UserAggregationUpdate.class ) ); } Stream<CompilationMessage> errors = Stream.empty(); ExecutableElement updateMethod = updateMethods.iterator().next(); if ( !isValidUpdateSignature( updateMethod ) ) { errors = Stream.of( new AggregationError( updateMethod, "@%s usage error: method should be public, non-static and define 'void' as return type.", UserAggregationUpdate.class.getSimpleName() ) ); } return Stream.concat( errors, functionVisitor.validateParameters( updateMethod.getParameters() ) ); }
@Override public Set<? extends RxWebSocketSession> getOpenSessions() { return webSocketSessionRepository.getChannelGroup().stream().flatMap((Function<Channel, Stream<RxWebSocketSession>>) ch -> { NettyRxWebSocketSession s = ch.attr(NettyRxWebSocketSession.WEB_SOCKET_SESSION_KEY).get(); if (s != null && s.isOpen()) { return Stream.of(s); } return Stream.empty(); }).collect(Collectors.toSet()); }