io.micronaut.core.util.CollectionUtils Java Examples

The following examples show how to use io.micronaut.core.util.CollectionUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GrpcServerChannel.java    From micronaut-grpc with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs a managed server channel.
 * @param server The server
 * @param executorService The executor service
 * @param clientInterceptors The client interceptors
 * @return The channel
 */
@Singleton
@Named(NAME)
@Requires(beans = GrpcEmbeddedServer.class)
@Bean(preDestroy = "shutdown")
protected ManagedChannel serverChannel(
        GrpcEmbeddedServer server,
        @javax.inject.Named(TaskExecutors.IO) ExecutorService executorService,
        List<ClientInterceptor> clientInterceptors) {
    final ManagedChannelBuilder<?> builder = ManagedChannelBuilder.forAddress(
            server.getHost(),
            server.getPort()
    ).executor(executorService);
    if (!server.getServerConfiguration().isSecure()) {
        builder.usePlaintext();
    }
    if (CollectionUtils.isNotEmpty(clientInterceptors)) {
        builder.intercept(clientInterceptors);
    }
    return builder.build();
}
 
Example #2
Source File: DefaultFindSliceAsyncInterceptor.java    From micronaut-data with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public CompletionStage<Slice<Object>> intercept(RepositoryMethodKey methodKey, MethodInvocationContext<T, CompletionStage<Slice<Object>>> context) {
    if (context.hasAnnotation(Query.class)) {
        PreparedQuery<?, ?> preparedQuery = prepareQuery(methodKey, context);
        Pageable pageable = preparedQuery.getPageable();
        return asyncDatastoreOperations.findAll(preparedQuery)
                .thenApply(objects ->
                        Slice.of((List<Object>) CollectionUtils.iterableToList(objects), pageable)
                );

    } else {
        PagedQuery<Object> pagedQuery = getPagedQuery(context);
        return asyncDatastoreOperations.findAll(pagedQuery).thenApply(objects ->
                Slice.of(CollectionUtils.iterableToList(objects), pagedQuery.getPageable())
        );
    }
}
 
Example #3
Source File: DefaultFindPageAsyncInterceptor.java    From micronaut-data with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public CompletionStage<Page<Object>> intercept(RepositoryMethodKey methodKey, MethodInvocationContext<T, CompletionStage<Page<Object>>> context) {
    if (context.hasAnnotation(Query.class)) {
        PreparedQuery<?, ?> preparedQuery = prepareQuery(methodKey, context);
        PreparedQuery<?, Number> countQuery = prepareCountQuery(methodKey, context);

        return asyncDatastoreOperations.findOne(countQuery)
                .thenCompose(total -> asyncDatastoreOperations.findAll(preparedQuery)
                        .thenApply(objects -> {
                            List<Object> resultList = CollectionUtils.iterableToList((Iterable<Object>) objects);
                            return Page.of(resultList, getPageable(context), total.longValue());
                        }));

    } else {
        return asyncDatastoreOperations.findPage(getPagedQuery(context));
    }
}
 
Example #4
Source File: SqlResultEntityTypeMapper.java    From micronaut-data with Apache License 2.0 6 votes vote down vote up
/**
 * Constructor used to customize the join paths.
 * @param entity The entity
 * @param resultReader The result reader
 * @param joinPaths The join paths
 */
private SqlResultEntityTypeMapper(
        @NonNull RuntimePersistentEntity<R> entity,
        @NonNull ResultReader<RS, String> resultReader,
        @Nullable Set<JoinPath> joinPaths,
        String startingPrefix,
        @Nullable MediaTypeCodec jsonCodec) {
    ArgumentUtils.requireNonNull("entity", entity);
    ArgumentUtils.requireNonNull("resultReader", resultReader);
    this.entity = entity;
    this.jsonCodec = jsonCodec;
    this.resultReader = resultReader;
    if (CollectionUtils.isNotEmpty(joinPaths)) {
        this.joinPaths = new HashMap<>(joinPaths.size());
        for (JoinPath joinPath : joinPaths) {
            this.joinPaths.put(joinPath.getPath(), joinPath);
        }
    } else {
        this.joinPaths = Collections.emptyMap();
    }
    this.startingPrefix = startingPrefix;
}
 
Example #5
Source File: GrpcServerChannel.java    From micronaut-grpc with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs a managed server channel.
 * @param server The server
 * @param executorService The executor service
 * @param clientInterceptors The client interceptors
 * @return The channel
 */
@Singleton
@Named(NAME)
@Requires(beans = GrpcEmbeddedServer.class)
@Bean(preDestroy = "shutdown")
protected ManagedChannel serverChannel(
        GrpcEmbeddedServer server,
        @javax.inject.Named(TaskExecutors.IO) ExecutorService executorService,
        List<ClientInterceptor> clientInterceptors) {
    final ManagedChannelBuilder<?> builder = ManagedChannelBuilder.forAddress(
            server.getHost(),
            server.getPort()
    ).executor(executorService);
    if (!server.getServerConfiguration().isSecure()) {
        builder.usePlaintext();
    }
    if (CollectionUtils.isNotEmpty(clientInterceptors)) {
        builder.intercept(clientInterceptors);
    }
    return builder.build();
}
 
Example #6
Source File: GrpcServerInstance.java    From micronaut-grpc with Apache License 2.0 6 votes vote down vote up
/**
 * Default constructor.
 * @param embeddedServer The embedded server
 * @param id The ID
 * @param uri The URI
 * @param metadata The metadata
 * @param metadataContributors The metadata contributors
 */
GrpcServerInstance(
        EmbeddedServer embeddedServer,
        String id,
        URI uri,
        @Nullable Map<String, String> metadata,
        @javax.annotation.Nullable List<ServiceInstanceMetadataContributor> metadataContributors) {
    this.embeddedServer = embeddedServer;
    this.id = id;
    this.uri = uri;
    if (metadata == null) {
        metadata = new LinkedHashMap<>(5);
    }

    if (CollectionUtils.isNotEmpty(metadataContributors)) {
        for (ServiceInstanceMetadataContributor contributor : metadataContributors) {
            contributor.contribute(this, metadata);
        }
    }

    this.metadata = ConvertibleValues.of(metadata);
}
 
Example #7
Source File: GrpcChannelBuilderFactory.java    From micronaut-grpc with Apache License 2.0 6 votes vote down vote up
/**
 * Constructor a managed channel build for the given target name and interceptors.
 * @param target The target name
 * @param interceptors The interceptors
 * @return The channel builder
 */
@Bean
@Prototype
protected NettyChannelBuilder managedChannelBuilder(@Parameter String target, List<ClientInterceptor> interceptors) {
    GrpcManagedChannelConfiguration config = beanContext.findBean(GrpcManagedChannelConfiguration.class, Qualifiers.byName(target)).orElseGet(() -> {
                final GrpcDefaultManagedChannelConfiguration mcc = new GrpcDefaultManagedChannelConfiguration(
                        target,
                        beanContext.getEnvironment(),
                        executorService
                );
                beanContext.inject(mcc);
                return mcc;
            }
    );
    final NettyChannelBuilder channelBuilder = config.getChannelBuilder();
    if (CollectionUtils.isNotEmpty(interceptors)) {
        channelBuilder.intercept(interceptors);
    }
    return channelBuilder;
}
 
Example #8
Source File: GrpcChannelBuilderFactory.java    From micronaut-grpc with Apache License 2.0 6 votes vote down vote up
/**
 * Constructor a managed channel build for the given target name and interceptors.
 * @param target The target name
 * @param interceptors The interceptors
 * @return The channel builder
 */
@Bean
@Prototype
protected NettyChannelBuilder managedChannelBuilder(@Parameter String target, List<ClientInterceptor> interceptors) {
    GrpcManagedChannelConfiguration config = beanContext.findBean(GrpcManagedChannelConfiguration.class, Qualifiers.byName(target)).orElseGet(() -> {
                final GrpcDefaultManagedChannelConfiguration mcc = new GrpcDefaultManagedChannelConfiguration(
                        target,
                        beanContext.getEnvironment(),
                        executorService
                );
                beanContext.inject(mcc);
                return mcc;
            }
    );
    final NettyChannelBuilder channelBuilder = config.getChannelBuilder();
    if (CollectionUtils.isNotEmpty(interceptors)) {
        channelBuilder.intercept(interceptors);
    }
    return channelBuilder;
}
 
Example #9
Source File: GrpcServerInstance.java    From micronaut-grpc with Apache License 2.0 6 votes vote down vote up
/**
 * Default constructor.
 * @param embeddedServer The embedded server
 * @param id The ID
 * @param uri The URI
 * @param metadata The metadata
 * @param metadataContributors The metadata contributors
 */
GrpcServerInstance(
        EmbeddedServer embeddedServer,
        String id,
        URI uri,
        @Nullable Map<String, String> metadata,
        @javax.annotation.Nullable List<ServiceInstanceMetadataContributor> metadataContributors) {
    this.embeddedServer = embeddedServer;
    this.id = id;
    this.uri = uri;
    if (metadata == null) {
        metadata = new LinkedHashMap<>(5);
    }

    if (CollectionUtils.isNotEmpty(metadataContributors)) {
        for (ServiceInstanceMetadataContributor contributor : metadataContributors) {
            contributor.contribute(this, metadata);
        }
    }

    this.metadata = ConvertibleValues.of(metadata);
}
 
Example #10
Source File: MicronautAwsProxyTest.java    From micronaut-aws with Apache License 2.0 6 votes vote down vote up
@Test
public void stripBasePath_route_shouldReturn404() throws ContainerInitializationException {
    MicronautLambdaContainerHandler handler = new MicronautLambdaContainerHandler(
            ApplicationContext.build(CollectionUtils.mapOf(
                    "spec.name", "MicronautAwsProxyTest",
                    "micronaut.security.enabled", false,
                    "micronaut.views.handlebars.enabled", true,
                    "micronaut.router.static-resources.lorem.paths", "classpath:static-lorem/",
                    "micronaut.router.static-resources.lorem.mapping", "/static-lorem/**"
            ))
    );
    handler.stripBasePath("/custom");
    try {
        AwsProxyRequest request = getRequestBuilder("/custompath/echo/status-code", "GET")
                .json()
                .queryString("status", "201")
                .build();
        AwsProxyResponse output = handler.proxy(request, lambdaContext);
        assertEquals(404, output.getStatusCode());
    } finally {

        handler.stripBasePath("");
    }
}
 
Example #11
Source File: MicronautAwsProxyTest.java    From micronaut-aws with Apache License 2.0 6 votes vote down vote up
@Test
public void error_statusCode_methodNotAllowed() throws ContainerInitializationException {
    MicronautLambdaContainerHandler handler = new MicronautLambdaContainerHandler(
            ApplicationContext.build(CollectionUtils.mapOf(
                    "spec.name", "MicronautAwsProxyTest",
                    "micronaut.security.enabled", false,
                    "micronaut.views.handlebars.enabled", true,
                    "micronaut.router.static-resources.lorem.paths", "classpath:static-lorem/",
                    "micronaut.router.static-resources.lorem.mapping", "/static-lorem/**"
            ))
    );
    AwsProxyRequest request = getRequestBuilder("/echo/status-code", "POST")
            .json()
            .queryString("status", "201")
            .build();

    AwsProxyResponse output = handler.proxy(request, lambdaContext);
    assertEquals(405, output.getStatusCode());
}
 
Example #12
Source File: MicronautAwsProxyTest.java    From micronaut-aws with Apache License 2.0 6 votes vote down vote up
@Test
public void errors_unknownRoute_expect404() throws ContainerInitializationException {
    MicronautLambdaContainerHandler handler = new MicronautLambdaContainerHandler(
            ApplicationContext.build(CollectionUtils.mapOf(
                    "spec.name", "MicronautAwsProxyTest",
                    "micronaut.security.enabled", false,
                    "micronaut.views.handlebars.enabled", true,
                    "micronaut.router.static-resources.lorem.paths", "classpath:static-lorem/",
                    "micronaut.router.static-resources.lorem.mapping", "/static-lorem/**"
            ))
    );
    AwsProxyRequest request = getRequestBuilder("/echo/test33", "GET").build();

    AwsProxyResponse output = handler.proxy(request, lambdaContext);
    assertEquals(404, output.getStatusCode());
}
 
Example #13
Source File: PropertySourceMapTest.java    From micronaut-test with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public Map<String, String> getProperties() {
    return CollectionUtils.mapOf(
            "foo.bar", "one",
            "foo.baz", "two"
    );
}
 
Example #14
Source File: MicronautJunit5Extension.java    From micronaut-test with Apache License 2.0 5 votes vote down vote up
@Override
protected void resolveTestProperties(ExtensionContext context, MicronautTest testAnnotation, Map<String, Object> testProperties) {
    Object o = context.getTestInstance().orElse(null);
    if (o instanceof TestPropertyProvider) {
        Map<String, String> properties = ((TestPropertyProvider) o).getProperties();
        if (CollectionUtils.isNotEmpty(properties)) {
            testProperties.putAll(properties);
        }
    }
}
 
Example #15
Source File: MicronautSpockExtension.java    From micronaut-test with Apache License 2.0 5 votes vote down vote up
@Override
protected void resolveTestProperties(IMethodInvocation context, MicronautTest testAnnotation, Map<String, Object> testProperties) {
    Object sharedInstance = context.getSharedInstance();
    if (sharedInstance instanceof TestPropertyProvider) {
        Map<String, String> properties = ((TestPropertyProvider) sharedInstance).getProperties();
        if (CollectionUtils.isNotEmpty(properties)) {
            testProperties.putAll(properties);
        }
    }
}
 
Example #16
Source File: PageDelegate.java    From micronaut-data with Apache License 2.0 5 votes vote down vote up
@Override
public Sort getSort() {
    List<io.micronaut.data.model.Sort.Order> orderBy = delegate.getSort().getOrderBy();
    if (CollectionUtils.isEmpty(orderBy)) {
        return Sort.unsorted();
    } else {
        return new SortDelegate(delegate.getSort());
    }
}
 
Example #17
Source File: MicronautAwsProxyRequest.java    From micronaut-aws with Apache License 2.0 5 votes vote down vote up
@Override
public List<String> getAll(CharSequence name) {
    if (StringUtils.isNotEmpty(name)) {
        final List<String> strings = multiValueHeaders.get(name.toString());
        if (CollectionUtils.isNotEmpty(strings)) {
            return strings;
        }
    }
    return Collections.emptyList();
}
 
Example #18
Source File: Sort.java    From micronaut-data with Apache License 2.0 5 votes vote down vote up
/**
 * Create a sort from the given list of orders.
 *
 * @param orderList The order list
 * @return The sort
 */
@JsonCreator
static @NonNull Sort of(
        @JsonProperty("orderBy") @Nullable List<Order> orderList) {
    if (CollectionUtils.isEmpty(orderList)) {
        return UNSORTED;
    }
    return new DefaultSort(orderList);
}
 
Example #19
Source File: MicronautAwsProxyRequest.java    From micronaut-aws with Apache License 2.0 5 votes vote down vote up
@Override
public List<String> getAll(CharSequence name) {
    if (StringUtils.isNotEmpty(name)) {
        final List<String> strings = params.get(name.toString());
        if (CollectionUtils.isNotEmpty(strings)) {
            return strings.stream().map(v -> decodeValue(name, v)).collect(Collectors.toList());
        }
    }
    return Collections.emptyList();
}
 
Example #20
Source File: HelloWorldMicronautTest.java    From micronaut-aws with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void initializeServer() throws ContainerInitializationException {
    try {
        handler = new MicronautLambdaContainerHandler(
                ApplicationContext.build()
                        .properties(CollectionUtils.mapOf(
                                "spec.name", "HelloWorldMicronautTest"
                        ))
        );
    } catch (RuntimeException e) {
        e.printStackTrace();
        fail();
    }
}
 
Example #21
Source File: AbstractPatternBasedMethod.java    From micronaut-data with Apache License 2.0 5 votes vote down vote up
/**
 * Apply ordering.
 *
 * @param context   The context
 * @param query     The query
 * @param orderList The list mutate
 * @return True if an error occurred applying the order
 */
protected boolean applyOrderBy(@NonNull MethodMatchContext context, @NonNull QueryModel query, @NonNull List<Sort.Order> orderList) {
    if (CollectionUtils.isNotEmpty(orderList)) {
        SourcePersistentEntity entity = context.getRootEntity();
        for (Sort.Order order : orderList) {
            String prop = order.getProperty();
            if (!entity.getPath(prop).isPresent()) {
                context.fail("Cannot order by non-existent property: " + prop);
                return true;
            }
        }
        query.sort(Sort.of(orderList));
    }
    return false;
}
 
Example #22
Source File: HibernateMetricsBinder.java    From micronaut-sql with Apache License 2.0 5 votes vote down vote up
/**
 * Default constructor.
 * @param meterRegistryProvider The meter registry provider
 * @param tags The tags
 */
public HibernateMetricsBinder(
        Provider<MeterRegistry> meterRegistryProvider,
        @Property(name = MICRONAUT_METRICS_BINDERS + ".hibernate.tags")
        @MapFormat(transformation = MapFormat.MapTransformation.FLAT)
        Map<String, String> tags) {
    this.meterRegistryProvider = meterRegistryProvider;
    if (CollectionUtils.isNotEmpty(tags)) {
        this.tags = tags.entrySet().stream().map(entry -> Tag.of(entry.getKey(), entry.getValue())).collect(Collectors.toList());
    } else {
        this.tags = Collections.emptyList();
    }

}
 
Example #23
Source File: DocTests.java    From micronaut-kafka with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setup() {
    kafkaContainer.start();
    applicationContext = ApplicationContext.run(
            CollectionUtils.mapOf(
                    "kafka.bootstrap.servers", kafkaContainer.getBootstrapServers()
        )
    );
}
 
Example #24
Source File: JpaConfiguration.java    From micronaut-sql with Apache License 2.0 5 votes vote down vote up
/**
 * Builds the standard service registry.
 *
 * @param additionalSettings Additional settings for the service registry
 * @return The standard service registry
 */
@SuppressWarnings("WeakerAccess")
public StandardServiceRegistry buildStandardServiceRegistry(@Nullable Map<String, Object> additionalSettings) {
    StandardServiceRegistryBuilder standardServiceRegistryBuilder = createStandServiceRegistryBuilder(bootstrapServiceRegistry);

    Map<String, Object> jpaProperties = getProperties();
    if (CollectionUtils.isNotEmpty(jpaProperties)) {
        standardServiceRegistryBuilder.applySettings(jpaProperties);
    }
    if (additionalSettings != null) {
        standardServiceRegistryBuilder.applySettings(additionalSettings);
    }
    return standardServiceRegistryBuilder.build();
}
 
Example #25
Source File: KafkaHeaders.java    From micronaut-kafka with Apache License 2.0 5 votes vote down vote up
@Override
public List<String> getAll(CharSequence name) {
    if (name != null) {
        List<Header> headers = CollectionUtils.iterableToList(this.headers.headers(name.toString()));
        return headers.stream().map(h -> new String(h.value(), StandardCharsets.UTF_8)).collect(Collectors.toList());
    } else {
        return Collections.emptyList();
    }
}
 
Example #26
Source File: EventIntegrator.java    From micronaut-data with Apache License 2.0 4 votes vote down vote up
@Override
public void integrate(
        Metadata metadata,
        SessionFactoryImplementor sessionFactory,
        SessionFactoryServiceRegistry serviceRegistry) {
    EventListenerRegistry eventListenerRegistry =
            serviceRegistry.getService(EventListenerRegistry.class);

    Collection<PersistentClass> entityBindings = metadata.getEntityBindings();
    Map<Class, BeanProperty> lastUpdates = new HashMap<>(entityBindings.size());
    Map<Class, BeanProperty> dateCreated = new HashMap<>(entityBindings.size());

    entityBindings.forEach(e -> {
                Class<?> mappedClass = e.getMappedClass();
                if (mappedClass != null) {
                    BeanIntrospection<?> introspection = BeanIntrospector.SHARED.findIntrospection(mappedClass).orElse(null);
                    if (introspection != null) {
                        introspection.getIndexedProperty(DateCreated.class).ifPresent(bp ->
                                dateCreated.put(mappedClass, bp)
                        );
                        introspection.getIndexedProperty(DateUpdated.class).ifPresent(bp ->
                                lastUpdates.put(mappedClass, bp)
                        );
                    }
                }
            }
    );

    ConversionService<?> conversionService = ConversionService.SHARED;

    if (CollectionUtils.isNotEmpty(dateCreated)) {

        eventListenerRegistry.getEventListenerGroup(EventType.PRE_INSERT)
                .appendListener((PreInsertEventListener) event -> {
                    Object[] state = event.getState();
                    timestampIfNecessary(
                            dateCreated,
                            lastUpdates,
                            conversionService,
                            event,
                            state,
                            true
                    );
                    return false;
                });
    }

    if (CollectionUtils.isNotEmpty(lastUpdates)) {

        eventListenerRegistry.getEventListenerGroup(EventType.PRE_UPDATE)
                .appendListener((PreUpdateEventListener) event -> {
                    timestampIfNecessary(
                            dateCreated, lastUpdates,
                            conversionService,
                            event,
                            event.getState(),
                            false
                    );
                    return false;
                });
    }
}
 
Example #27
Source File: EchoMicronautController.java    From micronaut-aws with Apache License 2.0 4 votes vote down vote up
@Get("/render-html")
@Produces(MediaType.TEXT_HTML)
public ModelAndView getHtmlFromRenderEngine(Context context) {
    ModelAndView mav = new ModelAndView("home", CollectionUtils.mapOf("firstname", "Luke", "lastname", "Skywalker"));
    return mav;
}
 
Example #28
Source File: DefaultTransactionAttribute.java    From micronaut-data with Apache License 2.0 4 votes vote down vote up
/**
 * Sets the exceptions that will not cause a rollback.
 * @param noRollbackFor The exceptions
 */
public void setNoRollbackFor(Class<? extends Throwable>... noRollbackFor) {
    if (ArrayUtils.isNotEmpty(noRollbackFor)) {
        this.noRollbackFor = CollectionUtils.setOf(noRollbackFor);
    }
}
 
Example #29
Source File: KafkaHealthIndicator.java    From micronaut-kafka with Apache License 2.0 4 votes vote down vote up
@Override
public Flowable<HealthResult> getResult() {
    DescribeClusterResult result = adminClient.describeCluster(
            new DescribeClusterOptions().timeoutMs(
                    (int) defaultConfiguration.getHealthTimeout().toMillis()
            )
    );

    Flowable<String> clusterId = Flowable.fromFuture(result.clusterId());
    Flowable<Collection<Node>> nodes = Flowable.fromFuture(result.nodes());
    Flowable<Node> controller = Flowable.fromFuture(result.controller());

    return controller.switchMap(node -> {
        String brokerId = node.idString();
        ConfigResource configResource = new ConfigResource(ConfigResource.Type.BROKER, brokerId);
        DescribeConfigsResult configResult = adminClient.describeConfigs(Collections.singletonList(configResource));
        Flowable<Map<ConfigResource, Config>> configs = Flowable.fromFuture(configResult.all());
        return configs.switchMap(resources -> {
            Config config = resources.get(configResource);
            ConfigEntry ce = config.get(REPLICATION_PROPERTY);
            int replicationFactor = Integer.parseInt(ce.value());
            return nodes.switchMap(nodeList -> clusterId.map(clusterIdString -> {
                int nodeCount = nodeList.size();
                HealthResult.Builder builder;
                if (nodeCount >= replicationFactor) {
                    builder = HealthResult.builder(ID, HealthStatus.UP);
                } else {
                    builder = HealthResult.builder(ID, HealthStatus.DOWN);
                }
                return builder
                        .details(CollectionUtils.mapOf(
                                "brokerId", brokerId,
                                "clusterId", clusterIdString,
                                "nodes", nodeCount
                        )).build();
            }));
        });
    }).onErrorReturn(throwable ->
            HealthResult.builder(ID, HealthStatus.DOWN)
                    .exception(throwable).build()
    );
}
 
Example #30
Source File: DefaultSlice.java    From micronaut-data with Apache License 2.0 4 votes vote down vote up
/**
 * Default constructor.
 * @param content The content
 * @param pageable The pageable
 */
DefaultSlice(List<T> content, Pageable pageable) {
    ArgumentUtils.requireNonNull("pageable", pageable);
    this.content = CollectionUtils.isEmpty(content) ? Collections.emptyList() : content;
    this.pageable = pageable;
}