blob: db26a7ee78538b879eaffc7f03c5808a599c00da [file] [log] [blame]
kmcpeake4fe18c82015-11-17 20:07:39 +00001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
kmcpeake4fe18c82015-11-17 20:07:39 +00003 *
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.incubator.net.faultmanagement.alarm;
17
18import com.google.common.annotations.Beta;
Jian Lib6d998e2016-02-29 11:41:18 -080019import org.onlab.util.Identifier;
20
kmcpeakeb172d5f2015-12-10 11:30:43 +000021import static com.google.common.base.Preconditions.checkArgument;
kmcpeake4fe18c82015-11-17 20:07:39 +000022/**
23 * Alarm identifier suitable as an external key.
24 * <p>
25 * This class is immutable.</p>
26 */
27@Beta
Jian Lib6d998e2016-02-29 11:41:18 -080028public final class AlarmId extends Identifier<Long> {
kmcpeake4fe18c82015-11-17 20:07:39 +000029
kmcpeakeb172d5f2015-12-10 11:30:43 +000030 public static final AlarmId NONE = new AlarmId();
kmcpeake4fe18c82015-11-17 20:07:39 +000031
32 /**
33 * Instantiates a new Alarm id.
34 *
35 * @param id the id
36 */
kmcpeakeb172d5f2015-12-10 11:30:43 +000037 private AlarmId(long id) {
Jian Lib6d998e2016-02-29 11:41:18 -080038 super(id);
kmcpeakeb172d5f2015-12-10 11:30:43 +000039 checkArgument(id != 0L, "id must be non-zero");
kmcpeake4fe18c82015-11-17 20:07:39 +000040 }
41
kmcpeakeb172d5f2015-12-10 11:30:43 +000042 private AlarmId() {
Jian Lib6d998e2016-02-29 11:41:18 -080043 super(0L);
kmcpeakeb172d5f2015-12-10 11:30:43 +000044 }
45
kmcpeake4fe18c82015-11-17 20:07:39 +000046 /**
47 * Creates an alarm identifier from the specified long representation.
48 *
49 * @param value long value
50 * @return intent identifier
51 */
kmcpeakeb172d5f2015-12-10 11:30:43 +000052 public static AlarmId alarmId(long value) {
kmcpeake4fe18c82015-11-17 20:07:39 +000053 return new AlarmId(value);
54 }
55
56 /**
57 * Returns the backing integer index.
58 *
59 * @return backing integer index
60 */
61 public long fingerprint() {
Jian Lib6d998e2016-02-29 11:41:18 -080062 return identifier;
kmcpeake4fe18c82015-11-17 20:07:39 +000063 }
kmcpeake4fe18c82015-11-17 20:07:39 +000064}