Skip to content

Commit

Permalink
fix: providers non null
Browse files Browse the repository at this point in the history
  • Loading branch information
sattvikc committed Jul 2, 2024
1 parent 00be795 commit be4f841
Showing 1 changed file with 5 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,18 @@
public class ThirdPartyConfig {
public final boolean enabled;

@Nullable
@Nonnull
public final Provider[] providers;

public ThirdPartyConfig(boolean enabled, @Nullable Provider[] providers) {
this.enabled = enabled;
this.providers = providers;
this.providers = providers == null ? new Provider[0] : providers;
}

private void addProvidersToJson(JsonObject result) {
JsonArray providersArray = new JsonArray();
if (this.providers != null) {
for (Provider provider : this.providers) {
providersArray.add(provider.toJson());
}
for (Provider provider : this.providers) {
providersArray.add(provider.toJson());
}
result.add("providers", providersArray);
}
Expand All @@ -49,8 +47,6 @@ public JsonElement toJson3_0(String[] firstFactors) {
result.addProperty("enabled",
this.enabled && (
firstFactors == null || List.of(firstFactors).contains("thirdparty")
) && (
providers == null || providers.length > 0
));
this.addProvidersToJson(result);
return result;
Expand All @@ -61,18 +57,14 @@ public JsonElement toJson5_0(String[] firstFactors) {
result.addProperty("enabled",
this.enabled && (
firstFactors == null || firstFactors.length > 0
) && (
providers == null || providers.length > 0
));
this.addProvidersToJson(result);
return result;
}

public JsonElement toJson_v2_5_1() {
JsonObject result = new JsonObject();
if (providers != null) {
this.addProvidersToJson(result);
}
this.addProvidersToJson(result);
return result;
}

Expand Down

0 comments on commit be4f841

Please sign in to comment.