This repository has been archived by the owner on Feb 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
CubeWhy
committed
Aug 4, 2023
1 parent
e2b22f0
commit 4c55b63
Showing
4 changed files
with
67 additions
and
25 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.cubewhy.lunarcn.value; | ||
|
||
import com.google.gson.JsonArray; | ||
import com.google.gson.JsonElement; | ||
import com.google.gson.JsonPrimitive; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class ListValue extends Value<String[]> { | ||
|
||
@Override | ||
public String[] getValue() { | ||
return value; | ||
} | ||
|
||
@Override | ||
public void setValue(String[] value) { | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
public JsonElement toJson() { | ||
JsonArray arr = new JsonArray(); | ||
for (String v : value) { | ||
arr.add(new JsonPrimitive(v)); | ||
} | ||
return arr; | ||
} | ||
|
||
@Override | ||
public void fromJson(@NotNull JsonElement jsonElement) { | ||
ArrayList<String> values = new ArrayList<>(); | ||
for (JsonElement v : jsonElement.getAsJsonArray()) { | ||
values.add(v.getAsString()); | ||
} | ||
this.value = values.toArray(new String[0]); | ||
} | ||
} |