2 * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.genius.mdsalutil;
10 import java.math.BigInteger;
11 import java.util.List;
12 import org.eclipse.jdt.annotation.Nullable;
13 import org.immutables.value.Value.Default;
14 import org.immutables.value.Value.Immutable;
15 import org.opendaylight.genius.infra.OpenDaylightImmutableStyle;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
23 @OpenDaylightImmutableStyle
24 public abstract class FlowEntity extends AbstractSwitchEntity {
26 // This is required as it will cause the code generation by @Immutable.org to implement Builder,
27 // which is required Xtend sources can use the XtendBuilderExtensions.operator_doubleGreaterThan
28 public abstract static class Builder implements org.opendaylight.yangtools.concepts.Builder<FlowEntity> {}
30 // This was done because MDSALManager has this hard-coded like this, upon MDSALManager.installFlow()
32 public BigInteger getCookie() {
33 return new BigInteger("0110000", 16);
36 public abstract String getFlowId();
38 public abstract @Nullable String getFlowName();
41 public int getHardTimeOut() {
46 public int getIdleTimeOut() {
50 public abstract List<InstructionInfo> getInstructionInfoList();
52 public abstract List<MatchInfoBase> getMatchInfoList();
55 public int getPriority() {
60 public boolean getSendFlowRemFlag() {
65 public boolean getStrictFlag() {
69 public abstract short getTableId();
71 public FlowBuilder getFlowBuilder() {
72 FlowBuilder flowBuilder = new FlowBuilder();
74 flowBuilder.setKey(new FlowKey(new FlowId(getFlowId())));
76 flowBuilder.setTableId(getTableId());
77 flowBuilder.setPriority(getPriority());
78 flowBuilder.setFlowName(getFlowName());
79 flowBuilder.setIdleTimeout(getIdleTimeOut());
80 flowBuilder.setHardTimeout(getHardTimeOut());
81 flowBuilder.setCookie(new FlowCookie(getCookie()));
82 flowBuilder.setMatch(MDSALUtil.buildMatches(getMatchInfoList()));
83 flowBuilder.setInstructions(MDSALUtil.buildInstructions(getInstructionInfoList()));
85 flowBuilder.setStrict(getStrictFlag());
86 // TODO flowBuilder.setResyncFlag(getResyncFlag());
87 if (getSendFlowRemFlag()) {
88 flowBuilder.setFlags(new FlowModFlags(false, false, false, false, true));
91 flowBuilder.setBarrier(false);
92 flowBuilder.setInstallHw(true);