@Override public ByteBuffer write(java.nio.ByteBuffer... buffers) { if (ArrayUtils.isNotEmpty(buffers)) { ByteBuf[] byteBufs = Arrays.stream(buffers) .map(Unpooled::wrappedBuffer).toArray(ByteBuf[]::new); return write(byteBufs); } return this; }
/** * @param handlers The {@link RequestHandler2} */ @Inject public void setRequestHandlers(@Nullable RequestHandler2... handlers) { if (ArrayUtils.isNotEmpty(handlers)) { builder.setRequestHandlers(handlers); } } }
/** * Sets the acceptable {@link MediaType} instances via the {@link HttpHeaders#ACCEPT} header. * * @param mediaTypes The media types * @return This request */ default MutableHttpRequest<B> accept(MediaType... mediaTypes) { if (ArrayUtils.isNotEmpty(mediaTypes)) { String acceptString = Arrays.stream(mediaTypes).collect(Collectors.joining(",")); header(HttpHeaders.ACCEPT, acceptString); } return this; }
@Nonnull @Override public UriBuilder queryParam(String name, Object... values) { if (StringUtils.isNotEmpty(name) && ArrayUtils.isNotEmpty(values)) { final List<String> existing = queryParams.getAll(name); List<String> strings = existing != null ? new ArrayList<>(existing) : new ArrayList<>(values.length); for (Object value : values) { if (value != null) { strings.add(value.toString()); } } queryParams.put(name, strings); } return this; }
@Override public ByteBuffer write(ByteBuffer... buffers) { if (ArrayUtils.isNotEmpty(buffers)) { ByteBuf[] byteBufs = Arrays.stream(buffers) .map(buffer -> { if (buffer instanceof NettyByteBuffer) { return ((NettyByteBuffer) buffer).asNativeBuffer(); } else { return Unpooled.wrappedBuffer(buffer.asNioBuffer()); } }).toArray(ByteBuf[]::new); return write(byteBufs); } return this; }
/** * @param aClass Some class * @param interfaces The interfaces * @return A set of interfaces */ @SuppressWarnings("Duplicates") private static Set<Type> populateInterfaces(Class<?> aClass, Set<Type> interfaces) { Type[] theInterfaces = aClass.getGenericInterfaces(); interfaces.addAll(Arrays.asList(theInterfaces)); for (Type theInterface : theInterfaces) { if (theInterface instanceof Class) { Class<?> i = (Class<?>) theInterface; if (ArrayUtils.isNotEmpty(i.getGenericInterfaces())) { populateInterfaces(i, interfaces); } } } if (!aClass.isInterface()) { Class<?> superclass = aClass.getSuperclass(); while (superclass != null) { populateInterfaces(superclass, interfaces); superclass = superclass.getSuperclass(); } } return interfaces; }
/** * Gets a list of {@link AnnotationValue} for the given member. * * @param member The member * @param type The type * @param <T> The type * @throws IllegalStateException If no member is available that conforms to the given name and type * @return The result */ public @Nonnull final <T extends Annotation> List<AnnotationValue<T>> getAnnotations(String member, Class<T> type) { AnnotationValue[] values = get(member, AnnotationValue[].class).orElse(null); if (ArrayUtils.isNotEmpty(values)) { List<AnnotationValue<T>> list = new ArrayList<>(values.length); String typeName = type.getName(); for (AnnotationValue value : values) { if (value == null) { continue; } if (value.getAnnotationName().equals(typeName)) { //noinspection unchecked list.add(value); } } return list; } return Collections.emptyList(); }
/** * Main method. * @param args The arguments */ public static void main(String... args) { // enable Graal class analysis System.setProperty(GraalClassLoadingReporter.GRAAL_CLASS_ANALYSIS, Boolean.TRUE.toString()); if (ArrayUtils.isNotEmpty(args)) { System.setProperty(GraalClassLoadingReporter.REFLECTION_JSON_FILE, args[0]); } try { ApplicationContext applicationContext = ApplicationContext.run(); // following beans may impact classloading, so load them. applicationContext.findBean(EmbeddedServer.class); applicationContext.getBeansOfType(ExecutableMethodProcessor.class); // finish up applicationContext.stop(); } catch (Throwable e) { System.err.println("An error occurred analyzing class requirements: " + e.getMessage()); e.printStackTrace(System.err); } }
AnnotationValue<Filter> filterAnn = filterOpt.get(); String[] clients = filterAnn.get("serviceId", String[].class).orElse(null); if (!clientIdentifiers.isEmpty() && ArrayUtils.isNotEmpty(clients)) { if (Arrays.stream(clients).noneMatch(id -> clientIdentifiers.contains(id))) { if (ArrayUtils.isNotEmpty(methods)) { if (!Arrays.asList(methods).contains(method)) { continue;
private void reportArguments(Argument... arguments) { if (ArrayUtils.isNotEmpty(arguments)) { for (Argument argument : arguments) { final Class argType = argument.getType(); if (!ClassUtils.isJavaLangType(argType)) { ClassLoadingReporter.reportBeanPresent(argType); } reportArguments(argument.getTypeParameters()); } } } }
if (ArrayUtils.isNotEmpty(contentTypes)) { request.contentType(contentTypes[0]);
/** * Configures the exceptions to not rollback for. * * @param exceptions The exceptions not to rollback for */ public final void setNoRollbackFor(Class<? extends Throwable>... exceptions) { if (ArrayUtils.isNotEmpty(exceptions)) { noRollbackFor.addAll(Arrays.asList(exceptions)); } }
/** * Configures the exceptions to not rollback for. * * @param exceptions The exceptions not to rollback for */ public final void setNoRollbackFor(Class<? extends Throwable>... exceptions) { if (ArrayUtils.isNotEmpty(exceptions)) { noRollbackFor.addAll(Arrays.asList(exceptions)); } }
@Override public FilterRoute methods(HttpMethod... methods) { if (ArrayUtils.isNotEmpty(methods)) { if (httpMethods == null) { httpMethods = new HashSet<>(); } httpMethods.addAll(Arrays.asList(methods)); } return this; } }
/** * Configures the exceptions to rollback for. * * @param exceptions The exceptions to rollback for */ public final void setRollbackFor(Class<? extends Throwable>... exceptions) { if (ArrayUtils.isNotEmpty(exceptions)) { if (rollbackFor == null) { rollbackFor = new HashSet<>(); } rollbackFor.addAll(Arrays.asList(exceptions)); } }
/** * Configures the exceptions to rollback for. * * @param exceptions The exceptions to rollback for */ public final void setRollbackFor(Class<? extends Throwable>... exceptions) { if (ArrayUtils.isNotEmpty(exceptions)) { if (rollbackFor == null) { rollbackFor = new HashSet<>(); } rollbackFor.addAll(Arrays.asList(exceptions)); } }
/** * Sets the acceptable {@link MediaType} instances via the {@link HttpHeaders#ACCEPT} header. * * @param mediaTypes The media types * @return This request */ default MutableHttpRequest<B> accept(MediaType... mediaTypes) { if (ArrayUtils.isNotEmpty(mediaTypes)) { String acceptString = Arrays.stream(mediaTypes).collect(Collectors.joining(",")); header(HttpHeaders.ACCEPT, acceptString); } return this; }
@Nonnull @Override public UriBuilder queryParam(String name, Object... values) { if (StringUtils.isNotEmpty(name) && ArrayUtils.isNotEmpty(values)) { final List<String> existing = queryParams.getAll(name); List<String> strings = existing != null ? new ArrayList<>(existing) : new ArrayList<>(values.length); for (Object value : values) { if (value != null) { strings.add(value.toString()); } } queryParams.put(name, strings); } return this; }
private boolean matchesPresenceOfBeans(ConditionContext context, AnnotationValue<Requires> requirements) { Class[] beans = requirements.get("beans", Class[].class).orElse(null); if (ArrayUtils.isNotEmpty(beans)) { BeanContext beanContext = context.getBeanContext(); for (Class type : beans) { if (!beanContext.containsBean(type)) { context.fail("No bean of type [" + type + "] present within context"); return false; } } } return true; }
private boolean matchesPresenceOfBeans(ConditionContext context, AnnotationValue<Requires> requirements) { Class[] beans = requirements.get("beans", Class[].class).orElse(null); if (ArrayUtils.isNotEmpty(beans)) { BeanContext beanContext = context.getBeanContext(); for (Class type : beans) { if (!beanContext.containsBean(type)) { context.fail("No bean of type [" + type + "] present within context"); return false; } } } return true; }