apply checkstyle check during build for neutron-mapper
[groupbasedpolicy.git] / neutron-mapper / src / main / java / org / opendaylight / groupbasedpolicy / neutron / mapper / util / RouterUtils.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.groupbasedpolicy.neutron.mapper.util;
10
11 import com.google.common.base.Optional;
12
13 import javax.annotation.Nullable;
14
15 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.Routers;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.Router;
18
19 public class RouterUtils {
20
21     public static Optional<Router> findRouter(Uuid uuid, @Nullable Routers routers) {
22         if (routers == null || routers.getRouter() == null) {
23             return Optional.absent();
24         }
25         for (Router router : routers.getRouter()) {
26             if (router.getUuid().equals(uuid)) {
27                 return Optional.of(router);
28             }
29         }
30         return Optional.absent();
31     }
32 }