Michele Santuari | 38dd82e | 2017-01-04 09:23:49 +0100 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Michele Santuari | 38dd82e | 2017-01-04 09:23:49 +0100 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package org.onosproject.net.domain; |
| 17 | |
| 18 | import com.google.common.base.MoreObjects; |
| 19 | |
| 20 | import static com.google.common.base.Preconditions.checkNotNull; |
| 21 | |
| 22 | /** |
| 23 | * Representation of an intent operation on a network domain. |
| 24 | */ |
| 25 | public class DomainIntentOperation { |
| 26 | |
| 27 | /** |
| 28 | * Type of domain intent operations. |
| 29 | * <p> |
| 30 | * TODO MODIFY to be added here. |
| 31 | */ |
| 32 | public enum Type { |
| 33 | ADD, |
| 34 | REMOVE |
| 35 | } |
| 36 | |
| 37 | private final DomainIntent intent; |
| 38 | private final Type type; |
| 39 | |
| 40 | /** |
| 41 | * Creates a domain intent operation using the supplied information. |
| 42 | * |
| 43 | * @param intent the domain intent |
| 44 | * @param type the operation type |
| 45 | */ |
| 46 | public DomainIntentOperation(DomainIntent intent, Type type) { |
| 47 | this.intent = checkNotNull(intent, "Intent cannot be null"); |
| 48 | this.type = checkNotNull(type, "Operation type cannot be null"); |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Returns the type of operation. |
| 53 | * |
| 54 | * @return type |
| 55 | */ |
| 56 | public Type type() { |
| 57 | return type; |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Returns the domain intent. |
| 62 | * |
| 63 | * @return domain intent |
| 64 | */ |
| 65 | public DomainIntent intent() { |
| 66 | return intent; |
| 67 | } |
| 68 | |
| 69 | @Override |
| 70 | public String toString() { |
| 71 | return MoreObjects.toStringHelper(this) |
| 72 | .add("intent", intent) |
| 73 | .add("type", type) |
| 74 | .toString(); |
| 75 | } |
| 76 | } |