Sho SHIMIZU | f7b693e | 2014-08-15 16:17:13 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.newintent; |
| 2 | |
| 3 | import net.onrc.onos.api.flowmanager.FlowId; |
| 4 | import net.onrc.onos.api.flowmanager.FlowIdGenerator; |
| 5 | import net.onrc.onos.api.newintent.Intent; |
| 6 | import net.onrc.onos.api.newintent.IntentIdGenerator; |
| 7 | |
| 8 | import static com.google.common.base.Preconditions.checkNotNull; |
| 9 | |
| 10 | /** |
| 11 | * A base class of {@link net.onrc.onos.api.newintent.IntentCompiler}, |
| 12 | * which generates Flow objects. |
| 13 | * @param <T> |
| 14 | */ |
| 15 | public abstract class AbstractFlowGeneratingIntentCompiler<T extends Intent> |
| 16 | extends AbstractIntentCompiler<T> { |
| 17 | |
| 18 | private final FlowIdGenerator flowIdGenerator; |
| 19 | |
| 20 | /** |
| 21 | * Constructs an object with the specified {@link IntentIdGenerator} |
| 22 | * and {@link FlowIdGenerator}. |
| 23 | * |
| 24 | * @param intentIdGenerator |
| 25 | * @param flowIdGenerator |
| 26 | */ |
| 27 | protected AbstractFlowGeneratingIntentCompiler(IntentIdGenerator intentIdGenerator, |
| 28 | FlowIdGenerator flowIdGenerator) { |
| 29 | super(intentIdGenerator); |
| 30 | this.flowIdGenerator = checkNotNull(flowIdGenerator); |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * Returns the next {@link FlowId}. |
| 35 | * |
| 36 | * @return the next {@link FlowId} |
| 37 | */ |
| 38 | protected FlowId getNextFlowId() { |
| 39 | return flowIdGenerator.getNewId(); |
| 40 | } |
| 41 | } |