blob: 123302088cbb86a996400dca1d60ca3d6bca8243 [file] [log] [blame]
Jian Li95edb592017-01-29 08:42:07 +09001/*
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 */
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 /**
48 * {@inheritDoc}
49 *
50 * Equality for mappings only considers 'match equality'. This means that
51 * two mappings with the same match conditions will be equal.
52 *
53 * @param obj the reference object with which to compare.
54 * @return {@code true} if this object is the same as the obj
55 * argument; {@code false} otherwise.
56 */
57 boolean equals(Object obj);
58
59 /**
60 * A mapping builder.
61 */
62 interface Builder {
63
64 /**
65 * Assigns the application that built this mapping to this object.
66 * The short value of the appId will be used as a basis for the
67 * cookie value computation. It is expected that application use this
68 * call to set their application id.
69 *
70 * @param appId an application identifier
71 * @return this builder object
72 */
73 Builder fromApp(ApplicationId appId);
74
75 /**
76 * Sets the deviceId for this mapping.
77 *
78 * @param deviceId a device identifier
79 * @return this builder object
80 */
81 Builder forDevice(DeviceId deviceId);
82
83 /**
84 * Builds a mapping object.
85 *
86 * @return a mapping object
87 */
88 Mapping build();
89 }
90}