blob: 7b49d9867b5de8fcb06752f1f97c7c5e5e95ece2 [file] [log] [blame]
Carmelo Cascone41605742017-06-19 15:46:44 +09001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2017-present Open Networking Foundation
Carmelo Cascone41605742017-06-19 15:46:44 +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 */
16
17package org.onosproject.net.flow;
18
19import org.onlab.util.Identifier;
20
21/**
22 * Table identifier representing the position of the table in the pipeline.
23 */
24public final class IndexTableId extends Identifier<Integer> implements TableId {
25
26 private IndexTableId(int index) {
27 super(index);
28 }
29
30 @Override
31 public Type type() {
32 return Type.INDEX;
33 }
34
Charles Chandc579c52018-08-28 13:49:29 -070035 @Override
36 public int compareTo(TableId other) {
37 if (this.type() != other.type()) {
38 return this.type().compareTo(other.type());
39 } else {
40 IndexTableId indexTableId = (IndexTableId) other;
41 return this.id() - indexTableId.id();
42 }
43 }
44
Carmelo Cascone41605742017-06-19 15:46:44 +090045 /**
46 * Returns a table identifier for the given index.
47 *
48 * @param index table index
49 * @return table identifier
50 */
51 public static IndexTableId of(int index) {
52 return new IndexTableId(index);
53 }
54}