blob: 159caf54bcbe5e92aa1faea06afb2bcb124b6758 [file] [log] [blame]
Sho SHIMIZUf7b693e2014-08-15 16:17:13 -07001package net.onrc.onos.core.newintent;
2
3import net.onrc.onos.api.flowmanager.FlowId;
Sho SHIMIZUf7b693e2014-08-15 16:17:13 -07004import net.onrc.onos.api.newintent.Intent;
Sho SHIMIZU7cd8a422014-08-27 16:05:21 -07005import net.onrc.onos.api.newintent.IntentId;
6import net.onrc.onos.core.util.IdGenerator;
Sho SHIMIZUf7b693e2014-08-15 16:17:13 -07007
8import 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 */
15public abstract class AbstractFlowGeneratingIntentCompiler<T extends Intent>
16 extends AbstractIntentCompiler<T> {
17
Sho SHIMIZU7cd8a422014-08-27 16:05:21 -070018 private final IdGenerator<FlowId> flowIdGenerator;
Sho SHIMIZUf7b693e2014-08-15 16:17:13 -070019
20 /**
Sho SHIMIZU7cd8a422014-08-27 16:05:21 -070021 * Constructs an object with the specified {@link IdGenerator IdGenerators} of intent ID
22 * and flow ID.
Sho SHIMIZUf7b693e2014-08-15 16:17:13 -070023 *
24 * @param intentIdGenerator
25 * @param flowIdGenerator
26 */
Sho SHIMIZU7cd8a422014-08-27 16:05:21 -070027 protected AbstractFlowGeneratingIntentCompiler(IdGenerator<IntentId> intentIdGenerator,
28 IdGenerator<FlowId> flowIdGenerator) {
Sho SHIMIZUf7b693e2014-08-15 16:17:13 -070029 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}