blob: 54096be0f02bae11f2207421acd9fff1789212ef [file] [log] [blame]
Sho SHIMIZU07ace752014-08-21 09:04:41 -07001package net.onrc.onos.core.newintent;
2
3import com.google.common.collect.ImmutableList;
4import net.onrc.onos.api.newintent.InstallableIntent;
5
6import java.util.ArrayList;
7import java.util.List;
8
9import static com.google.common.base.Preconditions.checkArgument;
10import static com.google.common.base.Preconditions.checkNotNull;
11
12/**
13 * A class representing a result of intent compilation.
14 */
15public class IntentCompilationResult {
16 private final List<InstallableIntent> result;
17
18 /**
19 * Constructs an instance containing the specified list of installable intents.
20 *
21 * @param result installable intents
22 */
23 public IntentCompilationResult(List<InstallableIntent> result) {
24 checkNotNull(result);
25 checkArgument(result.size() > 0,
26 "result of intent compilation should be " +
Sho SHIMIZU0870f782014-08-22 09:58:56 -070027 "at least one installable intent, but %s", result.size());
Sho SHIMIZU07ace752014-08-21 09:04:41 -070028
29 this.result = new ArrayList<>(checkNotNull(result));
30 }
31
32 /**
33 * Constructor for serializer.
34 */
35 protected IntentCompilationResult() {
36 this.result = null;
37 }
38
39 /**
40 * Returns list of installable intents that this object contains.
41 *
42 * @return installable intents
43 */
44 public List<InstallableIntent> getResult() {
45 return ImmutableList.copyOf(result);
46 }
47}