This class seems to be a duplicate of BindingReflections'
functionality, completely missing out on AugmentationHolder, which
can be used as an alternative to expose augmentations.
Change-Id: Iadcc4e2f4587ceeb27d6a47c42b0319705fc1e58
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
import org.opendaylight.mdsal.binding.dom.codec.util.AugmentationReader;
import org.opendaylight.yangtools.yang.binding.Augmentable;
import org.opendaylight.yangtools.yang.binding.Augmentation;
import org.opendaylight.mdsal.binding.dom.codec.util.AugmentationReader;
import org.opendaylight.yangtools.yang.binding.Augmentable;
import org.opendaylight.yangtools.yang.binding.Augmentation;
+import org.opendaylight.yangtools.yang.binding.AugmentationHolder;
/**
* Adds an {@link #getAugmentations(Augmentable)} method to {@link Augmentable}.
/**
* Adds an {@link #getAugmentations(Augmentable)} method to {@link Augmentable}.
* @author Michael Vorburger
*/
// package-local: no need to expose this, consider it an implementation detail; public API is the AssertDataObjects
* @author Michael Vorburger
*/
// package-local: no need to expose this, consider it an implementation detail; public API is the AssertDataObjects
+// FIXME: 5.0.0: this is a duplication of BindingReflections.getAugmentations() ... but why?
class AugmentableExtension {
private static final ReflectExtensions REFLECT_EXTENSIONS = new ReflectExtensions();
class AugmentableExtension {
private static final ReflectExtensions REFLECT_EXTENSIONS = new ReflectExtensions();
- public ClassToInstanceMap<Augmentation<?>> getAugmentations(Augmentable<?> augmentable) {
+ public ClassToInstanceMap<Augmentation<?>> getAugmentations(final Augmentable<?> augmentable) {
if (augmentable instanceof AugmentationReader) {
AugmentationReader augmentationReader = (AugmentationReader) augmentable;
return ImmutableClassToInstanceMap.copyOf(augmentationReader.getAugmentations(augmentable));
if (augmentable instanceof AugmentationReader) {
AugmentationReader augmentationReader = (AugmentationReader) augmentable;
return ImmutableClassToInstanceMap.copyOf(augmentationReader.getAugmentations(augmentable));
+ } else if (augmentable instanceof AugmentationHolder) {
+ AugmentationHolder<?> augmentationHolder = (AugmentationHolder<?>) augmentable;
+ return ImmutableClassToInstanceMap.copyOf(augmentationHolder.augmentations());
} else if (Proxy.isProxyClass(augmentable.getClass())) {
InvocationHandler invocationHandler = Proxy.getInvocationHandler(augmentable);
// class LazyDataObject implements InvocationHandler, AugmentationReader
} else if (Proxy.isProxyClass(augmentable.getClass())) {
InvocationHandler invocationHandler = Proxy.getInvocationHandler(augmentable);
// class LazyDataObject implements InvocationHandler, AugmentationReader