CheckSpec implements JsonObjectConvertible { public static CheckSpec fromJson(final @NotNull JsonObject json) { final JsonKeys keys = keys(); final CheckSpec checkSpec = new CheckSpec(); if (hasNonNull(json, keys.impl())) { checkSpec.setImpl(json.getString(keys.impl())); } if (hasNonNull(json, keys.inlineScript())) { checkSpec.setInlineScript(json.getString(keys.inlineScript())); } if (hasNonNull(json, keys.inlineEngine())) { checkSpec.setInlineEngine(json.getString(keys.inlineEngine())); } if (hasNonNull(json, keys.name())) { checkSpec.setName(json.getString(keys.name())); } if (hasNonNull(json, keys.template())) { checkSpec.setTemplate(json.getString(keys.template())); } if (hasNonNull(json, keys.skip())) { checkSpec.setSkip(json.getBoolean(keys.skip())); } if (hasNonNull(json, keys.config())) { checkSpec.setConfig(json.getJsonObject(keys.config())); } return checkSpec; }  @NotNull static CheckSpec.JsonKeys keys(); String getImpl(); void setImpl(final String impl); String getInlineScript(); void setInlineScript(final String inlineScript); String getInlineEngine(); void setInlineEngine(final String inlineEngine); final boolean isAbstract(); final boolean notAbstract(); String getName(); void setName(final String name); String getTemplate(); void setTemplate(final String template); boolean isSkip(); void setSkip(final boolean skip); final boolean notSkipped(); JsonObject getConfig(); void setConfig(final JsonObject config); final boolean overrides(final @NotNull CheckSpec that); final boolean isOverriddenBy(final @NotNull CheckSpec that); final CheckSpec overlay(final @NotNull CheckSpec that); final boolean inherits(final @NotNull CheckSpec that); final boolean isInheritedBy(final @NotNull CheckSpec that); final CheckSpec inherit(final @NotNull CheckSpec that); static CheckSpec fromJson(final @NotNull JsonObject json); @Override final JsonObject toJson(); @Override String toString(); @Override boolean equals(final Object o); @Override int hashCode(); static CheckSpec copyOf(final @NotNull CheckSpec original); static ImmutableSpec immutableCopyOf(final @NotNull CheckSpec original);  }
@Test public void testFromJson() { final CheckSpec.JsonKeys keys = CheckSpec.keys(); final JsonObject specJson = obj() .key(keys.name(), keys.name()) .key(keys.impl(), keys.impl()) .key(keys.inlineScript(), keys.inlineScript()) .key(keys.inlineEngine(), keys.inlineEngine()) .key(keys.config(), key("foo", "bar")) .key(keys.template(), keys.template()) .key(keys.skip(), true) .get(); final CheckSpec spec = CheckSpec.fromJson(specJson); assertEquals("fromJson getName same", keys.name(), spec.getName()); assertEquals("fromJson getImpl same", keys.impl(), spec.getImpl()); assertEquals("fromJson getTemplate same", keys.template(), spec.getTemplate()); assertEquals("fromJson getInlineScript same", keys.inlineScript(), spec.getInlineScript()); assertEquals("fromJson getInlineEngine same", keys.inlineEngine(), spec.getInlineEngine()); assertEquals("fromJson getConfig same", key("foo", "bar").get(), spec.getConfig()); assertTrue("fromJson isSkip true", spec.isSkip()); assertEquals("json should be equal", specJson, spec.toJson()); assertEquals("toString should equal toJson().toString", specJson.toString(), spec.toString()); }