Skip to content

Commit

Permalink
Finishing touches before release of 1.0.0
Browse files Browse the repository at this point in the history
* Validate SnakeYamlOptions and GsonOptions are not null
* Allow ConfigurationOptions#addSerialisers to take a Collection
  • Loading branch information
A248 committed Oct 26, 2020
1 parent 01d3285 commit ee5f60e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
*/
package space.arim.dazzleconf;

import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

Expand Down Expand Up @@ -199,7 +199,7 @@ public Builder addSerialisers(ValueSerialiser<?>...serialisers) {
* @throws NullPointerException if {@code serialisers} or an element in it is null
* @throws IllegalArgumentException if any serialiser conflicts with an existing one
*/
public Builder addSerialisers(List<ValueSerialiser<?>> serialisers) {
public Builder addSerialisers(Collection<ValueSerialiser<?>> serialisers) {
Objects.requireNonNull(serialisers, "serialisers");
for (ValueSerialiser<?> serialiser : serialisers) {
addSerialiser(serialiser);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.io.Writer;
import java.nio.charset.Charset;
import java.util.Map;
import java.util.Objects;

import com.google.gson.Gson;
import com.google.gson.JsonIOException;
Expand Down Expand Up @@ -55,13 +56,13 @@ public class GsonConfigurationFactory<C> extends AbstractConfigurationFactory<C>
* @param configClazz the config class
* @param options the config options
* @param gsonOptions the gson options
* @throws NullPointerException if {@code configClazz} or {@code options} is null
* @throws NullPointerException if {@code configClazz}, {@code options}, or {@code gsonOptions} is null
* @throws IllegalArgumentException if {@code configClazz} is not an interface
* @throws IllDefinedConfigException if a configuration entry in {@code configClazz} is not defined properly
*/
public GsonConfigurationFactory(Class<C> configClazz, ConfigurationOptions options, GsonOptions gsonOptions) {
super(configClazz, options);
this.gsonOptions = gsonOptions;
this.gsonOptions = Objects.requireNonNull(gsonOptions, "gsonOptions");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.io.Writer;
import java.nio.charset.Charset;
import java.util.Map;
import java.util.Objects;

import org.yaml.snakeyaml.error.YAMLException;

Expand All @@ -49,13 +50,13 @@ public class SnakeYamlConfigurationFactory<C> extends AbstractConfigurationFacto
* @param configClazz the config class
* @param options the config options
* @param yamlOptions the snake yaml options
* @throws NullPointerException if {@code configClazz} or {@code options} is null
* @throws NullPointerException if {@code configClazz}, {@code options}, or {@code yamlOptions} is null
* @throws IllegalArgumentException if {@code configClazz} is not an interface
* @throws IllDefinedConfigException if a configuration entry in {@code configClazz} is not defined properly
*/
public SnakeYamlConfigurationFactory(Class<C> configClazz, ConfigurationOptions options, SnakeYamlOptions yamlOptions) {
super(configClazz, options);
this.yamlOptions = yamlOptions;
this.yamlOptions = Objects.requireNonNull(yamlOptions, "yamlOptions");
}

/**
Expand Down

0 comments on commit ee5f60e

Please sign in to comment.