blob: 9debd0a47152692e069b31ab3ad9bde67c3edbfc [file] [log] [blame]
kmcpeake4fe18c82015-11-17 20:07:39 +00001/*
Thomas Vachuska52f2cd12018-11-08 21:20:04 -08002 * Copyright 2018-present Open Networking Foundation
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 *
Thomas Vachuska52f2cd12018-11-08 21:20:04 -08008 * http://www.apache.org/licenses/LICENSE-2.0
kmcpeake4fe18c82015-11-17 20:07:39 +00009 *
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 */
Thomas Vachuska52f2cd12018-11-08 21:20:04 -080016package org.onosproject.alarm;
kmcpeake4fe18c82015-11-17 20:07:39 +000017
kmcpeake4fe18c82015-11-17 20:07:39 +000018import com.google.common.collect.ImmutableSet;
Jian Lib6d998e2016-02-29 11:41:18 -080019import org.onlab.util.Identifier;
20
kmcpeake4fe18c82015-11-17 20:07:39 +000021import java.net.URI;
kmcpeake4fe18c82015-11-17 20:07:39 +000022import java.util.Set;
23
Jian Lib6d998e2016-02-29 11:41:18 -080024import static com.google.common.base.Preconditions.checkArgument;
25
kmcpeake4fe18c82015-11-17 20:07:39 +000026/**
27 * Immutable representation of a alarm source. It is meaningful within the
28 * context of a device.
29 */
Jian Lib6d998e2016-02-29 11:41:18 -080030public final class AlarmEntityId extends Identifier<URI> {
kmcpeake4fe18c82015-11-17 20:07:39 +000031
32 public static final AlarmEntityId NONE = new AlarmEntityId(URI.create("none:none"));
33 public static final Set<String> SCHEMES = ImmutableSet.of("none", "port", "och", "other");
34
kmcpeake4fe18c82015-11-17 20:07:39 +000035 private AlarmEntityId(final URI uri) {
Jian Lib6d998e2016-02-29 11:41:18 -080036 super(uri);
kmcpeake4fe18c82015-11-17 20:07:39 +000037 }
38
39 protected AlarmEntityId() {
Jian Lib6d998e2016-02-29 11:41:18 -080040 super(NONE.identifier);
kmcpeake4fe18c82015-11-17 20:07:39 +000041 }
42
43 public static AlarmEntityId alarmEntityId(final String string) {
44 return alarmEntityId(URI.create(string));
45 }
46
47 public static AlarmEntityId alarmEntityId(final URI uri) {
48 checkArgument(SCHEMES.contains(uri.getScheme()), "Unexpected scheme");
49 return new AlarmEntityId(uri);
50 }
kmcpeake4fe18c82015-11-17 20:07:39 +000051}