You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This library is very easy to use. It provides a [property](https://github.com/matteobaccan/owner)
22
-
and [json](https://github.com/google/gson) based file stores by default.
21
+
This library is very easy to use. It provides a [property](https://github.com/matteobaccan/owner) and [json](https://github.com/google/gson) based file stores by default.
23
22
24
-
For example, let's say you have this `PersonConfig` config interface (uses property based file store):
23
+
For example, let's say you have this `PersonConfig` config interface (uses the property based file store):
25
24
26
25
```java
27
26
publicinterfacePersonConfigextendsAccessible {
@@ -32,10 +31,10 @@ public interface PersonConfig extends Accessible {
32
31
@DefaultValue("24")
33
32
@key("person.age")
34
33
intgetAge();
35
-
};
34
+
}
36
35
```
37
36
38
-
You'll just have to do:
37
+
You'll just have to do:
39
38
40
39
```java
41
40
FileStore<PersonConfig> store =newConfigFileStore("./john.properties", PersonConfig.class);
@@ -47,13 +46,13 @@ If you call the `load()` method, it will try to load the file if it exists, othe
47
46
48
47
## Tips
49
48
50
-
If you are using the `JsonFileStore`, keep in mind that if the object hold by the store uses generics, you must use
51
-
gson's `TypeToken` for the type such as:
49
+
If you are using the `JsonFileStore`, keep in mind that if the object hold by the store uses generics, you must use gson's `TypeToken` for the type such as :
52
50
53
51
```java
54
-
FileStore<List<Integer>> store =newJsonFileStore("./int-list.json", TypeToken.getParameterized(List.class, Integer.class).getType(), ArrayList::new);
52
+
Type type =TypeToken.getParameterized(List.class, Integer.class).getType();
53
+
FileStore<List<Integer>> store =newJsonFileStore("./int-list.json", type, ArrayList::new);
55
54
```
56
55
57
-
As you can see, I don't use the raw `List.class` for the `Type`.
56
+
As you can see, I don't use the raw `List.class` for the `type`.
58
57
59
58
> Not doing this may result in `ClassCastException` exceptions and other funny bugs.
0 commit comments