+ .setAction(actions.values().stream()
+ .sorted(OrderComparator.build())
+ .flatMap(action -> {
+ final var actionList = new ArrayList<org.opendaylight.yang.gen.v1.urn
+ .opendaylight.action.types.rev131112.action.list.Action>();
+
+ // If current action is SetVlanId, insert PushVlan action before it and update
+ // order
+ if (action.getAction() instanceof SetVlanIdActionCase setVlanIdActionCase) {
+ actionList.add(new ActionBuilder()
+ .setAction(new PushVlanActionCaseBuilder()
+ .setPushVlanAction(new PushVlanActionBuilder()
+ .setCfi(PUSH_CFI)
+ .setVlanId(setVlanIdActionCase.getSetVlanIdAction().getVlanId())
+ .setEthernetType(PUSH_VLAN)
+ .setTag(PUSH_TAG)
+ .build())
+ .build())
+ .withKey(action.key())
+ .setOrder(action.getOrder() + offset[0])
+ .build());
+ offset[0]++;
+ }
+
+ // Update offset of action if there is any inserted PushVlan actions
+ actionList.add(offset[0] <= 0 ? action : new ActionBuilder(action)
+ .setOrder(action.getOrder() + offset[0])
+ .withKey(new ActionKey(action.getOrder() + offset[0]))
+ .build());
+ return actionList.stream();
+ }).collect(BindingMap.toOrderedMap()))