Skip to content

Commit

Permalink
#318 Break lines that exceed 120 chars
Browse files Browse the repository at this point in the history
  • Loading branch information
ljacqu committed Jun 20, 2023
1 parent 0a1cb3e commit 9f33830
Show file tree
Hide file tree
Showing 26 changed files with 101 additions and 52 deletions.
9 changes: 6 additions & 3 deletions src/main/java/ch/jalu/configme/SettingsManagerBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ private SettingsManagerBuilder(@NotNull PropertyResource resource) {
* @param resourceOptions the resource options
* @return settings manager builder
*/
public static @NotNull SettingsManagerBuilder withYamlFile(@NotNull Path path, @NotNull YamlFileResourceOptions resourceOptions) {
public static @NotNull SettingsManagerBuilder withYamlFile(@NotNull Path path,
@NotNull YamlFileResourceOptions resourceOptions) {
Utils.createFileIfNotExists(path);
return new SettingsManagerBuilder(new YamlFileResource(path, resourceOptions));
}
Expand All @@ -67,7 +68,8 @@ private SettingsManagerBuilder(@NotNull PropertyResource resource) {
* @param resourceOptions the resource options
* @return settings manager builder
*/
public static @NotNull SettingsManagerBuilder withYamlFile(@NotNull File file, @NotNull YamlFileResourceOptions resourceOptions) {
public static @NotNull SettingsManagerBuilder withYamlFile(@NotNull File file,
@NotNull YamlFileResourceOptions resourceOptions) {
return withYamlFile(file.toPath(), resourceOptions);
}

Expand All @@ -88,7 +90,8 @@ private SettingsManagerBuilder(@NotNull PropertyResource resource) {
* @return this builder
*/
@SafeVarargs
public final @NotNull SettingsManagerBuilder configurationData(@NotNull Class<? extends SettingsHolder>... classes) {
public final @NotNull SettingsManagerBuilder configurationData(
@NotNull Class<? extends SettingsHolder>... classes) {
this.configurationData = ConfigurationDataBuilder.createConfiguration(classes);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public ConfigMeMapperException(@NotNull MappingContext mappingContext, @NotNull
* @param message basic message to extend
* @param cause the cause
*/
public ConfigMeMapperException(@NotNull MappingContext mappingContext, @NotNull String message, @Nullable Throwable cause) {
public ConfigMeMapperException(@NotNull MappingContext mappingContext, @NotNull String message,
@Nullable Throwable cause) {
super(constructMessage(mappingContext, message), cause);
}

Expand Down
6 changes: 4 additions & 2 deletions src/main/java/ch/jalu/configme/beanmapper/Mapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public interface Mapper {
* @param errorRecorder error recorder to register errors even if a valid value is returned
* @return object of the given type, or null if not possible
*/
@Nullable Object convertToBean(@Nullable Object value, @NotNull TypeInformation typeInformation, @NotNull ConvertErrorRecorder errorRecorder);
@Nullable Object convertToBean(@Nullable Object value, @NotNull TypeInformation typeInformation,
@NotNull ConvertErrorRecorder errorRecorder);

/**
* Converts the given value to an object of the given class, if possible. Returns null otherwise.
Expand All @@ -36,7 +37,8 @@ public interface Mapper {
*/
@Nullable
@SuppressWarnings("unchecked")
default <T> T convertToBean(@Nullable Object value, @NotNull Class<T> clazz, @NotNull ConvertErrorRecorder errorRecorder) {
default <T> T convertToBean(@Nullable Object value, @NotNull Class<T> clazz,
@NotNull ConvertErrorRecorder errorRecorder) {
return (T) convertToBean(value, new TypeInformation(clazz), errorRecorder);
}

Expand Down
9 changes: 6 additions & 3 deletions src/main/java/ch/jalu/configme/beanmapper/MapperImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ public MapperImpl() {
this(new BeanDescriptionFactoryImpl(), StandardLeafValueHandlers.getDefaultLeafValueHandler());
}

public MapperImpl(@NotNull BeanDescriptionFactory beanDescriptionFactory, @NotNull LeafValueHandler leafValueHandler) {
public MapperImpl(@NotNull BeanDescriptionFactory beanDescriptionFactory,
@NotNull LeafValueHandler leafValueHandler) {
this.beanDescriptionFactory = beanDescriptionFactory;
this.leafValueHandler = leafValueHandler;
}
Expand All @@ -77,7 +78,8 @@ public MapperImpl(@NotNull BeanDescriptionFactory beanDescriptionFactory, @NotNu
return leafValueHandler;
}

protected @NotNull MappingContext createRootMappingContext(@NotNull TypeInformation beanType, @NotNull ConvertErrorRecorder errorRecorder) {
protected @NotNull MappingContext createRootMappingContext(@NotNull TypeInformation beanType,
@NotNull ConvertErrorRecorder errorRecorder) {
return MappingContextImpl.createRoot(beanType, errorRecorder);
}

Expand Down Expand Up @@ -151,7 +153,8 @@ public MapperImpl(@NotNull BeanDescriptionFactory beanDescriptionFactory, @NotNu
// ---------

@Override
public @Nullable Object convertToBean(@Nullable Object value, @NotNull TypeInformation beanType, @NotNull ConvertErrorRecorder errorRecorder) {
public @Nullable Object convertToBean(@Nullable Object value, @NotNull TypeInformation beanType,
@NotNull ConvertErrorRecorder errorRecorder) {
if (value == null) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public class MappingContextImpl implements MappingContext {
private final TypeInformation typeInformation;
private final ConvertErrorRecorder errorRecorder;

protected MappingContextImpl(@NotNull String path, @NotNull TypeInformation typeInformation, @NotNull ConvertErrorRecorder errorRecorder) {
protected MappingContextImpl(@NotNull String path, @NotNull TypeInformation typeInformation,
@NotNull ConvertErrorRecorder errorRecorder) {
this.path = path;
this.typeInformation = typeInformation;
this.errorRecorder = errorRecorder;
Expand All @@ -26,7 +27,8 @@ protected MappingContextImpl(@NotNull String path, @NotNull TypeInformation type
* @param errorRecorder error recorder to register errors even if a valid value is returned
* @return root mapping context
*/
public static @NotNull MappingContextImpl createRoot(@NotNull TypeInformation typeInformation, @NotNull ConvertErrorRecorder errorRecorder) {
public static @NotNull MappingContextImpl createRoot(@NotNull TypeInformation typeInformation,
@NotNull ConvertErrorRecorder errorRecorder) {
return new MappingContextImpl("", typeInformation, errorRecorder);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ public class BeanDescriptionFactoryImpl implements BeanDescriptionFactory {
* @param clazz the class to which the properties belong
* @param properties the properties that will be used on the class
*/
protected void validateProperties(@NotNull Class<?> clazz, @NotNull Collection<BeanPropertyDescription> properties) {
protected void validateProperties(@NotNull Class<?> clazz,
@NotNull Collection<BeanPropertyDescription> properties) {
Set<String> names = new HashSet<>(properties.size());
properties.forEach(property -> {
if (property.getName().isEmpty()) {
Expand Down Expand Up @@ -151,7 +152,8 @@ protected void validateProperties(@NotNull Class<?> clazz, @NotNull Collection<B
* @param properties the properties to sort
* @return sorted properties
*/
protected @NotNull List<PropertyDescriptor> sortPropertiesList(@NotNull Class<?> clazz, @NotNull List<PropertyDescriptor> properties) {
protected @NotNull List<PropertyDescriptor> sortPropertiesList(@NotNull Class<?> clazz,
@NotNull List<PropertyDescriptor> properties) {
Map<String, Integer> fieldNameByIndex = createFieldNameOrderMap(clazz);
int maxIndex = fieldNameByIndex.size();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public class BeanPropertyDescriptionImpl implements BeanPropertyDescription {
* @param getter getter for the property
* @param setter setter for the property
*/
public BeanPropertyDescriptionImpl(@NotNull String name, @NotNull TypeInformation typeInformation, @NotNull Method getter, @NotNull Method setter) {
public BeanPropertyDescriptionImpl(@NotNull String name, @NotNull TypeInformation typeInformation,
@NotNull Method getter, @NotNull Method setter) {
this.name = name;
this.typeInformation = typeInformation;
this.getter = getter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ protected ConfigurationDataBuilder() {
* @param classes the classes to scan for their property data
* @return collected configuration data
*/
public static @NotNull ConfigurationData createConfiguration(@NotNull Iterable<Class<? extends SettingsHolder>> classes) {
public static @NotNull ConfigurationData createConfiguration(
@NotNull Iterable<Class<? extends SettingsHolder>> classes) {
ConfigurationDataBuilder builder = new ConfigurationDataBuilder();
return builder.collectData(classes);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public class ConfigurationDataImpl implements ConfigurationData {
* @param allProperties all known properties
* @param allComments map of comments by path
*/
protected ConfigurationDataImpl(@NotNull List<? extends Property<?>> allProperties, @NotNull Map<String, List<String>> allComments) {
protected ConfigurationDataImpl(@NotNull List<? extends Property<?>> allProperties,
@NotNull Map<String, List<String>> allComments) {
this.properties = Collections.unmodifiableList(allProperties);
this.allComments = Collections.unmodifiableMap(allComments);
this.values = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ protected boolean performMigrations(@NotNull PropertyReader reader, @NotNull Con
* @param <T> the type of the property
* @return true if the old path exists in the configuration file, false otherwise
*/
protected static <T> boolean moveProperty(@NotNull Property<T> oldProperty, @NotNull Property<T> newProperty,
@NotNull PropertyReader reader, @NotNull ConfigurationData configurationData) {
protected static <T> boolean moveProperty(@NotNull Property<T> oldProperty,
@NotNull Property<T> newProperty,
@NotNull PropertyReader reader,
@NotNull ConfigurationData configurationData) {
if (reader.contains(oldProperty.getPath())) {
if (!reader.contains(newProperty.getPath())) {
PropertyValue<T> value = oldProperty.determineValue(reader);
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/ch/jalu/configme/properties/ArrayProperty.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public class ArrayProperty<T> extends BaseProperty<T[]> {
* @param type the property type
* @param arrayProducer array constructor (desired array size as argument)
*/
public ArrayProperty(@NotNull String path, T @NotNull [] defaultValue, @NotNull PropertyType<T> type, @NotNull IntFunction<T[]> arrayProducer) {
public ArrayProperty(@NotNull String path, T @NotNull [] defaultValue, @NotNull PropertyType<T> type,
@NotNull IntFunction<T[]> arrayProducer) {
super(path, defaultValue);
Objects.requireNonNull(type, "type");
Objects.requireNonNull(arrayProducer, "arrayProducer");
Expand All @@ -32,7 +33,8 @@ public ArrayProperty(@NotNull String path, T @NotNull [] defaultValue, @NotNull
}

@Override
protected T @Nullable [] getFromReader(@NotNull PropertyReader reader, @NotNull ConvertErrorRecorder errorRecorder) {
protected T @Nullable [] getFromReader(@NotNull PropertyReader reader,
@NotNull ConvertErrorRecorder errorRecorder) {
Object object = reader.getObject(this.getPath());
if (object instanceof Collection<?>) {
Collection<?> collection = (Collection<?>) object;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/ch/jalu/configme/properties/BaseProperty.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ public boolean isValidValue(@Nullable T value) {
* @param errorRecorder error recorder to register errors even if a valid value is returned
* @return value based on the reader, or null if not applicable
*/
protected abstract @Nullable T getFromReader(@NotNull PropertyReader reader, @NotNull ConvertErrorRecorder errorRecorder);
protected abstract @Nullable T getFromReader(@NotNull PropertyReader reader,
@NotNull ConvertErrorRecorder errorRecorder);

@Override
public @NotNull String toString() {
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/ch/jalu/configme/properties/BeanProperty.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public BeanProperty(@NotNull Class<T> beanType, @NotNull String path, @NotNull T
this(beanType, path, defaultValue, DefaultMapper.getInstance());
}

public BeanProperty(@NotNull Class<T> beanType, @NotNull String path, @NotNull T defaultValue, @NotNull Mapper mapper) {
public BeanProperty(@NotNull Class<T> beanType, @NotNull String path, @NotNull T defaultValue,
@NotNull Mapper mapper) {
super(path, defaultValue, BeanPropertyType.of(beanType, mapper));
}

Expand All @@ -26,7 +27,8 @@ public BeanProperty(@NotNull Class<T> beanType, @NotNull String path, @NotNull T
* @param defaultValue the default value
* @param mapper the mapper to map with
*/
protected BeanProperty(@NotNull TypeInformation beanType, @NotNull String path, @NotNull T defaultValue, @NotNull Mapper mapper) {
protected BeanProperty(@NotNull TypeInformation beanType, @NotNull String path, @NotNull T defaultValue,
@NotNull Mapper mapper) {
super(path, defaultValue, new BeanPropertyType<>(beanType, mapper));
if (!beanType.getSafeToWriteClass().isInstance(defaultValue)) {
throw new ConfigMeException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@ public class InlineArrayProperty<T> extends BaseProperty<T[]> {
* @param defaultValue the default value of the property
* @param inlineConverter the inline converter to use
*/
public InlineArrayProperty(@NotNull String path, T @NotNull [] defaultValue, @NotNull InlineArrayConverter<T> inlineConverter) {
public InlineArrayProperty(@NotNull String path, T @NotNull [] defaultValue,
@NotNull InlineArrayConverter<T> inlineConverter) {
super(path, defaultValue);
Objects.requireNonNull(inlineConverter, "inlineConverter");
this.inlineConverter = inlineConverter;
}

@Override
protected T @Nullable [] getFromReader(@NotNull PropertyReader reader, @NotNull ConvertErrorRecorder errorRecorder) {
protected T @Nullable [] getFromReader(@NotNull PropertyReader reader,
@NotNull ConvertErrorRecorder errorRecorder) {
String value = reader.getString(getPath());
return value == null ? null : inlineConverter.fromString(value);
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/ch/jalu/configme/properties/ListProperty.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public ListProperty(@NotNull String path, @NotNull PropertyType<T> type, @NotNul
}

@Override
protected @Nullable List<T> getFromReader(@NotNull PropertyReader reader, @NotNull ConvertErrorRecorder errorRecorder) {
protected @Nullable List<T> getFromReader(@NotNull PropertyReader reader,
@NotNull ConvertErrorRecorder errorRecorder) {
List<?> list = reader.getList(getPath());

if (list != null) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/ch/jalu/configme/properties/MapProperty.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public MapProperty(@NotNull String path, @NotNull Map<String, V> defaultValue, @
}

@Override
protected @Nullable Map<String, V> getFromReader(@NotNull PropertyReader reader, @NotNull ConvertErrorRecorder errorRecorder) {
protected @Nullable Map<String, V> getFromReader(@NotNull PropertyReader reader,
@NotNull ConvertErrorRecorder errorRecorder) {
Object rawObject = reader.getObject(getPath());

if (!(rawObject instanceof Map<?, ?>)) {
Expand Down
Loading

0 comments on commit 9f33830

Please sign in to comment.