*/
package org.opendaylight.mdsal.binding.dom.codec.impl;
-import java.lang.reflect.Method;
import java.util.List;
import org.opendaylight.yangtools.concepts.Codec;
import org.opendaylight.yangtools.yang.binding.DataObject;
final class KeyedListNodeCodecContext<D extends DataObject & Identifiable<?>> extends ListNodeCodecContext<D> {
private final Codec<NodeIdentifierWithPredicates, IdentifiableItem<?, ?>> codec;
- private final Method keyGetter;
KeyedListNodeCodecContext(final DataContainerCodecPrototype<ListSchemaNode> prototype) {
super(prototype);
- this.codec = factory().getPathArgumentCodec(getBindingClass(), getSchema());
+ final Class<D> bindingClass = getBindingClass();
+ this.codec = factory().getPathArgumentCodec(bindingClass, getSchema());
try {
- this.keyGetter = getBindingClass().getMethod("getKey");
+ // This just verifies the method is present
+ bindingClass.getMethod("getKey");
} catch (NoSuchMethodException e) {
throw new IllegalStateException("Required method not available", e);
}
@Override
@SuppressWarnings("rawtypes")
- Object getBindingChildValue(final Method method, final NormalizedNodeContainer dom) {
- if (dom instanceof MapEntryNode && keyGetter.equals(method)) {
+ Object getBindingChildValue(final String methodName, final NormalizedNodeContainer dom) {
+ if (dom instanceof MapEntryNode && "getKey".equals(methodName)) {
NodeIdentifierWithPredicates identifier = ((MapEntryNode) dom).getIdentifier();
return codec.deserialize(identifier).getKey();
}
- return super.getBindingChildValue(method, dom);
+ return super.getBindingChildValue(methodName, dom);
}
@Override