*/
package org.opendaylight.mdsal.binding.dom.codec.api;
+import static com.google.common.base.Verify.verifyNotNull;
+
import com.google.common.annotations.Beta;
+import com.google.common.base.VerifyException;
import java.util.Map.Entry;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
YangInstanceIdentifier toYangInstanceIdentifier(@NonNull InstanceIdentifier<?> binding);
/**
- * Translates supplied YANG Instance Identifier into Binding instance identifier.
+ * Translates supplied YANG Instance Identifier into Binding instance identifier. This method can return null
+ * if the instance identifier is not representable in Binding. If it is statically known this is not the case,
+ * use {@link #coerceFromYangInstanceIdentifier(YangInstanceIdentifier)}.
*
* @param dom YANG Instance Identifier
* @return Binding Instance Identifier, or null if the instance identifier is not representable.
<T extends DataObject> @Nullable InstanceIdentifier<T> fromYangInstanceIdentifier(
@NonNull YangInstanceIdentifier dom);
+ /**
+ * Translates supplied YANG Instance Identifier into Binding instance identifier.
+ *
+ * @param dom YANG Instance Identifier
+ * @return Binding Instance Identifier
+ * @throws VerifyException if the instance identifier is not representable.
+ */
+ @Beta
+ default <T extends DataObject> @NonNull InstanceIdentifier<T> coerceFromYangInstanceIdentifier(
+ final @NonNull YangInstanceIdentifier dom) {
+ return verifyNotNull(fromYangInstanceIdentifier(dom), "%s is not representable", dom);
+ }
+
/**
* Translates supplied Binding Instance Identifier and data into NormalizedNode representation.
*
* @return NormalizedNode representation of action input
* @throws NullPointerException if any of the arguments is null
*/
- @Beta default @NonNull BindingLazyContainerNode<RpcInput> toLazyNormalizedNodeActionInput(
- @NonNull final Class<? extends Action<?, ?, ?>> action, @NonNull final RpcInput input) {
+ @Beta
+ default @NonNull BindingLazyContainerNode<RpcInput> toLazyNormalizedNodeActionInput(
+ final @NonNull Class<? extends Action<?, ?, ?>> action, final @NonNull RpcInput input) {
return toLazyNormalizedNodeActionInput(action,
new NodeIdentifier(YangConstants.operationInputQName(BindingReflections.getQNameModule(action))), input);
}
* @return NormalizedNode representation of action input
* @throws NullPointerException if any of the arguments is null
*/
- @Beta default @NonNull ContainerNode toNormalizedNodeActionInput(
- @NonNull final Class<? extends Action<?, ?, ?>> action, @NonNull final RpcInput input) {
+ @Beta
+ default @NonNull ContainerNode toNormalizedNodeActionInput(final @NonNull Class<? extends Action<?, ?, ?>> action,
+ @NonNull final RpcInput input) {
return toLazyNormalizedNodeActionInput(action,
new NodeIdentifier(YangConstants.operationInputQName(BindingReflections.getQNameModule(action))), input)
.getDelegate();
* @param output Binding action output
* @return NormalizedNode representation of action output
*/
- @Beta default @NonNull BindingLazyContainerNode<RpcOutput> toLazyNormalizedNodeActionOutput(
- @NonNull final Class<? extends Action<?, ?, ?>> action, @NonNull final RpcOutput output) {
+ @Beta
+ default @NonNull BindingLazyContainerNode<RpcOutput> toLazyNormalizedNodeActionOutput(
+ final @NonNull Class<? extends Action<?, ?, ?>> action, final @NonNull RpcOutput output) {
return toLazyNormalizedNodeActionOutput(action,
new NodeIdentifier(YangConstants.operationInputQName(BindingReflections.getQNameModule(action))), output);
}
* @param output Binding action output
* @return NormalizedNode representation of action output
*/
- @Beta default @NonNull ContainerNode toNormalizedNodeActionOutput(
- @NonNull final Class<? extends Action<?, ?, ?>> action, @NonNull final RpcOutput output) {
+ @Beta
+ default @NonNull ContainerNode toNormalizedNodeActionOutput(final @NonNull Class<? extends Action<?, ?, ?>> action,
+ final @NonNull RpcOutput output) {
return toLazyNormalizedNodeActionOutput(action,
new NodeIdentifier(YangConstants.operationInputQName(BindingReflections.getQNameModule(action))), output)
.getDelegate();