- private static final MethodType CONSTRUCTOR_TYPE = MethodType.methodType(void.class, InvocationHandler.class);
- private static final MethodType DATAOBJECT_TYPE = MethodType.methodType(DataObject.class, InvocationHandler.class);
- private static final Comparator<Method> METHOD_BY_ALPHABET = Comparator.comparing(Method::getName);
-
- private final ImmutableMap<String, LeafNodeCodecContext<?>> leafChild;
- private final ImmutableMap<YangInstanceIdentifier.PathArgument, NodeContextSupplier> byYang;
- private final ImmutableSortedMap<Method, NodeContextSupplier> byMethod;
- private final ImmutableMap<Class<?>, DataContainerCodecPrototype<?>> byStreamClass;
- private final ImmutableMap<Class<?>, DataContainerCodecPrototype<?>> byBindingArgClass;
- private final ImmutableMap<AugmentationIdentifier, Type> possibleAugmentations;
- private final MethodHandle proxyConstructor;
-
- private final ConcurrentMap<YangInstanceIdentifier.PathArgument, DataContainerCodecPrototype<?>> byYangAugmented =
- new ConcurrentHashMap<>();
- private final ConcurrentMap<Class<?>, DataContainerCodecPrototype<?>> byStreamAugmented = new ConcurrentHashMap<>();
-
- DataObjectCodecContext(final DataContainerCodecPrototype<T> prototype) {
- super(prototype);
-
- this.leafChild = factory().getLeafNodes(getBindingClass(), getSchema());
-
- final Map<Class<?>, Method> clsToMethod = BindingReflections.getChildrenClassToMethod(getBindingClass());
-
- final Map<YangInstanceIdentifier.PathArgument, NodeContextSupplier> byYangBuilder = new HashMap<>();
- final SortedMap<Method, NodeContextSupplier> byMethodBuilder = new TreeMap<>(METHOD_BY_ALPHABET);
- final Map<Class<?>, DataContainerCodecPrototype<?>> byStreamClassBuilder = new HashMap<>();
- final Map<Class<?>, DataContainerCodecPrototype<?>> byBindingArgClassBuilder = new HashMap<>();
-
- // Adds leaves to mapping
- for (final LeafNodeCodecContext<?> leaf : leafChild.values()) {
- byMethodBuilder.put(leaf.getGetter(), leaf);
- byYangBuilder.put(leaf.getDomPathArgument(), leaf);
- }
-
- for (final Entry<Class<?>, Method> childDataObj : clsToMethod.entrySet()) {
- final DataContainerCodecPrototype<?> childProto = loadChildPrototype(childDataObj.getKey());
- byMethodBuilder.put(childDataObj.getValue(), childProto);
- byStreamClassBuilder.put(childProto.getBindingClass(), childProto);
- byYangBuilder.put(childProto.getYangArg(), childProto);
- if (childProto.isChoice()) {
- final ChoiceNodeCodecContext<?> choice = (ChoiceNodeCodecContext<?>) childProto.get();
- for (final Class<?> cazeChild : choice.getCaseChildrenClasses()) {
- byBindingArgClassBuilder.put(cazeChild, childProto);
- }
- }
- }
- this.byMethod = ImmutableSortedMap.copyOfSorted(byMethodBuilder);
- this.byYang = ImmutableMap.copyOf(byYangBuilder);
- this.byStreamClass = ImmutableMap.copyOf(byStreamClassBuilder);
- byBindingArgClassBuilder.putAll(byStreamClass);
- this.byBindingArgClass = ImmutableMap.copyOf(byBindingArgClassBuilder);