blob: 3b3e538e1d449d7b9d75049941d3c8ca5f408007 [file] [log] [blame]
Jonathan Hart74c83132015-02-02 18:37:57 -08001/*
2 * Copyright 2015 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.store.intent.impl;
17
18import com.google.common.base.MoreObjects;
19
20import java.util.Objects;
21
22/**
23 * Identifies a partition of the intent keyspace which will be assigned to and
24 * processed by a single ONOS instance at a time.
25 */
26public class PartitionId {
27 private final int id;
28
29 /**
30 * Creates a new partition ID.
31 *
32 * @param id the partition ID
33 */
34 PartitionId(int id) {
35 this.id = id;
36 }
37
38 @Override
39 public boolean equals(Object o) {
40 if (!(o instanceof PartitionId)) {
41 return false;
42 }
43
44 PartitionId that = (PartitionId) o;
45 return Objects.equals(this.id, that.id);
46 }
47
48 @Override
49 public int hashCode() {
50 return Objects.hash(id);
51 }
52
53 @Override
54 public String toString() {
55 return MoreObjects.toStringHelper(getClass())
56 .add("partition ID", id)
57 .toString();
58 }
59}