blob: 99401dcb61fd96663c009722e995af29d4b47c88 [file] [log] [blame]
HIGUCHI Yuta95d83e82016-04-26 12:13:48 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
HIGUCHI Yuta95d83e82016-04-26 12:13:48 -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 */
16package org.onosproject.net.optical.device.port;
17
18import java.util.Optional;
19
20import org.onosproject.net.Port;
21import org.onosproject.net.optical.OmsPort;
22import org.onosproject.net.optical.device.OmsPortHelper;
HIGUCHI Yuta95d83e82016-04-26 12:13:48 -070023
24import com.google.common.annotations.Beta;
25
26/**
27 * {@link PortMapper} to handler {@link OmsPort} translation.
28 */
29@Beta
30public class OmsPortMapper extends AbstractPortMapper<OmsPort> {
31
32 @Override
33 public boolean is(Port port) {
34 return port != null &&
35 port.type() == Port.Type.OMS &&
36 super.is(port);
37 }
38
39 @Override
40 public Optional<OmsPort> as(Port port) {
41 if (port instanceof OmsPort) {
42 return Optional.of((OmsPort) port);
43 }
44 return super.as(port);
45 }
46
47 @Override
48 protected Optional<OmsPort> mapPort(Port port) {
49 if (port instanceof OmsPort) {
50 return Optional.of((OmsPort) port);
HIGUCHI Yuta95d83e82016-04-26 12:13:48 -070051 }
HIGUCHI Yuta95d83e82016-04-26 12:13:48 -070052 return OmsPortHelper.asOmsPort(port);
53 }
54
55}