Java Code Examples for io.micronaut.core.util.ArgumentUtils#requireNonNull()

The following examples show how to use io.micronaut.core.util.ArgumentUtils#requireNonNull() . 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: GrpcEmbeddedServer.java    From micronaut-grpc with Apache License 2.0 6 votes vote down vote up
/**
 * Default constructor.
 * @param applicationContext The application context
 * @param applicationConfiguration The application configuration
 * @param grpcServerConfiguration The GRPC server configuration
 * @param serverBuilder The server builder
 * @param eventPublisher The event publisher
 * @param computeInstanceMetadataResolver The computed instance metadata
 * @param metadataContributors The metadata contributors
 */
@Internal
GrpcEmbeddedServer(
        @Nonnull ApplicationContext applicationContext,
        @Nonnull ApplicationConfiguration applicationConfiguration,
        @Nonnull GrpcServerConfiguration grpcServerConfiguration,
        @Nonnull ServerBuilder<?> serverBuilder,
        @Nonnull ApplicationEventPublisher eventPublisher,
        @Nullable ComputeInstanceMetadataResolver computeInstanceMetadataResolver,
        @Nullable List<ServiceInstanceMetadataContributor> metadataContributors) {
    ArgumentUtils.requireNonNull("applicationContext", applicationContext);
    ArgumentUtils.requireNonNull("applicationConfiguration", applicationConfiguration);
    ArgumentUtils.requireNonNull("grpcServerConfiguration", grpcServerConfiguration);
    this.applicationContext = applicationContext;
    this.configuration = applicationConfiguration;
    this.grpcConfiguration = grpcServerConfiguration;
    this.eventPublisher = eventPublisher;
    this.server = serverBuilder.build();
    this.computeInstanceMetadataResolver = computeInstanceMetadataResolver;
    this.metadataContributors = metadataContributors;
}
 
Example 2
Source File: AbstractSqlRepositoryOperations.java    From micronaut-data with Apache License 2.0 6 votes vote down vote up
@NonNull
@Override
public final <T> RuntimePersistentEntity<T> getEntity(@NonNull Class<T> type) {
    ArgumentUtils.requireNonNull("type", type);
    RuntimePersistentEntity<T> entity = entities.get(type);
    if (entity == null) {
        entity = new RuntimePersistentEntity<T>(type) {
            @Override
            protected RuntimePersistentEntity<T> getEntity(Class<T> type) {
                return AbstractSqlRepositoryOperations.this.getEntity(type);
            }
        };
        entities.put(type, entity);
    }
    return entity;
}
 
Example 3
Source File: MicronautLambdaContainerHandler.java    From micronaut-aws with Apache License 2.0 6 votes vote down vote up
/**
 * constructor.
 *
 * @param lambdaContainerEnvironment The container environment
 * @param applicationContextBuilder  The context builder
 * @throws ContainerInitializationException if the container couldn't be started
 */
private MicronautLambdaContainerHandler(
        LambdaContainerState lambdaContainerEnvironment,
        ApplicationContextBuilder applicationContextBuilder) throws ContainerInitializationException {
    super(
            AwsProxyRequest.class,
            AwsProxyResponse.class,
            new MicronautRequestReader(lambdaContainerEnvironment),
            new MicronautResponseWriter(lambdaContainerEnvironment),
            new AwsProxySecurityContextWriter(),
            new MicronautAwsProxyExceptionHandler(lambdaContainerEnvironment)

    );
    ArgumentUtils.requireNonNull("applicationContextBuilder", applicationContextBuilder);
    this.lambdaContainerEnvironment = lambdaContainerEnvironment;
    this.applicationContextBuilder = applicationContextBuilder;
    initialize();
}
 
Example 4
Source File: SpringHibernateTransactionOperations.java    From micronaut-data with Apache License 2.0 5 votes vote down vote up
@Override
public <R> R executeRead(@NonNull TransactionCallback<Connection, R> callback) {
    ArgumentUtils.requireNonNull("callback", callback);
    return readTransactionTemplate.execute(status -> {
                try {
                    return callback.call(new JpaTransactionStatus(status));
                } catch (RuntimeException | Error ex) {
                    throw ex;
                } catch (Exception e) {
                    throw new UndeclaredThrowableException(e, "TransactionCallback threw undeclared checked exception");
                }
            }
    );
}
 
Example 5
Source File: DefaultQuery.java    From micronaut-data with Apache License 2.0 5 votes vote down vote up
/**
 * Adds the specified criterion instance to the query.
 *
 * @param criterion The criterion instance
 */
@Override
public @NonNull
QueryModel add(@NonNull QueryModel.Criterion criterion) {
    ArgumentUtils.requireNonNull("criterion", criterion);
    QueryModel.Junction currentJunction = criteria;
    add(currentJunction, criterion);
    return this;
}
 
Example 6
Source File: SpringHibernateTransactionOperations.java    From micronaut-data with Apache License 2.0 5 votes vote down vote up
@Override
public <R> R executeWrite(@NonNull TransactionCallback<Connection, R> callback) {
    ArgumentUtils.requireNonNull("callback", callback);
    return writeTransactionTemplate.execute(status -> {
                try {
                    return callback.call(new JpaTransactionStatus(status));
                } catch (RuntimeException | Error ex) {
                    throw ex;
                } catch (Exception e) {
                    throw new UndeclaredThrowableException(e, "TransactionCallback threw undeclared checked exception");
                }
            }
    );
}
 
Example 7
Source File: KafkaConsumerProcessor.java    From micronaut-kafka with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public <K, V> Consumer<K, V> getConsumer(@Nonnull String id) {
    ArgumentUtils.requireNonNull("id", id);
    final Consumer consumer = consumers.get(id);
    if (consumer == null) {
        throw new IllegalArgumentException("No consumer found for ID: " + id);
    }
    return consumer;
}
 
Example 8
Source File: NamingStrategy.java    From micronaut-data with Apache License 2.0 5 votes vote down vote up
/**
 * Return the mapped name for the given entity.
 * @param entity The entity
 * @return The mapped name
 */
default @NonNull String mappedName(@NonNull PersistentEntity entity) {
    ArgumentUtils.requireNonNull("entity", entity);
    return entity.getAnnotationMetadata().stringValue(MappedEntity.class)
            .filter(StringUtils::isNotEmpty)
            .orElseGet(() -> mappedName(entity.getSimpleName()));
}
 
Example 9
Source File: MicronautAwsProxyResponse.java    From micronaut-aws with Apache License 2.0 5 votes vote down vote up
@Override
public MutableHttpHeaders add(CharSequence header, CharSequence value) {
    ArgumentUtils.requireNonNull("header", header);
    ArgumentUtils.requireNonNull("value", value);
    multiValueHeaders.add(header.toString(), value.toString());
    return this;
}
 
Example 10
Source File: GoogleMultiValueMap.java    From micronaut-gcp with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public String get(CharSequence name) {
    ArgumentUtils.requireNonNull("name", name);

    final List<String> values = map.get(name.toString());
    if (values != null) {
        final Iterator<String> i = values.iterator();
        if (i.hasNext()) {
            return i.next();
        }
    }
    return null;
}
 
Example 11
Source File: MicronautAwsProxyResponse.java    From micronaut-aws with Apache License 2.0 4 votes vote down vote up
@Override
public MutableHttpHeaders remove(CharSequence header) {
    ArgumentUtils.requireNonNull("header", header);
    multiValueHeaders.remove(header.toString());
    return this;
}
 
Example 12
Source File: GoogleCredentialsFactory.java    From micronaut-gcp with Apache License 2.0 4 votes vote down vote up
/**
 * Default constructor.
 * @param configuration The configuration
 */
public GoogleCredentialsFactory(@Nonnull GoogleCredentialsConfiguration configuration) {
    ArgumentUtils.requireNonNull("configuration", configuration);
    this.configuration = configuration;
}
 
Example 13
Source File: GoogleMultiValueMap.java    From micronaut-gcp with Apache License 2.0 4 votes vote down vote up
@Override
public List<String> getAll(CharSequence name) {
    ArgumentUtils.requireNonNull("name", name);
    return map.getOrDefault(name.toString(), Collections.emptyList());
}
 
Example 14
Source File: MicronautBeanFactoryConfiguration.java    From micronaut-spring with Apache License 2.0 4 votes vote down vote up
/**
 * The bean types to exclude from being exposed by Spring's {@link org.springframework.beans.factory.BeanFactory} interface.
 * @param beanExcludes The bean types
 */
public void setBeanExcludes(@Nonnull List<Class<?>> beanExcludes) {
    ArgumentUtils.requireNonNull("beanExcludes", beanExcludes);
    this.beanExcludes = beanExcludes;
}
 
Example 15
Source File: GoogleFunctionHttpResponse.java    From micronaut-gcp with Apache License 2.0 4 votes vote down vote up
@Override
public MutableHttpHeaders remove(CharSequence header) {
    ArgumentUtils.requireNonNull("header", header);
    response.getHeaders().remove(header.toString());
    return this;
}
 
Example 16
Source File: GoogleFunctionHttpRequest.java    From micronaut-gcp with Apache License 2.0 4 votes vote down vote up
@Override
public Optional<String> getFirst(CharSequence name) {
    ArgumentUtils.requireNonNull("name", name);
    return googleRequest.getFirstQueryParameter(name.toString());
}
 
Example 17
Source File: QueryParameter.java    From micronaut-data with Apache License 2.0 4 votes vote down vote up
/**
 * Default constructor.
 * @param name The parameter name
 */
public QueryParameter(@NonNull String name) {
    ArgumentUtils.requireNonNull("name", name);
    this.name = name;
}
 
Example 18
Source File: MicronautLambdaContainerHandler.java    From micronaut-aws with Apache License 2.0 2 votes vote down vote up
/**
 * Gets a new {@link MicronautLambdaContainerHandler} should be called exactly once.
 *
 * @param builder The builder to customize the context creation
 * @return The {@link MicronautLambdaContainerHandler}
 * @throws ContainerInitializationException if the container couldn't be started
 * @deprecated Use {@link #MicronautLambdaContainerHandler(ApplicationContextBuilder)} instead
 */
@Deprecated
public static MicronautLambdaContainerHandler getAwsProxyHandler(ApplicationContextBuilder builder) throws ContainerInitializationException {
    ArgumentUtils.requireNonNull("builder", builder);
    return new MicronautLambdaContainerHandler(new LambdaContainerState(), builder);
}
 
Example 19
Source File: ExecutorReactiveOperations.java    From micronaut-data with Apache License 2.0 2 votes vote down vote up
/**
 * Default constructor.
 *
 * @param asyncOperations The instance operations instance
 */
public ExecutorReactiveOperations(@NonNull ExecutorAsyncOperations asyncOperations) {
    ArgumentUtils.requireNonNull("asyncOperations", asyncOperations);
    this.asyncOperations = asyncOperations;
}
 
Example 20
Source File: QueryModel.java    From micronaut-data with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a query from the given entity.
 *
 * @param entity The entity
 * @return The query
 */
static @NonNull
QueryModel from(@NonNull PersistentEntity entity) {
    ArgumentUtils.requireNonNull("entity", entity);
    return new DefaultQuery(entity);
}