Checklist implements JsonObjectConvertible { public static <T> Comparator<T> comparingJsonKeys(final @NotNull Function<T, String> jsonKeyExtractor) { return (t1, t2) -> checklistKeyComparator.compare(jsonKeyExtractor.apply(t1), jsonKeyExtractor.apply(t2)); } Checklist(final @Nullable JsonObject originalJson,
              final @Nullable String moduleName,
              final @Nullable String name,
              final @NotNull List<URL> cndUrls,
              final @NotNull List<JcrNs> jcrNamespaces,
              final @NotNull List<QNodeTypeDefinition> jcrNodetypes,
              final @NotNull List<PrivilegeDefinition> jcrPrivileges,
              final @NotNull List<ForcedRoot> forcedRoots,
              final @NotNull List<CheckSpec.ImmutableSpec> checks,
              final @NotNull List<String> repoInits); @NotNull static Checklist.JsonKeys keys(); static Comparator<T> comparingJsonKeys(final @NotNull Function<T, String> jsonKeyExtractor); String getModuleName(); String getName(); List<URL> getCndUrls(); List<QNodeTypeDefinition> getJcrNodetypes(); List<JcrNs> getJcrNamespaces(); List<String> getJcrPrivilegeNames(); List<PrivilegeDefinition> getJcrPrivileges(); List<ForcedRoot> getForcedRoots(); List<CheckSpec> getChecks(); List<String> getRepoInits(); InitStage asInitStage(); @Override String toString(); @Override JsonObject toJson(); static Checklist fromJson(final @NotNull String moduleName,
                                     final @Nullable URL manifestUrl,
                                     final @NotNull JsonObject json);  }
@Test public void testComparingJsonKeys() { final Checklist.JsonKeys keys = Checklist.keys(); final JsonObject obj1 = key("id", keys.checks()).get(); final JsonObject obj2 = key("id", keys.cndNames()).get(); final JsonObject obj3 = key("id", keys.cndUrls()).get(); final JsonObject[] inputValues1 = new JsonObject[]{obj2, obj3, obj1}; final JsonObject[] expectValues1 = new JsonObject[]{obj1, obj2, obj3}; Arrays.sort(inputValues1, Checklist.comparingJsonKeys(obj -> obj.getString("id"))); assertArrayEquals("sort keys using json extractor", expectValues1, inputValues1); }