From dba407e1c39331368f815cd3a199f3e43d1a2986 Mon Sep 17 00:00:00 2001 From: KennyTV Date: Sun, 12 Jul 2020 13:11:38 +0200 Subject: [PATCH] Replace doubled map lookups --- .../service/plugindata/PluginFileData.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/main/java/me/minidigger/hangar/service/plugindata/PluginFileData.java b/src/main/java/me/minidigger/hangar/service/plugindata/PluginFileData.java index 0c1bc682..99fd8ee2 100644 --- a/src/main/java/me/minidigger/hangar/service/plugindata/PluginFileData.java +++ b/src/main/java/me/minidigger/hangar/service/plugindata/PluginFileData.java @@ -22,44 +22,44 @@ public class PluginFileData { @Nullable public UUID getId() { - if (!dataValues.containsKey("id")) return null; - return ((UUIDDataValue) dataValues.get("id")).getValue(); + DataValue id = dataValues.get("id"); + return id != null ? ((UUIDDataValue) id).getValue() : null; } @Nullable public String getName() { - if (!dataValues.containsKey("name")) return null; - return ((StringDataValue) dataValues.get("name")).getValue(); + DataValue name = dataValues.get("name"); + return name != null ? ((StringDataValue) name).getValue() : null; } @Nullable public String getDescription() { - if (!dataValues.containsKey("description")) return null; - return ((StringDataValue) dataValues.get("description")).getValue(); + DataValue description = dataValues.get("description"); + return description != null ? ((StringDataValue) description).getValue() : null; } @Nullable public String getWebsite() { - if (!dataValues.containsKey("url")) return null; - return ((StringDataValue) dataValues.get("url")).getValue(); + DataValue url = dataValues.get("url"); + return url != null ? ((StringDataValue) url).getValue() : null; } @Nullable public String getVersion() { - if (!dataValues.containsKey("version")) return null; - return ((StringDataValue) dataValues.get("version")).getValue(); + DataValue version = dataValues.get("version"); + return version != null ? ((StringDataValue) version).getValue() : null; } @Nullable public List getAuthors() { - if (!dataValues.containsKey("authors")) return null; - return ((StringListDataValue) dataValues.get("authors")).getValue(); + DataValue authors = dataValues.get("authors"); + return authors != null ? ((StringListDataValue) authors).getValue() : null; } @Nullable public List getDependencies() { - if (!dataValues.containsKey("dependencies")) return null; - return ((DependencyDataValue) dataValues.get("dependencies")).getValue(); + DataValue dependencies = dataValues.get("dependencies"); + return dependencies != null ? ((DependencyDataValue) dependencies).getValue() : null; } public boolean validate() {