Skip to content

Commit

Permalink
Checkstyle upgrade (helidon-io#3642)
Browse files Browse the repository at this point in the history
* Upgrade checkstyle to support records.
  • Loading branch information
tomas-langer authored Nov 15, 2021
1 parent 1f3fdf7 commit 9206bc0
Show file tree
Hide file tree
Showing 17 changed files with 272 additions and 6 deletions.
6 changes: 6 additions & 0 deletions config/config/src/main/java/io/helidon/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,12 @@ interface Key extends Comparable<Key> {
@Override
String toString();

/**
* Create a child key to the current key.
*
* @param key child key (relative to current key)
* @return a new resolved key
*/
Key child(Key key);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ interface ChangeEvent<T> {
*/
ChangeEventType type();

/**
* Create a new change event.
*
* @param target target of the change
* @param type event type
* @param instant time the event occurred
* @param <T> type of the target
* @return a new typed change event
*/
static <T> ChangeEvent<T> create(T target, ChangeEventType type, Instant instant) {
return new ChangeEvent<>() {
@Override
Expand All @@ -105,6 +114,14 @@ public String toString() {
};
}

/**
* Create a new change event that occurred right now.
*
* @param target target of the change
* @param type event type
* @param <T> type of the target
* @return a new typed change event
*/
static <T> ChangeEvent<T> create(T target, ChangeEventType type) {
return create(target, type, Instant.now());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ static Builder builder() {
*/
OverrideSource.OverrideData data();

/**
* Fluent API builder for {@link io.helidon.config.spi.ConfigContent}.
*/
class Builder extends ConfigContent.Builder<Builder> implements io.helidon.common.Builder<Builder, OverrideContent> {
// override data
private OverrideSource.OverrideData data;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020 Oracle and/or its affiliates.
* Copyright (c) 2020, 2021 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -52,8 +52,20 @@ public interface PollableSource<S> {
* @see io.helidon.config.AbstractConfigSource
*/
interface Builder<T extends Builder<T>> {
/**
* Configure the polling strategy to use.
*
* @param pollingStrategy polling strategy
* @return updated builder
*/
T pollingStrategy(PollingStrategy pollingStrategy);

/**
* Configure the polling strategy to use.
*
* @param pollingStrategy supplier of polling strategy (such as its builder)
* @return updated builder
*/
default T pollingStrategy(Supplier<? extends PollingStrategy> pollingStrategy) {
return pollingStrategy(pollingStrategy.get());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@
* Class that represents not-set default values.
*/
interface None extends Supplier<Void> {
/**
* Value to use when a {@code null} value should be the default.
*/
String VALUE = "io.helidon.config:default=null";

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ private List<HikariCpExtension> extensions() {
.collect(Collectors.toList());
}

/**
* Update builder from configuration.
*
* @param config configuration
* @return updated builder
*/
public Builder config(Config config) {
Map<String, String> poolConfig = config.detach().asMap().get();
poolConfig.forEach((key, value) -> {
Expand All @@ -182,21 +188,45 @@ public Builder config(Config config) {
return this;
}

/**
* Connection pool URL string.
*
* @param url connection pool string to use
* @return updated builder
*/
public Builder url(String url) {
this.url = url;
return this;
}

/**
* Connection pool username.
*
* @param username username to use
* @return updated builder
*/
public Builder username(String username) {
this.username = username;
return this;
}

/**
* Connection pool password.
*
* @param password password to use
* @return updated builder
*/
public Builder password(String password) {
this.password = password;
return this;
}

/**
* Configure connection pool properties.
*
* @param properties properties to use
* @return updated builder
*/
public Builder properties(Properties properties) {
this.properties = properties;
return this;
Expand Down
2 changes: 1 addition & 1 deletion etc/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
<!-- Checks for Javadoc comments. -->
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
<module name="JavadocMethod">
<property name="scope" value="protected"/>
<property name="accessModifiers" value="public, protected"/>
<property name="validateThrows" value="false"/>
</module>
<module name="MissingJavadocMethod">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,11 @@ private JitterRetryPolicy(Builder builder) {
}
}

/**
* A new fluent API builder to configure instances of {@link io.helidon.faulttolerance.Retry}.
*
* @return a new builder
*/
public static Builder builder() {
return new Builder();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,13 @@ final class Builder implements io.helidon.common.Builder<Builder, GrpcServerConf
private Builder() {
}

public GrpcServerConfiguration.Builder config(Config config) {
/**
* Update the builder from configuration.
*
* @param config configuration instance
* @return updated builder
*/
public Builder config(Config config) {
if (config == null) {
return this;
}
Expand Down Expand Up @@ -220,7 +226,8 @@ public Builder context(Context context) {
}

/**
* Sets an <a href="http://opentracing.io">opentracing.io</a> tracer. (Default is {@link GlobalTracer}.)
* Sets an <a href="http://opentracing.io">opentracing.io</a> tracer.
* (Default is {@link GlobalTracer}.)
*
* @param tracer a tracer to set
* @return an updated builder
Expand Down Expand Up @@ -286,6 +293,11 @@ int port() {
return port;
}

/**
* Current Helidon {@link io.helidon.common.context.Context}.
*
* @return current context
*/
public Context context() {
return context;
}
Expand Down
1 change: 1 addition & 0 deletions grpc/server/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@
requires java.logging;

requires jakarta.inject;
requires io.opentracing.util;
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,38 @@ public Builder config(Config config) {
return this;
}

/**
* Replace host prefix.
* Changing host prefix may be a breaking change. This API is designed to work with
* {@link #API_HOST_PREFIX}.
*
* @param prefix prefix to use
* @return updated builder
*/
public Builder hostPrefix(String prefix) {
this.hostPrefix = prefix;
return this;
}

/**
* Replace endpoint to be invoked when contacting OCI.
*
* @param endpoint endpoint to use
* @return updated builder
*/
public Builder endpoint(String endpoint) {
this.endpoint = endpoint;
return this;
}

/**
* Configure API version to use.
* API version is part of the request URI. Changing API version is potentially breaking,
* as this API is designed to work with a specific version (see {@link #API_VERSION}).
*
* @param apiVersion version of the API to use
* @return updated builder
*/
public Builder apiVersion(String apiVersion) {
this.apiVersion = apiVersion;
return this;
Expand All @@ -153,6 +175,12 @@ public Builder updateRestApi(Consumer<OciRestApi.Builder> builderConsumer) {
return this;
}

/**
* Configure REST API to use.
*
* @param restApi OCI rest API
* @return updated builder
*/
public Builder restApi(OciRestApi restApi) {
this.restApi = restApi;
return this;
Expand Down
Loading

0 comments on commit 9206bc0

Please sign in to comment.