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; |
Sho SHIMIZU | f7b693e | 2014-08-15 16:17:13 -0700 | [diff] [blame] | 4 | import net.onrc.onos.api.newintent.Intent; |
Sho SHIMIZU | 7cd8a42 | 2014-08-27 16:05:21 -0700 | [diff] [blame] | 5 | import net.onrc.onos.api.newintent.IntentId; |
| 6 | import net.onrc.onos.core.util.IdGenerator; |
Sho SHIMIZU | f7b693e | 2014-08-15 16:17:13 -0700 | [diff] [blame] | 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 | |
Sho SHIMIZU | 7cd8a42 | 2014-08-27 16:05:21 -0700 | [diff] [blame] | 18 | private final IdGenerator<FlowId> flowIdGenerator; |
Sho SHIMIZU | f7b693e | 2014-08-15 16:17:13 -0700 | [diff] [blame] | 19 | |
| 20 | /** |
Sho SHIMIZU | 7cd8a42 | 2014-08-27 16:05:21 -0700 | [diff] [blame] | 21 | * Constructs an object with the specified {@link IdGenerator IdGenerators} of intent ID |
| 22 | * and flow ID. |
Sho SHIMIZU | f7b693e | 2014-08-15 16:17:13 -0700 | [diff] [blame] | 23 | * |
| 24 | * @param intentIdGenerator |
| 25 | * @param flowIdGenerator |
| 26 | */ |
Sho SHIMIZU | 7cd8a42 | 2014-08-27 16:05:21 -0700 | [diff] [blame] | 27 | protected AbstractFlowGeneratingIntentCompiler(IdGenerator<IntentId> intentIdGenerator, |
| 28 | IdGenerator<FlowId> flowIdGenerator) { |
Sho SHIMIZU | f7b693e | 2014-08-15 16:17:13 -0700 | [diff] [blame] | 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 | } |