use of it.niedermann.owncloud.notes.shared.model.ApiVersion in project nextcloud-notes by stefan-niedermann.
the class Migration_22_23 method sanitizeApiVersion.
@Nullable
public static String sanitizeApiVersion(@Nullable String raw) {
if (TextUtils.isEmpty(raw)) {
return null;
}
JSONArray a;
try {
a = new JSONArray(raw);
} catch (JSONException e) {
try {
a = new JSONArray("[" + raw + "]");
} catch (JSONException e1) {
return null;
}
}
final var result = new ArrayList<ApiVersion>();
for (int i = 0; i < a.length(); i++) {
try {
final var version = ApiVersion.of(a.getString(i));
if (version.getMajor() != 0 || version.getMinor() != 0) {
result.add(version);
}
} catch (Exception ignored) {
}
}
if (result.isEmpty()) {
return null;
}
return "[" + result.stream().filter(Objects::nonNull).map(v -> v.getMajor() + "." + v.getMinor()).collect(Collectors.joining(",")) + "]";
}
Aggregations