Jian Li | 95edb59 | 2017-01-29 08:42:07 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017-present Open Networking Laboratory |
| 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.mapping; |
| 17 | |
| 18 | import org.onosproject.core.ApplicationId; |
| 19 | import org.onosproject.net.DeviceId; |
| 20 | |
| 21 | /** |
| 22 | * Abstraction of mapping. |
| 23 | */ |
| 24 | public interface Mapping { |
| 25 | |
| 26 | /** |
| 27 | * Obtains the identifier of this mapping. |
| 28 | * |
| 29 | * @return mapping identifier |
| 30 | */ |
| 31 | MappingId id(); |
| 32 | |
| 33 | /** |
| 34 | * Obtains the application identifier of this mapping. |
| 35 | * |
| 36 | * @return an application identifier |
| 37 | */ |
| 38 | short appId(); |
| 39 | |
| 40 | /** |
| 41 | * Obtains the identity of the device where this mapping applies. |
| 42 | * |
| 43 | * @return device identifier |
| 44 | */ |
| 45 | DeviceId deviceId(); |
| 46 | |
| 47 | /** |
Jian Li | a0bf459 | 2017-02-03 17:43:21 +0900 | [diff] [blame] | 48 | * Obtains the mapping key that is used for query the mapping entry. |
Jian Li | 95edb59 | 2017-01-29 08:42:07 +0900 | [diff] [blame] | 49 | * |
Jian Li | a0bf459 | 2017-02-03 17:43:21 +0900 | [diff] [blame] | 50 | * @return mapping key |
| 51 | */ |
| 52 | MappingKey key(); |
| 53 | |
| 54 | /** |
| 55 | * Obtains the mapping value that is queried using the mapping key. |
| 56 | * |
| 57 | * @return mapping value |
| 58 | */ |
| 59 | MappingValue value(); |
| 60 | |
| 61 | /** |
| 62 | * {@inheritDoc} |
| 63 | * <p> |
Jian Li | 95edb59 | 2017-01-29 08:42:07 +0900 | [diff] [blame] | 64 | * Equality for mappings only considers 'match equality'. This means that |
| 65 | * two mappings with the same match conditions will be equal. |
| 66 | * |
Jian Li | a0bf459 | 2017-02-03 17:43:21 +0900 | [diff] [blame] | 67 | * @param obj the reference object with which to compare. |
| 68 | * @return {@code true} if this object is the same as the obj |
| 69 | * argument; {@code false} otherwise. |
Jian Li | 95edb59 | 2017-01-29 08:42:07 +0900 | [diff] [blame] | 70 | */ |
| 71 | boolean equals(Object obj); |
| 72 | |
| 73 | /** |
| 74 | * A mapping builder. |
| 75 | */ |
| 76 | interface Builder { |
| 77 | |
| 78 | /** |
Jian Li | a0bf459 | 2017-02-03 17:43:21 +0900 | [diff] [blame] | 79 | * Assigns an id value to this mapping. |
| 80 | * |
| 81 | * @param id a long value |
| 82 | * @return this builder object |
| 83 | */ |
| 84 | Builder withId(long id); |
| 85 | |
| 86 | /** |
Jian Li | 95edb59 | 2017-01-29 08:42:07 +0900 | [diff] [blame] | 87 | * Assigns the application that built this mapping to this object. |
| 88 | * The short value of the appId will be used as a basis for the |
| 89 | * cookie value computation. It is expected that application use this |
| 90 | * call to set their application id. |
| 91 | * |
| 92 | * @param appId an application identifier |
| 93 | * @return this builder object |
| 94 | */ |
| 95 | Builder fromApp(ApplicationId appId); |
| 96 | |
| 97 | /** |
| 98 | * Sets the deviceId for this mapping. |
| 99 | * |
| 100 | * @param deviceId a device identifier |
| 101 | * @return this builder object |
| 102 | */ |
| 103 | Builder forDevice(DeviceId deviceId); |
| 104 | |
| 105 | /** |
Jian Li | a0bf459 | 2017-02-03 17:43:21 +0900 | [diff] [blame] | 106 | * Sets the mapping key for this mapping. |
| 107 | * |
| 108 | * @param key mapping key |
| 109 | * @return this builder object |
| 110 | */ |
| 111 | Builder withKey(MappingKey key); |
| 112 | |
| 113 | /** |
| 114 | * Sets the mapping value for this mapping. |
| 115 | * |
| 116 | * @param value mapping value |
| 117 | * @return this builder object |
| 118 | */ |
| 119 | Builder withValue(MappingValue value); |
| 120 | |
| 121 | /** |
Jian Li | 95edb59 | 2017-01-29 08:42:07 +0900 | [diff] [blame] | 122 | * Builds a mapping object. |
| 123 | * |
| 124 | * @return a mapping object |
| 125 | */ |
| 126 | Mapping build(); |
| 127 | } |
| 128 | } |