+public abstract class ReusableNormalizedNodePruner extends AbstractNormalizedNodePruner {
+ private static final class SimplePruner extends ReusableNormalizedNodePruner {
+ SimplePruner(final SchemaContext schemaContext) {
+ super(schemaContext);
+ }
+
+ SimplePruner(final DataSchemaContextTree tree) {
+ super(tree);
+ }
+
+ @Override
+ public ReusableNormalizedNodePruner duplicate() {
+ return new SimplePruner(getTree());
+ }
+ }
+
+ private static final class UintAdaptingPruner extends ReusableNormalizedNodePruner {
+ private static final Logger LOG = LoggerFactory.getLogger(UintAdaptingPruner.class);
+
+ UintAdaptingPruner(final DataSchemaContextTree tree) {
+ super(tree);
+ }
+
+ @Override
+ public ReusableNormalizedNodePruner duplicate() {
+ return new UintAdaptingPruner(getTree());
+ }
+
+ @Override
+ Object translateScalar(final DataSchemaContextNode<?> context, final Object value) throws IOException {
+ final DataSchemaNode schema = context.getDataSchemaNode();
+ if (schema instanceof TypedDataSchemaNode) {
+ final TypeDefinition<?> type = ((TypedDataSchemaNode) schema).getType();
+ if (value instanceof Short && type instanceof Uint8TypeDefinition) {
+ LOG.trace("Translating legacy uint8 {}", value);
+ return Uint8.valueOf((Short) value);
+ } else if (value instanceof Integer && type instanceof Uint16TypeDefinition) {
+ LOG.trace("Translating legacy uint16 {}", value);
+ return Uint16.valueOf((Integer) value);
+ } else if (value instanceof Long && type instanceof Uint32TypeDefinition) {
+ LOG.trace("Translating legacy uint32 {}", value);
+ return Uint32.valueOf((Long) value);
+ } else if (value instanceof BigInteger && type instanceof Uint64TypeDefinition) {
+ LOG.trace("Translating legacy uint64 {}", value);
+ return Uint64.valueOf((BigInteger) value);
+ }
+ }
+ return value;
+ }
+ }
+
+ ReusableNormalizedNodePruner(final SchemaContext schemaContext) {