- private static NormalizedNodeDataInput streamReader(final DataInput in) throws IOException {
- NormalizedNodeDataInput streamReader = REUSABLE_READER_TL.get();
- if (streamReader == null) {
- streamReader = NormalizedNodeInputOutput.newDataInput(in);
- }
-
- return streamReader;
- }
-
- public static <T> void deserializePathAndNode(final DataInput in, final T instance, final Applier<T> applier) {
- try {
- NormalizedNodeDataInput streamReader = streamReader(in);
- NormalizedNode<?, ?> node = streamReader.readNormalizedNode();
- YangInstanceIdentifier path = streamReader.readYangInstanceIdentifier();
- applier.apply(instance, path, node);
- } catch (IOException e) {
- throw new IllegalArgumentException("Error deserializing path and Node", e);
- }
- }
-
- private static NormalizedNode<?, ?> tryDeserializeNormalizedNode(final DataInput in) throws IOException {
- boolean present = in.readBoolean();
- if (present) {
- NormalizedNodeDataInput streamReader = streamReader(in);
- return streamReader.readNormalizedNode();
- }
-
- return null;
+ @FunctionalInterface
+ public interface Applier<T> {
+ void apply(T instance, YangInstanceIdentifier path, NormalizedNode node);