Open Kilda Java Documentation
LinkPropsMapper.java
Go to the documentation of this file.
1 /* Copyright 2018 Telstra Open Source
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 package org.openkilda.northbound.converter;
17 
18 import static java.util.Objects.requireNonNull;
19 
27 
28 import org.mapstruct.Mapper;
29 
30 @Mapper(componentModel = "spring")
31 public interface LinkPropsMapper {
32 
37  requireNonNull(data.getLinkProps(), "Link props should be presented");
38 
39  NetworkEndpoint source = data.getLinkProps().getSource();
40  NetworkEndpoint destination = data.getLinkProps().getDest();
41  return new LinkPropsDto(
42  source.getDatapath().toString(), source.getPortNumber(),
43  destination.getDatapath().toString(), destination.getPortNumber(),
44  data.getLinkProps().getProps());
45  }
46 
51  NetworkEndpoint source = new NetworkEndpoint(new SwitchId(input.getSrcSwitch()), input.getSrcPort());
52  NetworkEndpoint dest = new NetworkEndpoint(new SwitchId(input.getDstSwitch()), input.getDstPort());
53  return new LinkProps(source, dest, input.getProps());
54  }
55 
60  NetworkEndpointMask source = new NetworkEndpointMask(new SwitchId(input.getSrcSwitch()), input.getSrcPort());
61  NetworkEndpointMask dest = new NetworkEndpointMask(new SwitchId(input.getDstSwitch()), input.getDstPort());
62  return new LinkPropsMask(source, dest);
63  }
64 }
source
Definition: nodes.py:53