blob: 53cf1b6a72681f8de43a0ac3f368bacd2e9870bf [file] [log] [blame]
Carmelo Cascone87892e22017-11-13 16:01:29 -08001/*
2 * Copyright 2017-present Open Networking Foundation
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 */
16
17package org.onosproject.net.pi.model;
18
19import com.google.common.annotations.Beta;
20import org.onlab.util.Identifier;
21
22import static com.google.common.base.Preconditions.checkArgument;
23import static com.google.common.base.Preconditions.checkNotNull;
24
25/**
Carmelo Cascone4c289b72019-01-22 15:30:45 -080026 * Identifier of a packet metadata in a protocol-independent pipeline, unique within the scope of a pipeline model.
Carmelo Cascone87892e22017-11-13 16:01:29 -080027 */
28@Beta
Carmelo Cascone4c289b72019-01-22 15:30:45 -080029public final class PiPacketMetadataId extends Identifier<String> {
Carmelo Cascone87892e22017-11-13 16:01:29 -080030
Carmelo Cascone4c289b72019-01-22 15:30:45 -080031 private PiPacketMetadataId(String name) {
Carmelo Cascone87892e22017-11-13 16:01:29 -080032 super(name);
33 }
34
35 /**
Carmelo Cascone4c289b72019-01-22 15:30:45 -080036 * Returns an identifier for the given packet metadata name.
Carmelo Cascone87892e22017-11-13 16:01:29 -080037 *
Carmelo Cascone4c289b72019-01-22 15:30:45 -080038 * @param name packet metadata name
39 * @return packet metadata ID
Carmelo Cascone87892e22017-11-13 16:01:29 -080040 */
Carmelo Cascone4c289b72019-01-22 15:30:45 -080041 public static PiPacketMetadataId of(String name) {
Carmelo Cascone87892e22017-11-13 16:01:29 -080042 checkNotNull(name);
43 checkArgument(!name.isEmpty(), "Name can't be empty");
Carmelo Cascone4c289b72019-01-22 15:30:45 -080044 return new PiPacketMetadataId(name);
Carmelo Cascone87892e22017-11-13 16:01:29 -080045 }
46}