blob: 1d11c9e258a9247141df78a11d8855b6a2ea3ba6 [file] [log] [blame]
HIGUCHI Yuta4c0ef6b2016-05-02 19:45:41 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
HIGUCHI Yuta4c0ef6b2016-05-02 19:45:41 -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.OduCltPort;
22import org.onosproject.net.optical.device.OduCltPortHelper;
HIGUCHI Yuta4c0ef6b2016-05-02 19:45:41 -070023
24import com.google.common.annotations.Beta;
25
26/**
27 * {@link PortMapper} to handler {@link OduCltPort} translation.
28 */
29@Beta
30public class OduCltPortMapper extends AbstractPortMapper<OduCltPort> {
31
32 @Override
33 public boolean is(Port port) {
34 return port != null &&
35 port.type() == Port.Type.ODUCLT &&
36 super.is(port);
37 }
38
39 @Override
40 public Optional<OduCltPort> as(Port port) {
41 if (port instanceof OduCltPort) {
42 return Optional.of((OduCltPort) port);
43 }
44 return super.as(port);
45 }
46
47 @Override
48 protected Optional<OduCltPort> mapPort(Port port) {
49 if (port instanceof OduCltPort) {
50 return Optional.of((OduCltPort) port);
HIGUCHI Yuta4c0ef6b2016-05-02 19:45:41 -070051 }
52
53 return OduCltPortHelper.asOduCltPort(port);
54 }
55
56}