Skip to content

Commit

Permalink
Merge version 4.4.0
Browse files Browse the repository at this point in the history
Version 4.4.0
  • Loading branch information
Siroshun09 authored Aug 18, 2021
2 parents 56fbb47 + fda3f30 commit 9b619e8
Show file tree
Hide file tree
Showing 17 changed files with 595 additions and 79 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,31 @@ on: [ push, pull_request ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ '11', '16' ]
steps:
- uses: actions/[email protected]
- name: Set up JDK 11
- name: Set up JDK ${{ matrix.java }}
uses: actions/[email protected]
with:
distribution: 'adopt'
java-version: 11
java-version: ${{ matrix.java }}
- uses: actions/[email protected]
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build with Maven
run: mvn -B package --file pom.xml
- name: Move built jars
- name: Build Project
run: mvn -B package --file pom.xml -Djava.version=${{ matrix.java }}
- name: Move Artifacts
run: |
mkdir staging
mv target staging/parent
mv api/target staging/api
mv yaml/target staging/yaml
- uses: actions/[email protected]
with:
name: Artifacts
name: Artifacts-Java-${{ matrix.java }}
path: staging
6 changes: 3 additions & 3 deletions .github/workflows/update-javadoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Set up JDK 11
- name: Set up JDK 16
uses: actions/[email protected]
with:
distribution: 'adopt'
java-version: 11
java-version: 16
- uses: actions/[email protected]
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build with Maven
run: mvn -B package -D java.version=11 --file pom.xml
run: mvn -B package -Djava.version=16 --file pom.xml
- name: Deploy pages
uses: peaceiris/[email protected]
with:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Javadoc is [here](https://siroshun09.github.io/ConfigAPI/)
<dependency>
<groupId>com.github.siroshun09.configapi</groupId>
<artifactId>configapi</artifactId>
<version>4.3.1</version>
<version>4.4.0</version>
<scope>compile</scope>
</dependency>
```
Expand All @@ -32,7 +32,7 @@ Javadoc is [here](https://siroshun09.github.io/ConfigAPI/)
<dependency>
<groupId>com.github.siroshun09.configapi</groupId>
<artifactId>configapi-yaml</artifactId>
<version>4.3.1</version>
<version>4.4.0</version>
<scope>compile</scope>
</dependency>
```
Expand Down
2 changes: 1 addition & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>com.github.siroshun09.configapi</groupId>
<artifactId>parent</artifactId>
<version>4.3.1</version>
<version>4.4.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public abstract class AbstractConfiguration implements Configuration {
@Override
public @NotNull Object get(@NotNull String path, @NotNull Object def) {
var value = get(path);
return value != null ? value : Objects.requireNonNull(path);
return value != null ? value : Objects.requireNonNull(def);
}

@Override
Expand Down Expand Up @@ -71,7 +71,7 @@ public <T> void set(@NotNull String path, @NotNull T value, @NotNull Serializer<
@Override
public @NotNull @Unmodifiable List<?> getList(@NotNull String path, @NotNull List<?> def) {
var value = get(path);
return value instanceof List<?> ? (List<?>) value : def;
return value instanceof List<?> ? (List<?>) value : Objects.requireNonNull(def);
}

@Override
Expand Down Expand Up @@ -180,7 +180,12 @@ public short getShort(@NotNull String path, short def) {
@Override
public @NotNull String getString(@NotNull String path, @NotNull String def) {
var value = get(path);
return value instanceof String ? (String) value : def;

if (value != null) {
return value instanceof String ? (String) value : value.toString();
} else {
return Objects.requireNonNull(def);
}
}

@Override
Expand Down Expand Up @@ -309,6 +314,7 @@ public short getShort(@NotNull String path, short def) {

if (list != null) {
return list.stream()
.filter(Objects::nonNull)
.map(object -> object instanceof String ? (String) object : object.toString())
.collect(Collectors.toUnmodifiableList());
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,9 @@ public interface Configuration {
*/
<T> void set(@NotNull String path, @NotNull T value, @NotNull Serializer<T, ?> serializer);

/**
* Gets the set of root paths included in this {@link Configuration}.
*
* @return set of root paths
* @deprecated use {@link Configuration#getKeyList()}
*/
@Deprecated(since = "4.3.0", forRemoval = true)
@NotNull @Unmodifiable Set<String> getPaths();

/**
* Gets the list of root keys included in this {@link Configuration}.
*
* <p>
* This method may not return to the correct order depending on the implementation.
*
* @return list of root keys
Expand Down Expand Up @@ -357,7 +348,7 @@ public interface Configuration {
/**
* Gets the string of the specified path.
* <p>
* If the string could not be obtained, this method returns 0.
* If the string could not be obtained, this method returns empty string.
*
* @param path the path to get the string
* @return the string
Expand All @@ -378,6 +369,9 @@ public interface Configuration {
* <p>
* If the boolean list could not be obtained,
* this method returns {@link Collections#emptyList()}.
* <p>
* If the list that obtained from {@link Configuration#getList(String)}
* contains an object that cannot be converted to a boolean, it will be excluded.
*
* @param path the path to get the boolean list
* @return the boolean list
Expand All @@ -386,6 +380,9 @@ public interface Configuration {

/**
* Gets the boolean list of the specified path.
* <p>
* If the list that obtained from {@link Configuration#getList(String)}
* contains an object that cannot be converted to a boolean, it will be excluded.
*
* @param path the path to get the boolean list
* @param def the default boolean list to return if the boolean list could not be obtained
Expand All @@ -398,6 +395,12 @@ public interface Configuration {
* <p>
* If the byte list could not be obtained,
* this method returns {@link Collections#emptyList()}.
* <p>
* If the list that obtained from {@link Configuration#getList(String)}
* contains an object that cannot be converted to a number, it will be excluded.
* <p>
* If the list contains a number that is outside the byte range,
* it will be converted to a byte using {@link Number#byteValue()}.
*
* @param path the path to get the byte list
* @return the byte list
Expand All @@ -406,6 +409,12 @@ public interface Configuration {

/**
* Gets the byte list of the specified path.
* <p>
* If the list that obtained from {@link Configuration#getList(String)}
* contains an object that cannot be converted to a number, it will be excluded.
* <p>
* If the list contains a number that is outside the byte range,
* it will be converted to a byte using {@link Number#byteValue()}.
*
* @param path the path to get the byte list
* @param def the default byte list to return if the byte list could not be obtained
Expand All @@ -418,6 +427,12 @@ public interface Configuration {
* <p>
* If the double list could not be obtained,
* this method returns {@link Collections#emptyList()}.
* <p>
* If the list that obtained from {@link Configuration#getList(String)}
* contains an object that cannot be converted to a number, it will be excluded.
* <p>
* If the list contains a number that is outside the double range,
* it will be converted to a byte using {@link Number#doubleValue()}.
*
* @param path the path to get the double list
* @return the double list
Expand All @@ -426,6 +441,12 @@ public interface Configuration {

/**
* Gets the double list of the specified path.
* <p>
* If the list that obtained from {@link Configuration#getList(String)}
* contains an object that cannot be converted to a number, it will be excluded.
* <p>
* If the list contains a number that is outside the double range,
* it will be converted to a byte using {@link Number#doubleValue()}.
*
* @param path the path to get the double list
* @param def the default double list to return if the double list could not be obtained
Expand All @@ -438,6 +459,12 @@ public interface Configuration {
* <p>
* If the float list could not be obtained,
* this method returns {@link Collections#emptyList()}.
* <p>
* If the list that obtained from {@link Configuration#getList(String)}
* contains an object that cannot be converted to a number, it will be excluded.
* <p>
* If the list contains a number that is outside the float range,
* it will be converted to a byte using {@link Number#floatValue()}.
*
* @param path the path to get the float list
* @return the float list
Expand All @@ -446,6 +473,12 @@ public interface Configuration {

/**
* Gets the float list of the specified path.
* <p>
* If the list that obtained from {@link Configuration#getList(String)}
* contains an object that cannot be converted to a number, it will be excluded.
* <p>
* If the list contains a number that is outside the float range,
* it will be converted to a byte using {@link Number#floatValue()}.
*
* @param path the path to get the float list
* @param def the default float list to return if the float list could not be obtained
Expand All @@ -458,6 +491,12 @@ public interface Configuration {
* <p>
* If the integer list could not be obtained,
* this method returns {@link Collections#emptyList()}.
* <p>
* If the list that obtained from {@link Configuration#getList(String)}
* contains an object that cannot be converted to a number, it will be excluded.
* <p>
* If the list contains a number that is outside the int range,
* it will be converted to a byte using {@link Number#intValue()}.
*
* @param path the path to get the integer list
* @return the integer list
Expand All @@ -466,6 +505,12 @@ public interface Configuration {

/**
* Gets the integer list of the specified path.
* <p>
* If the list that obtained from {@link Configuration#getList(String)}
* contains an object that cannot be converted to a number, it will be excluded.
* <p>
* If the list contains a number that is outside the int range,
* it will be converted to a byte using {@link Number#intValue()}.
*
* @param path the path to get the integer list
* @param def the default integer list to return if the integer list could not be obtained
Expand All @@ -478,6 +523,12 @@ public interface Configuration {
* <p>
* If the long list could not be obtained,
* this method returns {@link Collections#emptyList()}.
* <p>
* If the list that obtained from {@link Configuration#getList(String)}
* contains an object that cannot be converted to a number, it will be excluded.
* <p>
* If the list contains a number that is outside the long range,
* it will be converted to a byte using {@link Number#longValue()}.
*
* @param path the path to get the long list
* @return the long list
Expand All @@ -486,6 +537,12 @@ public interface Configuration {

/**
* Gets the long list of the specified path.
* <p>
* If the list that obtained from {@link Configuration#getList(String)}
* contains an object that cannot be converted to a number, it will be excluded.
* <p>
* If the list contains a number that is outside the long range,
* it will be converted to a byte using {@link Number#longValue()}.
*
* @param path the path to get the long list
* @param def the default long list to return if the long list could not be obtained
Expand All @@ -498,6 +555,12 @@ public interface Configuration {
* <p>
* If the short list could not be obtained,
* this method returns {@link Collections#emptyList()}.
* <p>
* If the list that obtained from {@link Configuration#getList(String)}
* contains an object that cannot be converted to a number, it will be excluded.
* <p>
* If the list contains a number that is outside the short range,
* it will be converted to a byte using {@link Number#shortValue()}.
*
* @param path the path to get the short list
* @return the short list
Expand All @@ -506,6 +569,12 @@ public interface Configuration {

/**
* Gets the short list of the specified path.
* <p>
* If the list that obtained from {@link Configuration#getList(String)}
* contains an object that cannot be converted to a number, it will be excluded.
* <p>
* If the list contains a number that is outside the short range,
* it will be converted to a byte using {@link Number#shortValue()}.
*
* @param path the path to get the short list
* @param def the default short list to return if the short list could not be obtained
Expand All @@ -518,6 +587,10 @@ public interface Configuration {
* <p>
* If the string list could not be obtained,
* this method returns {@link Collections#emptyList()}.
* <p>
* If the list that obtained from {@link Configuration#getList(String)} contains non-string object,
* it will be converted to a string based on {@link Object#toString()}
* or the <code>toString</code> implementation of that object.
*
* @param path the path to get the string list
* @return the string list
Expand All @@ -526,6 +599,10 @@ public interface Configuration {

/**
* Gets the string list of the specified path.
* <p>
* If the list that obtained from {@link Configuration#getList(String)} contains non-string object,
* it will be converted to a string based on {@link Object#toString()}
* or the <code>toString</code> implementation of that object.
*
* @param path the path to get the string list
* @param def the default string list to return if the string list could not be obtained
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,6 @@ public void set(@NotNull String path, @Nullable Object value) {
}
}

@Override
public @NotNull @Unmodifiable Set<String> getPaths() {
return map.keySet().stream()
.map(object -> object instanceof String ? (String) object : object.toString())
.collect(Collectors.toUnmodifiableSet());
}

@Override
public @NotNull @Unmodifiable List<String> getKeyList() {
return map.keySet().stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,6 @@ public void set(@NotNull String path, @Nullable Object value) {
}
}

@Override
public @NotNull @Unmodifiable Set<String> getPaths() {
return properties.keySet()
.stream()
.map(object -> object instanceof String ? (String) object : object.toString())
.collect(Collectors.toUnmodifiableSet());
}

@Override
public @NotNull @Unmodifiable List<String> getKeyList() {
return properties.keySet()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public interface ConfigurationSerializer<T> extends Serializer<T, Configuration>
* Deserializes {@link Configuration}
*
* @param config the config to deserialize
* @return the deserialized value or {@code null} if could not deserialize
* @return the deserialized value or {@code null} if configuration could not be deserialized
*/
@Nullable T deserializeConfiguration(@NotNull Configuration config);
}
Loading

0 comments on commit 9b619e8

Please sign in to comment.