package org.opendaylight.netvirt.fibmanager;
-import static java.util.Collections.emptyList;
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;
import static org.opendaylight.controller.md.sal.binding.api.WriteTransaction.CREATE_MISSING_PARENTS;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.locks.ReentrantLock;
-import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.inject.Inject;
import javax.inject.Singleton;
public static void removeOrUpdateNextHopInfo(BigInteger dpnId, String nextHopKey, String groupId,
Nexthops nexthops, TypedWriteTransaction<Operational> tx) {
InstanceIdentifier<Nexthops> nextHopsId = getNextHopsIdentifier(nextHopKey);
- List<String> targetDeviceIds = new ArrayList<>(nullToEmpty(nexthops.getTargetDeviceId()));
+ List<String> targetDeviceIds =
+ nexthops.getTargetDeviceId() != null ? new ArrayList<>(nexthops.getTargetDeviceId()) : new ArrayList<>();
targetDeviceIds.remove(dpnId.toString());
if (targetDeviceIds.isEmpty()) {
tx.delete(nextHopsId);
}
return false;
}
-
- // TODO Replace this with mdsal's DataObjectUtils.nullToEmpty when upgrading to mdsal 3
- @Nonnull
- public static <T> List<T> nullToEmpty(final @Nullable List<T> input) {
- return input != null ? input : emptyList();
- }
}