* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.openflowplugin.impl.util;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import org.apache.commons.lang3.tuple.Pair;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.batch.flow.output.list.grouping.BatchFailedFlowsOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.Key;
+import org.opendaylight.yangtools.yang.binding.KeyAware;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.util.BindingMap;
import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
public final class FlowUtil {
private static final RpcResultBuilder<List<BatchFailedFlowsOutput>> SUCCESSFUL_FLOW_OUTPUT_RPC_RESULT =
- RpcResultBuilder.success(Collections.emptyList());
+ RpcResultBuilder.success(List.of());
/**
* Attach barrier response to given {@link RpcResult}<RemoveFlowsBatchOutput>.
RpcResult<RemoveFlowsBatchOutput>> FLOW_REMOVE_TRANSFORM =
batchFlowsCumulativeResult -> {
final RemoveFlowsBatchOutput batchOutput = new RemoveFlowsBatchOutputBuilder()
- .setBatchFailedFlowsOutput(batchFlowsCumulativeResult.getResult()).build();
+ .setBatchFailedFlowsOutput(index(batchFlowsCumulativeResult.getResult())).build();
final RpcResultBuilder<RemoveFlowsBatchOutput> resultBld =
createCumulativeRpcResult(batchFlowsCumulativeResult, batchOutput);
RpcResult<AddFlowsBatchOutput>> FLOW_ADD_TRANSFORM =
batchFlowsCumulativeResult -> {
final AddFlowsBatchOutput batchOutput = new AddFlowsBatchOutputBuilder()
- .setBatchFailedFlowsOutput(batchFlowsCumulativeResult.getResult()).build();
+ .setBatchFailedFlowsOutput(index(batchFlowsCumulativeResult.getResult())).build();
final RpcResultBuilder<AddFlowsBatchOutput> resultBld =
createCumulativeRpcResult(batchFlowsCumulativeResult, batchOutput);
RpcResult<UpdateFlowsBatchOutput>> FLOW_UPDATE_TRANSFORM =
batchFlowsCumulativeResult -> {
final UpdateFlowsBatchOutput batchOutput = new UpdateFlowsBatchOutputBuilder()
- .setBatchFailedFlowsOutput(batchFlowsCumulativeResult.getResult()).build();
+ .setBatchFailedFlowsOutput(index(batchFlowsCumulativeResult.getResult())).build();
final RpcResultBuilder<UpdateFlowsBatchOutput> resultBld =
createCumulativeRpcResult(batchFlowsCumulativeResult, batchOutput);
};
private FlowUtil() {
- throw new IllegalStateException("This class should not be instantiated.");
+ // Hidden on purpose
+ }
+
+ static <K extends Key<V>, V extends KeyAware<K>> Map<K, V> index(final List<V> list) {
+ return list == null ? null : BindingMap.ordered(list);
}
/**