import java.math.BigInteger;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
+import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.genius.mdsalutil.MetaDataUtil;
import org.opendaylight.genius.mdsalutil.NwConstants;
import org.opendaylight.netvirt.aclservice.utils.AclConstants;
-import org.opendaylight.netvirt.aclservice.utils.AclDataUtil;
import org.opendaylight.netvirt.aclservice.utils.AclServiceUtils;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsInputBuilder;
* @param dataBroker the data broker
* @return the acl port stats
*/
- public static List<AclPortStats> getAclPortStats(Direction direction, @Nullable List<String> interfaceNames,
+ public static List<AclPortStats> getAclPortStats(Direction direction, @Nonnull List<String> interfaceNames,
OpendaylightDirectStatisticsService odlDirectStatsService, DataBroker dataBroker) {
LOG.trace("Get ACL port stats for direction {} and interfaces {}", direction, interfaceNames);
List<AclPortStats> lstAclPortStats = new ArrayList<>();
FlowCookie aclDropFlowCookieMask = new FlowCookie(COOKIE_ACL_DROP_FLOW_MASK);
- for (String interfaceName : AclDataUtil.requireNonNullElse(interfaceNames, Collections.<String>emptyList())) {
+ for (String interfaceName : interfaceNames) {
AclPortStatsBuilder aclStatsBuilder = new AclPortStatsBuilder().setInterfaceName(interfaceName);
Interface interfaceState = AclServiceUtils.getInterfaceStateFromOperDS(dataBroker, interfaceName);
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
+import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Singleton;
+import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.OpendaylightDirectStatisticsService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.AclLiveStatisticsService;
// Default direction is Both
Direction direction = input.getDirection() == null ? Direction.Both : input.getDirection();
- List<AclPortStats> lstAclInterfaceStats = AclLiveStatisticsHelper.getAclPortStats(direction,
- input.getInterfaceNames(), this.odlDirectStatsService, this.dataBroker);
+ @Nullable List<String> interfaceNames = input.getInterfaceNames();
+ List<AclPortStats> lstAclInterfaceStats =
+ interfaceNames != null ? AclLiveStatisticsHelper.getAclPortStats(direction, interfaceNames,
+ this.odlDirectStatsService, this.dataBroker) : new ArrayList<>();
GetAclPortStatisticsOutputBuilder output =
new GetAclPortStatisticsOutputBuilder().setAclPortStats(lstAclInterfaceStats);
package org.opendaylight.netvirt.aclservice.utils;
-import static java.util.Objects.requireNonNull;
-
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
import java.math.BigInteger;
public Map<String, Acl> getAclMap() {
return ImmutableMap.copyOf(aclMap);
}
-
- // Use Objects.requireNonNullElse instead with JDK9+
- @Nonnull
- public static <T> T requireNonNullElse(@Nullable T obj, @Nonnull T defaultObj) {
- return obj != null ? obj : requireNonNull(defaultObj);
- }
}