-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#33 "source code style rule definition"
- now there are also class members of type Optional<?> (instead of wrapping them on-the-fly in the getter) - had to add OptionalTypeAdapter because Gson does not!!! support Optional<?> in 2022 (see google/gson#1102)
- Loading branch information
1 parent
a9ab48d
commit 07e0d89
Showing
5 changed files
with
53 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...is-maven-plugin/src/main/java/com/scheible/testgapanalysis/maven/OptionalTypeAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.scheible.testgapanalysis.maven; | ||
|
||
import com.google.gson.JsonDeserializationContext; | ||
import com.google.gson.JsonDeserializer; | ||
import com.google.gson.JsonElement; | ||
import com.google.gson.JsonParseException; | ||
import com.google.gson.JsonSerializationContext; | ||
import com.google.gson.JsonSerializer; | ||
import java.lang.reflect.Type; | ||
import java.util.Optional; | ||
|
||
/** | ||
* Unfortunately Gson has no built-in support for Optional. | ||
* | ||
* @author sj | ||
*/ | ||
class OptionalTypeAdapter implements JsonDeserializer<Optional<?>>, JsonSerializer<Optional<?>> { | ||
|
||
OptionalTypeAdapter() { | ||
} | ||
|
||
@Override | ||
public Optional<?> deserialize(final JsonElement element, final Type type, final JsonDeserializationContext context) throws JsonParseException { | ||
throw new UnsupportedOperationException("Not supported yet."); | ||
} | ||
|
||
@Override | ||
public JsonElement serialize(final Optional<?> value, final Type type, final JsonSerializationContext context) { | ||
return context.serialize(value.orElse(null)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters