This repository has been archived by the owner on Aug 8, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 90
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
ENORMOUZ
committed
Sep 3, 2023
1 parent
71bf7fe
commit 1feaf69
Showing
4 changed files
with
93 additions
and
14 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
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
51 changes: 51 additions & 0 deletions
51
src/main/java/com/wynntils/webapi/profiles/GuildColorProfile.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,51 @@ | ||
package com.wynntils.webapi.profiles; | ||
|
||
import com.google.gson.*; | ||
|
||
import java.lang.reflect.Type; | ||
|
||
public class GuildColorProfile { | ||
String name; | ||
String prefix; | ||
String guildColor; | ||
|
||
public GuildColorProfile(String name, String prefix, String guildColor) { | ||
this.name = name; | ||
this.prefix = prefix; | ||
this.guildColor = guildColor; | ||
|
||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public String getPrefix() { | ||
return prefix; | ||
} | ||
|
||
public String getGuildColor() { | ||
return guildColor; | ||
} | ||
|
||
public static class GuildColorDeserializer implements JsonDeserializer<GuildColorProfile> { | ||
@Override | ||
public GuildColorProfile deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { | ||
JsonObject guildColorObject = json.getAsJsonObject(); | ||
|
||
String name; | ||
if (guildColorObject.get("_id").isJsonNull()) name = "Unknown"; | ||
else name = guildColorObject.get("_id").getAsString(); | ||
|
||
String prefix; | ||
if (guildColorObject.get("prefix").isJsonNull()) prefix = "UNK"; | ||
else prefix = guildColorObject.get("prefix").getAsString(); | ||
|
||
String guildColor; | ||
if (guildColorObject.get("color").getAsString().isEmpty()) guildColor = null; | ||
else guildColor = guildColorObject.get("color").getAsString(); | ||
|
||
return new GuildColorProfile(name, prefix, guildColor); | ||
} | ||
} | ||
} |
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