ForcedRoot implements JsonObjectConvertible, Comparable<ForcedRoot> { public static @NotNull ForcedRoot fromJson(final @NotNull JsonObject json) { final JsonKeys keys = keys(); final ForcedRoot forcedRoot = new ForcedRoot(); if (json.containsKey(keys.path())) { forcedRoot.setPath(json.getString(keys.path())); } if (json.containsKey(keys.primaryType())) { forcedRoot.setPrimaryType(json.getString(keys.primaryType())); } optArray(json, keys.mixinTypes()).ifPresent(jsonArray -> { forcedRoot.setMixinTypes(mapArrayOfStrings(jsonArray, Function.identity())); }); return forcedRoot; }  @NotNull static ForcedRoot.JsonKeys keys(); @Nullable String getPath(); void setPath(final @Nullable String path); @Nullable String getPrimaryType(); void setPrimaryType(final @Nullable String primaryType); @NotNull List<String> getMixinTypes(); void setMixinTypes(final @Nullable List<String> mixinTypes); @SuppressWarnings("WeakerAccess") ForcedRoot withPath(final @Nullable String path); @SuppressWarnings("WeakerAccess") ForcedRoot withPrimaryType(final @Nullable String primaryType); @SuppressWarnings("WeakerAccess") ForcedRoot withMixinTypes(final @NotNull String... mixinTypes); final boolean hasPath(); static @NotNull ForcedRoot fromJson(final @NotNull JsonObject json); @NotNull String[] getNamespacePrefixes(); @Override JsonObject toJson(); @Override int compareTo(final @NotNull ForcedRoot o); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }
@Test public void testFromJson() { final ForcedRoot.JsonKeys keys = ForcedRoot.keys(); final String path = "/correct/path"; final String primaryType = "primaryType"; final List<String> mixinTypes = Collections.singletonList("mixinType"); final ForcedRoot rootEmpty = ForcedRoot.fromJson(obj().get()); assertNull("empty root has null path", rootEmpty.getPath()); assertNull("empty root has null primaryType", rootEmpty.getPrimaryType()); assertTrue("empty root has empty mixinTypes", rootEmpty.getMixinTypes().isEmpty()); final ForcedRoot rootPath = ForcedRoot.fromJson( obj().key(keys.path(), path).get()); assertEquals("path root has correct path", path, rootPath.getPath()); final ForcedRoot rootPrimaryType = ForcedRoot.fromJson( obj().key(keys.primaryType(), primaryType).get()); assertEquals("primaryType root has correct primaryType", primaryType, rootPrimaryType.getPrimaryType()); final ForcedRoot rootMixinTypes = ForcedRoot.fromJson( obj().key(keys.mixinTypes(), mixinTypes).get()); assertEquals("mixinTypes root has correct mixinTypes", mixinTypes, rootMixinTypes.getMixinTypes()); }