Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/code cleanup #112

Merged
merged 3 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public SecretsManagerClient getSecretsClient() {

/**
* Set the SecretsManagerClient to use to communicate with AWS.
* If this is not set, then you must provide the region and
* If this is not set, then you must provide the region, and
* it will be constructed using defaults.
*
* @param secretsClient Set the SecretsManagerClient to use to communicate with AWS.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* @author Colin Redmond (c) 2023.
*/
public class AWSModuleConfig implements GestaltModuleConfig {
public final class AWSModuleConfig implements GestaltModuleConfig {

private String region;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* @author Colin Redmond (c) 2023.
*/
public class AWSValidationErrors {
public final class AWSValidationErrors {

public static class AWSModuleConfigNotSet extends ValidationError {
private final String path;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
* @author <a href="mailto:colin.redmond@outlook.com"> Colin Redmond </a> (c) 2023.
*/
public class S3ConfigSource implements ConfigSource {
public final class S3ConfigSource implements ConfigSource {

private final S3Client s3;
private final String keyName;
Expand Down Expand Up @@ -114,7 +114,7 @@ public String format() {
* @param fileName the name of the file
* @return the extension of the file
*/
protected String format(String fileName) {
private String format(String fileName) {
int index = fileName.lastIndexOf('.');
if (index > 0) {
return fileName.substring(index + 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
* @author <a href="mailto:colin.redmond@outlook.com"> Colin Redmond </a> (c) 2023.
*/
public class AWSSecretTransformer implements Transformer {
public final class AWSSecretTransformer implements Transformer {

private static final System.Logger logger = System.getLogger(AWSSecretTransformer.class.getName());
private final ObjectMapper mapper = new ObjectMapper();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void createAWSConfigClient() throws GestaltConfigurationException {
}

@Test
public void createAWSConfigEmpty() throws GestaltConfigurationException {
public void createAWSConfigEmpty() {

AWSBuilder builder = AWSBuilder.builder();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import org.github.gestalt.config.exceptions.GestaltException;
import org.github.gestalt.config.tag.Tags;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.testcontainers.junit.jupiter.Testcontainers;
Expand All @@ -19,10 +18,6 @@ class S3ConfigSourceMockTest {

private final S3Client s3Client = Mockito.mock();

@BeforeEach
void setUp() {
}

@Test
void idTest() throws GestaltException {
S3ConfigSource source = new S3ConfigSource(s3Client, BUCKET_NAME, "test");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.Objects;

public class ConfigClassWithPrefix {
public final class ConfigClassWithPrefix {
private final Class<?> klass;
private final String prefix;

Expand All @@ -25,14 +25,12 @@ public String getPrefix() {

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
} else if (!(o instanceof ConfigClassWithPrefix)) {
ConfigClassWithPrefix that = (ConfigClassWithPrefix) o;
return this.klass.equals(that.klass) && this.prefix.equals(that.prefix);
} else {
if (this == o) return true;
if (!(o instanceof ConfigClassWithPrefix)) {
return false;
}
ConfigClassWithPrefix that = (ConfigClassWithPrefix) o;
return Objects.equals(klass, that.klass) && Objects.equals(prefix, that.prefix);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.github.gestalt.config.cdi;

public class GestaltConfigException extends RuntimeException {
public final class GestaltConfigException extends RuntimeException {
private final String configPropertyName;

public GestaltConfigException(String message) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
* @author <a href="mailto:struberg@yahoo.de">Mark Struberg</a>
* @author <a href="mailto:colin.redmond@outlook.com"> Colin Redmond </a> (c) 2023.
*/
public class GestaltConfigInjectionBean<T> implements Bean<T>, PassivationCapable {
public final class GestaltConfigInjectionBean<T> implements Bean<T>, PassivationCapable {

private static final Set<Annotation> QUALIFIERS = new HashSet<>();

Expand Down Expand Up @@ -101,7 +101,7 @@ public T create(CreationalContext<T> context) {
}
} else {
Class<?> annotatedTypeClass = (Class<?>) annotated.getBaseType();
if (defaultValue.length() == 0) {
if (defaultValue.isEmpty()) {
return (T) getConfig().getConfig(key, annotatedTypeClass);
} else {
Optional<T> optionalValue = (Optional<T>) getConfig().getConfigOptional(key, annotatedTypeClass);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* Based on https://github.com/smallrye/smallrye-config/tree/3.1.1/cdi
*/
public class GestaltConfigsInjectionBean<T> implements Bean<T> {
public final class GestaltConfigsInjectionBean<T> implements Bean<T> {
private final ConfigClassWithPrefix configClassWithPrefix;
private final Set<Annotation> qualifiers;

Expand Down
2 changes: 2 additions & 0 deletions gestalt-core/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
exports org.github.gestalt.config.path.mapper;
exports org.github.gestalt.config.post.process;
exports org.github.gestalt.config.post.process.transform;
exports org.github.gestalt.config.post.process.transform.substitution;
exports org.github.gestalt.config.reflect;
exports org.github.gestalt.config.reload;
exports org.github.gestalt.config.source;
Expand Down Expand Up @@ -89,3 +90,4 @@
org.github.gestalt.config.post.process.transform.URLDecoderTransformer,
org.github.gestalt.config.post.process.transform.URLEncoderTransformer;
}

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* @param <T> type of array
* @author <a href="mailto:colin.redmond@outlook.com"> Colin Redmond </a> (c) 2023.
*/
public class ArrayDecoder<T> implements Decoder<T[]> {
public final class ArrayDecoder<T> implements Decoder<T[]> {

@Override
public Priority priority() {
Expand Down Expand Up @@ -76,7 +76,7 @@ public ValidateOf<T[]> decode(String path, ConfigNode node, TypeCapture<?> type,
* @return ValidateOf array built from the config node
*/
@SuppressWarnings("unchecked")
protected ValidateOf<T[]> arrayDecode(String path, ConfigNode node, TypeCapture<?> klass, DecoderService decoderService) {
private ValidateOf<T[]> arrayDecode(String path, ConfigNode node, TypeCapture<?> klass, DecoderService decoderService) {
List<ValidationError> errors = new ArrayList<>();
T[] results = (T[]) Array.newInstance(klass.getComponentType(), node.size());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
* @author <a href="mailto:colin.redmond@outlook.com"> Colin Redmond </a> (c) 2023.
*/
public class BigDecimalDecoder extends LeafDecoder<BigDecimal> {
public final class BigDecimalDecoder extends LeafDecoder<BigDecimal> {

@Override
public Priority priority() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
* @author <a href="mailto:colin.redmond@outlook.com"> Colin Redmond </a> (c) 2023.
*/
public class BigIntegerDecoder extends LeafDecoder<BigInteger> {
public final class BigIntegerDecoder extends LeafDecoder<BigInteger> {

@Override
public Priority priority() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
* @author <a href="mailto:colin.redmond@outlook.com"> Colin Redmond </a> (c) 2023.
*/
public class BooleanDecoder extends LeafDecoder<Boolean> {
public final class BooleanDecoder extends LeafDecoder<Boolean> {

@Override
public Priority priority() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* @author <a href="mailto:colin.redmond@outlook.com"> Colin Redmond </a> (c) 2023.
*/
public class ByteDecoder extends LeafDecoder<Byte> {
public final class ByteDecoder extends LeafDecoder<Byte> {

@Override
public Priority priority() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
* @author <a href="mailto:colin.redmond@outlook.com"> Colin Redmond </a> (c) 2023.
*/
public class CharDecoder extends LeafDecoder<Character> {
public final class CharDecoder extends LeafDecoder<Character> {

@Override
public Priority priority() {
Expand All @@ -36,7 +36,7 @@ protected ValidateOf<Character> leafDecode(String path, ConfigNode node) {
List<ValidationError> error = new ArrayList<>();

String value = node.getValue().orElse("");
if (value.length() > 0) {
if (!value.isEmpty()) {
results = value.charAt(0);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
* @author <a href="mailto:colin.redmond@outlook.com"> Colin Redmond </a> (c) 2023.
*/
public class DateDecoder extends LeafDecoder<Date> {
public final class DateDecoder extends LeafDecoder<Date> {

private DateTimeFormatter formatter;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*
* @author <a href="mailto:colin.redmond@outlook.com"> Colin Redmond </a> (c) 2023.
*/
public class DecoderRegistry implements DecoderService {
public final class DecoderRegistry implements DecoderService {
private static final System.Logger logger = System.getLogger(GestaltCore.class.getName());

private final ConfigNodeService configNodeService;
Expand Down Expand Up @@ -103,7 +103,7 @@ public void setPathMappers(List<PathMapper> pathMappers) {
* @return a list of decoders that match the class
*/
@SuppressWarnings("rawtypes")
protected <T> List<Decoder> getDecoderForClass(TypeCapture<T> klass) {
<T> List<Decoder> getDecoderForClass(TypeCapture<T> klass) {
return decoders
.stream()
.filter(decoder -> decoder.matches(klass))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*
* @author <a href="mailto:colin.redmond@outlook.com"> Colin Redmond </a> (c) 2023.
*/
public class DoubleDecoder extends LeafDecoder<Double> {
public final class DoubleDecoder extends LeafDecoder<Double> {

@Override
public Priority priority() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
* @author <a href="mailto:colin.redmond@outlook.com"> Colin Redmond </a> (c) 2023.
*/
public class DurationDecoder extends LeafDecoder<Duration> {
public final class DurationDecoder extends LeafDecoder<Duration> {

@Override
public Priority priority() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
* @author <a href="mailto:colin.redmond@outlook.com"> Colin Redmond </a> (c) 2023.
*/
public class EnumDecoder<T extends Enum<T>> extends LeafDecoder<T> {
public final class EnumDecoder<T extends Enum<T>> extends LeafDecoder<T> {

@Override
public Priority priority() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
* @author <a href="mailto:colin.redmond@outlook.com"> Colin Redmond </a> (c) 2023.
*/
public class FileDecoder extends LeafDecoder<File> {
public final class FileDecoder extends LeafDecoder<File> {

@Override
public Priority priority() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*
* @author <a href="mailto:colin.redmond@outlook.com"> Colin Redmond </a> (c) 2023.
*/
public class FloatDecoder extends LeafDecoder<Float> {
public final class FloatDecoder extends LeafDecoder<Float> {

@Override
public Priority priority() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
* @author <a href="mailto:colin.redmond@outlook.com"> Colin Redmond </a> (c) 2023.
*/
public class InstantDecoder extends LeafDecoder<Instant> {
public final class InstantDecoder extends LeafDecoder<Instant> {

@Override
public Priority priority() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*
* @author <a href="mailto:colin.redmond@outlook.com"> Colin Redmond </a> (c) 2023.
*/
public class IntegerDecoder extends LeafDecoder<Integer> {
public final class IntegerDecoder extends LeafDecoder<Integer> {

@Override
public Priority priority() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*
* @author <a href="mailto:colin.redmond@outlook.com"> Colin Redmond </a> (c) 2023.
*/
public class ListDecoder extends CollectionDecoder<List<?>> {
public final class ListDecoder extends CollectionDecoder<List<?>> {

@Override
public String name() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
* @author <a href="mailto:colin.redmond@outlook.com"> Colin Redmond </a> (c) 2023.
*/
public class LocalDateDecoder extends LeafDecoder<LocalDate> {
public final class LocalDateDecoder extends LeafDecoder<LocalDate> {

private DateTimeFormatter formatter;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
* @author <a href="mailto:colin.redmond@outlook.com"> Colin Redmond </a> (c) 2023.
*/
public class LocalDateTimeDecoder extends LeafDecoder<LocalDateTime> {
public final class LocalDateTimeDecoder extends LeafDecoder<LocalDateTime> {

private DateTimeFormatter formatter;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*
* @author <a href="mailto:colin.redmond@outlook.com"> Colin Redmond </a> (c) 2023.
*/
public class LongDecoder extends LeafDecoder<Long> {
public final class LongDecoder extends LeafDecoder<Long> {

@Override
public Priority priority() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
* @author <a href="mailto:colin.redmond@outlook.com"> Colin Redmond </a> (c) 2023.
*/
public class MapDecoder implements Decoder<Map<?, ?>> {
public final class MapDecoder implements Decoder<Map<?, ?>> {

@Override
public Priority priority() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*
* @author <a href="mailto:colin.redmond@outlook.com"> Colin Redmond </a> (c) 2023.
*/
public class ObjectDecoder implements Decoder<Object> {
public final class ObjectDecoder implements Decoder<Object> {
private static final System.Logger logger = System.getLogger(ObjectDecoder.class.getName());

private final Set<Class<?>> ignoreTypes;
Expand Down Expand Up @@ -175,7 +175,7 @@ public ValidateOf<Object> decode(String path, ConfigNode node, TypeCapture<?> ty
private Object getObject(Object obj, Field field, Class<?> klass) throws IllegalAccessException {

String methodName;
if (field.getType().equals(boolean.class) || field.getType().equals(Boolean.TYPE)) {
if (field.getType().equals(boolean.class)) {
methodName = "is" + field.getName();
} else {
methodName = "get" + field.getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*
* @author <a href="mailto:colin.redmond@outlook.com"> Colin Redmond </a> (c) 2023.
*/
public class OptionalDecoder implements Decoder<Optional<?>> {
public final class OptionalDecoder implements Decoder<Optional<?>> {

@Override
public Priority priority() {
Expand Down
Loading