import java.util.Arrays;
import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
import org.opendaylight.yangtools.yang.data.api.schema.AbstractLeafSetEntryNode;
}
public static <T> @NonNull ImmutableLeafSetEntryNode<T> of(final NodeWithValue<T> name) {
- if (name.getValue() instanceof byte[]) {
+ final var nameValue = name.getValue();
+ if (nameValue instanceof byte[]) {
@SuppressWarnings("unchecked")
final var ret = (ImmutableLeafSetEntryNode<T>) new Binary((NodeWithValue<byte[]>) name);
return ret;
+ } else if (nameValue instanceof YangInstanceIdentifier yiid && yiid.isEmpty()) {
+ throw new IllegalArgumentException("Leafset entry node value cannot be an empty instance identifier");
}
return new Regular<>(name);
}
final var ret = (ImmutableLeafSetEntryNode<T>) new Binary((NodeWithValue<byte[]>) name);
return ret;
}
+ } else if (nameValue instanceof YangInstanceIdentifier yiid && yiid.isEmpty()) {
+ throw new IllegalArgumentException("Leafset entry node value cannot be an empty instance identifier");
} else if (nameValue.equals(body)) {
return new Regular<>(name);
}