class JsonCnd {

    @SuppressWarnings("WeakerAccess")
    public static List<PrivilegeDefinition>
    getPrivilegesFromJson(final @NotNull JsonValue json,
                          final @NotNull NamespaceMapping mapping) {
        if (json.getValueType() == JsonValue.ValueType.ARRAY) {
            return JavaxJson.mapArrayOfStrings(json.asJsonArray(),
                    zipKeysWithValueFunc(constantly1(() -> JsonValue.EMPTY_JSON_OBJECT)), true)
                    .stream()
                    .map(mapEntry(uncheck2(privDefinitionMapper(mapping))))
                    .collect(Collectors.toList());
        } else if (json.getValueType() == JsonValue.ValueType.OBJECT) {
            return JavaxJson.mapObjectValues(json.asJsonObject(), uncheck2(privDefinitionMapper(mapping)), true);
        } else {
            return Collections.emptyList();
        }
    }

    private  JsonCnd();

}