package org.opendaylight.mdsal.binding.dom.codec.impl;
import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
import static com.google.common.base.Verify.verify;
import com.google.common.base.Throwables;
private ActionCodecContext prepareActionContext(final int inputOffset, final int outputOffset,
final int expectedArgsLength, final Class<? extends Action<?, ?, ?>> action, final Class<?> actionType) {
- final ParameterizedType paramType = checkNotNull(ClassLoaderUtils.findParameterizedType(action, actionType),
- "There does not exist any ParameterType in %s", action);
+ final Optional<ParameterizedType> optParamType = ClassLoaderUtils.findParameterizedType(action, actionType);
+ checkState(optParamType.isPresent(), "%s does not specialize %s", action, actionType);
+
+ final ParameterizedType paramType = optParamType.get();
final Type[] args = paramType.getActualTypeArguments();
checkArgument(args.length == expectedArgsLength, "Unexpected (%s) Action generatic arguments", args.length);
final ActionDefinition schema = factory().getRuntimeContext().getActionDefinition(action);
.orElseThrow(() -> new IllegalArgumentException("Failed to find module for " + qnameModule));
final String className = BindingMapping.getClassName(qname);
- RpcDefinition rpc = null;
for (final RpcDefinition potential : module.getRpcs()) {
final QName potentialQName = potential.getQName();
/*
- * Check if rpc and class represents data from same module and then
- * checks if rpc local name produces same class name as class name
- * appended with Input/Output based on QName associated with bidning
- * class.
+ * Check if rpc and class represents data from same module and then checks if rpc local name produces same
+ * class name as class name appended with Input/Output based on QName associated with binding class.
*
- * FIXME: Rework this to have more precise logic regarding Binding
- * Specification.
+ * FIXME: Rework this to have more precise logic regarding Binding Specification.
*/
if (key.getSimpleName().equals(BindingMapping.getClassName(potentialQName) + className)) {
- rpc = potential;
- break;
+ final ContainerSchemaNode schema = SchemaNodeUtils.getRpcDataSchema(potential, qname);
+ checkArgument(schema != null, "Schema for %s does not define input / output.", potential.getQName());
+ return (ContainerNodeCodecContext<?>) DataContainerCodecPrototype.from(key, schema, factory()).get();
}
}
- checkArgument(rpc != null, "Supplied class %s is not valid RPC class.", key);
- final ContainerSchemaNode schema = SchemaNodeUtils.getRpcDataSchema(rpc, qname);
- checkArgument(schema != null, "Schema for %s does not define input / output.", rpc.getQName());
- return (ContainerNodeCodecContext<?>) DataContainerCodecPrototype.from(key, schema, factory()).get();
+
+ throw new IllegalArgumentException("Supplied class " + key + " is not valid RPC class.");
}
NotificationCodecContext<?> createNotificationDataContext(final Class<?> notificationType) {