- private DataContainerCodecPrototype<?> loadChildPrototype(final Class<?> childClass) {
- final DataSchemaNode origDef = factory().getRuntimeContext().getSchemaDefinition(childClass);
- // Direct instantiation or use in same module in which grouping
- // was defined.
- DataSchemaNode sameName;
- try {
- sameName = getSchema().getDataChildByName(origDef.getQName());
- } catch (final IllegalArgumentException e) {
- sameName = null;
- }
- final DataSchemaNode childSchema;
- if (sameName != null) {
- // Exactly same schema node
- if (origDef.equals(sameName)) {
- childSchema = sameName;
- // We check if instantiated node was added via uses
- // statement and is instantiation of same grouping
- } else if (origDef.equals(SchemaNodeUtils.getRootOriginalIfPossible(sameName))) {
- childSchema = sameName;
- } else {
- // Node has same name, but clearly is different
- childSchema = null;
- }
- } else {
- // We are looking for instantiation via uses in other module
- final QName instantiedName = QName.create(namespace(), origDef.getQName().getLocalName());
- final DataSchemaNode potential = getSchema().getDataChildByName(instantiedName);
- // We check if it is really instantiated from same
- // definition as class was derived
- if (potential != null && origDef.equals(SchemaNodeUtils.getRootOriginalIfPossible(potential))) {
- childSchema = potential;
- } else {
- childSchema = null;
+ private @Nullable AugmentationCodecPrototype loadMismatchedAugmentation(
+ final ImmutableMap<Class<?>, AugmentationCodecPrototype> oldMismatched,
+ final @NonNull Class<?> childClass) {
+ @SuppressWarnings("rawtypes")
+ final Class<?> augTarget = findAugmentationTarget((Class) childClass);
+ // Do not bother with proposals which are not augmentations of our class, or do not match what the runtime
+ // context would load.
+ if (getBindingClass().equals(augTarget) && belongsToRuntimeContext(childClass)) {
+ for (var realChild : augmentToPrototype.values()) {
+ if (Augmentation.class.isAssignableFrom(realChild.getBindingClass())
+ && isSubstitutionFor(childClass, realChild.getBindingClass())) {
+ return cacheMismatched(oldMismatched, childClass, realChild);
+ }