blob: 07041e99ad4a821efbfa34410b83a00bbdb3efc2 [file] [log] [blame]
Sho SHIMIZUf7b693e2014-08-15 16:17:13 -07001package net.onrc.onos.core.newintent;
2
3import net.onrc.onos.api.flowmanager.FlowId;
4import net.onrc.onos.api.flowmanager.FlowIdGenerator;
5import net.onrc.onos.api.newintent.Intent;
6import net.onrc.onos.api.newintent.IntentIdGenerator;
7
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
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}