Sho SHIMIZU | 07ace75 | 2014-08-21 09:04:41 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.newintent; |
| 2 | |
| 3 | import com.google.common.collect.ImmutableList; |
| 4 | import net.onrc.onos.api.newintent.InstallableIntent; |
| 5 | |
| 6 | import java.util.ArrayList; |
| 7 | import java.util.List; |
| 8 | |
| 9 | import static com.google.common.base.Preconditions.checkArgument; |
| 10 | import static com.google.common.base.Preconditions.checkNotNull; |
| 11 | |
| 12 | /** |
| 13 | * A class representing a result of intent compilation. |
| 14 | */ |
| 15 | public 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 SHIMIZU | 0870f78 | 2014-08-22 09:58:56 -0700 | [diff] [blame] | 27 | "at least one installable intent, but %s", result.size()); |
Sho SHIMIZU | 07ace75 | 2014-08-21 09:04:41 -0700 | [diff] [blame] | 28 | |
| 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 | } |