2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.groupbasedpolicy.neutron.mapper.util;
11 import com.google.common.base.Optional;
13 import javax.annotation.Nullable;
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.subnets.rev150712.subnets.attributes.Subnets;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet;
19 public class SubnetUtils {
21 public static Optional<Subnet> findSubnet(Uuid uuid, @Nullable Subnets subnets) {
22 if (subnets == null || subnets.getSubnet() == null) {
23 return Optional.absent();
25 for (Subnet subnet : subnets.getSubnet()) {
26 if (subnet.getUuid().equals(uuid)) {
27 return Optional.of(subnet);
30 return Optional.absent();