Skip to content

Commit 5836a9d

Browse files
committed
1.0.1-SNAPSHOT
1 parent 16fcaa4 commit 5836a9d

File tree

20 files changed

+869
-704
lines changed

20 files changed

+869
-704
lines changed

.config/checkstyle/checkstyle.xml

Lines changed: 336 additions & 315 deletions
Large diffs are not rendered by default.

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ name: Java CI with Gradle
33
on:
44
push:
55
branches:
6-
- main
6+
- master
77
pull_request:
88
branches:
9-
- main
9+
- master
1010

1111
jobs:
1212
build:
@@ -25,4 +25,4 @@ jobs:
2525
uses: actions/[email protected]
2626
with:
2727
name: Serializer
28-
path: "build/libs/serializer*.jar"
28+
path: "build/libs/serializer*.jar"

README.md

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,28 @@ Elytrium Java Serializer is uploaded to the Maven Central repository, so you can
2121

2222
- Maven (pom.xml):
2323
```xml
24-
<dependencies>
25-
<dependency>
26-
<groupId>net.elytrium</groupId>
27-
<artifactId>serializer</artifactId>
28-
<version>1.0.0</version>
29-
</dependency>
30-
</dependencies>
24+
<dependencies>
25+
<dependency>
26+
<groupId>net.elytrium</groupId>
27+
<artifactId>serializer</artifactId>
28+
<version>1.0.0</version>
29+
</dependency>
30+
</dependencies>
3131
```
3232
- Gradle (build.gradle):
3333
```groovy
34-
dependencies {
35-
implementation("net.elytrium:serializer:1.0.0")
36-
}
34+
dependencies {
35+
implementation("net.elytrium:serializer:1.0.0")
36+
}
3737
```
3838

3939
### Without any modifications
4040

4141
1) Create the class
4242
```java
43-
public static class Settings {
44-
public String regularField = "regular value";
43+
public class Settings {
44+
45+
public String regularField = "regular value";
4546
}
4647
```
4748
2) Create YamlWriter
@@ -59,16 +60,17 @@ Elytrium Java Serializer is uploaded to the Maven Central repository, so you can
5960

6061
### With some modifications
6162

62-
1) Create the class that extends YamlSerializable. You can optionally modify the config and call ``YamlSerializable#setConfig(SerializerConfig)`` method. You can safely remove ``this.setConfig(CONFIG)``.
63+
1) Create the class that extends YamlSerializable. You can optionally modify the config and call ``YamlSerializable#setConfig(SerializerConfig)`` method. You can safely remove ``this.setConfig(Settings.CONFIG)``.
6364
```java
64-
public static class Settings extends YamlSerializable {
65-
private static final SerializerConfig CONFIG = new SerializerConfig.Builder().build();
66-
67-
Settings() {
68-
this.setConfig(CONFIG);
69-
}
65+
public class Settings extends YamlSerializable {
7066

71-
public String regularField = "regular value";
67+
private static final SerializerConfig CONFIG = new SerializerConfig.Builder().build();
68+
69+
Settings() {
70+
this.setConfig(Settings.CONFIG);
71+
}
72+
73+
public String regularField = "regular value";
7274
}
7375
```
7476
2) Instantiate it.
@@ -83,22 +85,22 @@ Elytrium Java Serializer is uploaded to the Maven Central repository, so you can
8385
### Comments and New lines
8486

8587
```java
86-
@NewLine(amount = 3)
87-
@Comment(
88-
value = {
89-
@CommentValue(" SAME_LINE comment Line 1")
90-
},
91-
at = Comment.At.SAME_LINE
92-
)
93-
@Comment(
94-
value = {
95-
@CommentValue(" SAME_LINE APPEND second comment Line 1"),
96-
@CommentValue(type = CommentValue.Type.NEW_LINE),
97-
@CommentValue(" SAME_LINE APPEND second comment Line 2")
98-
},
99-
at = Comment.At.APPEND
100-
)
101-
public String regularField = "regular value";
88+
@NewLine(amount = 3)
89+
@Comment(
90+
value = {
91+
@CommentValue(" SAME_LINE comment Line 1")
92+
},
93+
at = Comment.At.SAME_LINE
94+
)
95+
@Comment(
96+
value = {
97+
@CommentValue(" SAME_LINE APPEND second comment Line 1"),
98+
@CommentValue(type = CommentValue.Type.NEW_LINE),
99+
@CommentValue(" SAME_LINE APPEND second comment Line 2")
100+
},
101+
at = Comment.At.APPEND
102+
)
103+
public String regularField = "regular value";
102104
```
103105

104106
### Final and Transient fields
@@ -107,23 +109,20 @@ Final fields - unmodifiable fields that will be saved in the config. \
107109
Transient fields - unmodifiable fields that won't be saved in the config.
108110

109111
```java
112+
public final String finalField = "final";
110113
@Final
111-
public String finalField = "final";
112-
113-
public final String finalFieldToo = "final";
114-
115-
114+
public String finalFieldToo = "final";
115+
116+
public transient String transientField = "transient";
116117
@Transient
117-
public String transientField = "transient";
118-
119-
public transient String transientFieldToo = "transient";
118+
public String transientFieldToo = "transient";
120119
```
121120

122121
### Placeholders
123122

124123
```java
125-
@RegisterPlaceholders({"PLACEHOLDER", "another-placeholder"})
126-
public String anotherStringWithPlaceholders = "{PLACEHOLDER} {ANOTHER_PLACEHOLDER}";
124+
@RegisterPlaceholders({"PLACEHOLDER", "another-placeholder"})
125+
public String anotherStringWithPlaceholders = "{PLACEHOLDER} {ANOTHER_PLACEHOLDER}";
127126
```
128127

129128
```java
@@ -143,6 +142,7 @@ Placeholders.replace will work even with custom placeholder.
143142

144143
```java
145144
public class StringPlaceholderReplacer implements PlaceholderReplacer<String> {
145+
146146
@Override
147147
public String replace(String value, String[] placeholders, Object... values) {
148148
for (int i = Math.min(values.length, placeholders.length) - 1; i >= 0; --i) {
@@ -203,7 +203,7 @@ Custom serializers will be instantiated once for one SerializableConfig.
203203
```
204204

205205
```java
206-
public static class ExternalClassSerializer extends ClassSerializer<ExternalDeserializedClass, Map<String, Object>> {
206+
public class ExternalClassSerializer extends ClassSerializer<ExternalDeserializedClass, Map<String, Object>> {
207207

208208
@SuppressWarnings("unchecked")
209209
protected ExternalClassSerializer() {
@@ -232,21 +232,21 @@ Custom serializers will be instantiated once for one SerializableConfig.
232232
In case if you can't add @Serializer annotation or if you have multiple entries with similar classes, you can register the serializer in the config.
233233

234234
```java
235-
private static final SerializerConfig CONFIG = new SerializerConfig.Builder()
236-
.registerSerializer(new PathSerializer()).registerSerializer(new ClassSerializer<>(String.class, String.class) {
237-
@Override
238-
public String serialize(String from) {
239-
return from == null ? "" : from;
240-
}
235+
private static final SerializerConfig CONFIG = new SerializerConfig.Builder().registerSerializer(new PathSerializer()).registerSerializer(new ClassSerializer<>(String.class, String.class) {
236+
237+
@Override
238+
public String serialize(String from) {
239+
return from == null ? "" : from;
240+
}
241241

242-
@Override
243-
public String deserialize(String from) {
244-
return from.trim().isEmpty() ? null : from;
245-
}
246-
}).build();
242+
@Override
243+
public String deserialize(String from) {
244+
return from.trim().isEmpty() ? null : from;
245+
}
246+
}).build();
247247
```
248248

249249
## Support
250250

251251
If you want to get help or donate to us, you can join our Discord server and talk to us here. \
252-
Invite link: https://elytrium.net/discord
252+
Invite link: https://elytrium.net/discord

0 commit comments

Comments
 (0)