blob: 0f87379bec03d7f19a827a5a93383dad64f1af69 [file] [log] [blame]
Jian Li95edb592017-01-29 08:42:07 +09001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2017-present Open Networking Foundation
Jian Li95edb592017-01-29 08:42:07 +09003 *
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 */
16package org.onosproject.mapping;
17
18import org.onosproject.core.ApplicationId;
19import org.onosproject.net.DeviceId;
20
21/**
22 * Abstraction of mapping.
23 */
24public 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 Lia0bf4592017-02-03 17:43:21 +090048 * Obtains the mapping key that is used for query the mapping entry.
Jian Li95edb592017-01-29 08:42:07 +090049 *
Jian Lia0bf4592017-02-03 17:43:21 +090050 * @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 Li95edb592017-01-29 08:42:07 +090064 * Equality for mappings only considers 'match equality'. This means that
65 * two mappings with the same match conditions will be equal.
66 *
Jian Lia0bf4592017-02-03 17:43:21 +090067 * @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 Li95edb592017-01-29 08:42:07 +090070 */
71 boolean equals(Object obj);
72
73 /**
74 * A mapping builder.
75 */
76 interface Builder {
77
78 /**
Jian Lia0bf4592017-02-03 17:43:21 +090079 * 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 Li95edb592017-01-29 08:42:07 +090087 * 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 Lia0bf4592017-02-03 17:43:21 +0900106 * 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 Li95edb592017-01-29 08:42:07 +0900122 * Builds a mapping object.
123 *
124 * @return a mapping object
125 */
126 Mapping build();
127 }
128}