@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; }
/** * Whether the given array is not empty. * * @param array The array * @return True if it is */ public static boolean isNotEmpty(Object[] array) { return !isEmpty(array); }
@Override public Annotation[] synthesizeAll() { return ArrayUtils.concat(childContext.synthesizeAll(), thisContext.synthesizeAll()); }
private boolean matchesEnvironment(ConditionContext context, AnnotationValue<Requires> requirements) { String[] env = requirements.get("env", String[].class).orElse(null); if (ArrayUtils.isEmpty(env)) { env = requirements.get("notEnv", String[].class).orElse(null); if (ArrayUtils.isNotEmpty(env)) { BeanContext beanContext = context.getBeanContext(); if (beanContext instanceof ApplicationContext) { boolean result = Arrays.stream(env).anyMatch(s -> !activeNames.contains(s)); if (!result) { context.fail("Disallowed environments [" + ArrayUtils.toString(env) + "] are active: " + activeNames); boolean result = Arrays.stream(env).anyMatch(activeNames::contains); if (!result) { context.fail("None of the required environments [" + ArrayUtils.toString(env) + "] are active: " + activeNames);
/** * Produce a string representation of the given array. * * @param array The array * @return The string representation */ public static String toString(@Nullable Object[] array) { String delimiter = ","; return toString(delimiter, array); }
private boolean matchesEnvironment(ConditionContext context, AnnotationValue<Requires> requirements) { String[] env = requirements.get("env", String[].class).orElse(null); if (ArrayUtils.isEmpty(env)) { env = requirements.get("notEnv", String[].class).orElse(null); if (ArrayUtils.isNotEmpty(env)) { BeanContext beanContext = context.getBeanContext(); if (beanContext instanceof ApplicationContext) { boolean result = Arrays.stream(env).noneMatch(activeNames::contains); if (!result) { context.fail("Disallowed environments [" + ArrayUtils.toString(env) + "] are active: " + activeNames); boolean result = Arrays.stream(env).anyMatch(activeNames::contains); if (!result) { context.fail("None of the required environments [" + ArrayUtils.toString(env) + "] are active: " + activeNames);
addConverter(Object[].class, String.class, (object, targetType, context) -> Optional.of(ArrayUtils.toString(object)));
/** * @param handlers The {@link RequestHandler2} */ @Inject public void setRequestHandlers(@Nullable RequestHandler2... handlers) { if (ArrayUtils.isNotEmpty(handlers)) { builder.setRequestHandlers(handlers); } } }
/** * Produce a string representation of the given array. * * @param delimiter The delimiter * @param array The array * @return The string representation */ public static String toString(String delimiter, @Nullable Object[] array) { if (isEmpty(array)) { return ""; } List<Object> list = Arrays.asList(array); return CollectionUtils.toString(delimiter, list); } }
@Override public Annotation[] synthesizeDeclared() { return ArrayUtils.concat(childContext.synthesizeDeclared(), thisContext.synthesizeDeclared()); }
@Override public String toString() { return ParametersKey.class.getSimpleName() + ": " + ArrayUtils.toString(params); } }
/** * 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; }
/** * Check whether any of the given stereotypes is present. * * @param annotations The annotations * @return True if any of the given stereotypes are present */ default boolean hasStereotype(@Nullable String[] annotations) { if (ArrayUtils.isEmpty(annotations)) { return false; } for (String annotation : annotations) { if (hasStereotype(annotation)) { return true; } } return false; }
/** * Resolves the interceptors for a method for {@link Introduction} advise. For {@link Introduction} advise * any {@link Around} advise interceptors are applied first * * @param beanContext Bean Context * @param method The method * @param interceptors The array of interceptors * @return The filtered array of interceptors */ @Internal public static Interceptor[] resolveIntroductionInterceptors(BeanContext beanContext, ExecutableMethod<?, ?> method, Interceptor... interceptors) { instrumentAnnotationMetadata(beanContext, method); Interceptor[] aroundInterceptors = resolveAroundInterceptors(beanContext, method, interceptors); Interceptor[] introductionInterceptors = resolveInterceptorsInternal(method, Introduction.class, interceptors); if (introductionInterceptors.length == 0) { if (method.hasStereotype(Adapter.class)) { introductionInterceptors = new Interceptor[] { new AdapterIntroduction(beanContext, method) }; } else { throw new IllegalStateException("At least one @Introduction method interceptor required, but missing. Check if your @Introduction stereotype annotation is marked with @Retention(RUNTIME) and @Type(..) with the interceptor type. Otherwise do not load @Introduction beans if their interceptor definitions are missing!"); } } return ArrayUtils.concat(aroundInterceptors, introductionInterceptors); }
LOG.trace("Bean type {} is not compatible with candidate generic types [{}] of candidate {}", beanType, ArrayUtils.toString(classes), candidate); boolean result = areTypesCompatible(Arrays.asList(classes)); if (LOG.isTraceEnabled() && !result) { LOG.trace("Bean type {} is not compatible with candidate generic types [{}] of candidate {}", beanType, ArrayUtils.toString(classes), candidate);
@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; }
/** * Convert an argument array to a class array. * * @param arguments The arguments * @return The class array */ static Class[] toClassArray(Argument... arguments) { if (ArrayUtils.isEmpty(arguments)) { return ReflectionUtils.EMPTY_CLASS_ARRAY; } Class[] types = new Class[arguments.length]; for (int i = 0; i < arguments.length; i++) { Argument argument = arguments[i]; types[i] = argument.getType(); } return types; }
LOG.trace("Bean type {} is not compatible with candidate generic types [{}] of candidate {}", beanType, ArrayUtils.toString(classes), candidate); boolean result = areTypesCompatible(Arrays.asList(classes)); if (LOG.isTraceEnabled() && !result) { LOG.trace("Bean type {} is not compatible with candidate generic types [{}] of candidate {}", beanType, ArrayUtils.toString(classes), candidate);
@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; }