blob: d4c4c2ef392529e95cade94583978fcfc91e846e [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2014-present Open Networking Laboratory
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07003 *
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 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.cluster;
tom73d6d1e2014-09-17 20:08:01 -070017
Thomas Vachuska48448082016-02-19 22:14:54 -080018import org.onlab.util.Identifier;
tomfc9a4ff2014-09-22 18:22:47 -070019
tom73d6d1e2014-09-17 20:08:01 -070020/**
21 * Controller cluster identity.
22 */
Thomas Vachuska48448082016-02-19 22:14:54 -080023public final class NodeId extends Identifier<String> implements Comparable<NodeId> {
tomfc9a4ff2014-09-22 18:22:47 -070024
Thomas Vachuska48448082016-02-19 22:14:54 -080025 /**
26 * Constructor for serialization.
27 */
28 private NodeId() {
29 super("");
30 }
tomfc9a4ff2014-09-22 18:22:47 -070031
tomfc9a4ff2014-09-22 18:22:47 -070032 /**
tome4729872014-09-23 00:37:37 -070033 * Creates a new cluster node identifier from the specified string.
tomfc9a4ff2014-09-22 18:22:47 -070034 *
35 * @param id string identifier
36 */
tome4729872014-09-23 00:37:37 -070037 public NodeId(String id) {
Thomas Vachuska48448082016-02-19 22:14:54 -080038 super(id);
tomfc9a4ff2014-09-22 18:22:47 -070039 }
40
Thomas Vachuska48448082016-02-19 22:14:54 -080041 /**
42 * Creates a new cluster node identifier from the specified string.
43 *
44 * @param id string identifier
45 * @return node id
46 */
47 public static NodeId nodeId(String id) {
48 return new NodeId(id);
tomfc9a4ff2014-09-22 18:22:47 -070049 }
50
David K. Bainbridgee676dab2015-10-23 16:13:07 -070051 @Override
52 public int compareTo(NodeId that) {
Thomas Vachuska48448082016-02-19 22:14:54 -080053 return identifier.compareTo(that.identifier);
David K. Bainbridgee676dab2015-10-23 16:13:07 -070054 }
tom73d6d1e2014-09-17 20:08:01 -070055}