Skip to content

Commit

Permalink
Revert FieldValueType.registerStringValueType() to old version
Browse files Browse the repository at this point in the history
  • Loading branch information
nvamelichev committed Feb 26, 2024
1 parent 7d9d425 commit b42f698
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions databind/src/main/java/tech/ydb/yoj/databind/FieldValueType.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,21 +121,14 @@ public enum FieldValueType {
@Deprecated(forRemoval = true)
@ExperimentalApi(issue = "https://github.com/ydb-platform/yoj-project/issues/24")
public static void registerStringValueType(@NonNull Class<?> clazz) {
ensureValidStringValueType(clazz);
STRING_VALUE_TYPES.add(clazz);
if (clazz.isSealed()) {
STRING_VALUE_TYPES.addAll(Arrays.asList(clazz.getPermittedSubclasses()));
}
}

private static void ensureValidStringValueType(@NotNull Class<?> clazz) {
boolean isFinal = isFinal(clazz.getModifiers());
boolean isSealed = clazz.isSealed();
Preconditions.checkArgument(isFinal || isSealed,
"String-value type must either be final or sealed, but got: %s", clazz);

STRING_VALUE_TYPES.add(clazz);
if (isSealed) {
Arrays.stream(clazz.getPermittedSubclasses()).forEach(FieldValueType::ensureValidStringValueType);
Arrays.stream(clazz.getPermittedSubclasses()).forEach(FieldValueType::registerStringValueType);
}
}

Expand Down

0 comments on commit b42f698

Please sign in to comment.