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.util;
11 import java.util.Collections;
12 import java.util.List;
14 import javax.annotation.Nonnull;
15 import javax.annotation.Nullable;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.endpoints.address.endpoints.AddressEndpointKey;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.has.child.endpoints.ChildEndpoint;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.parent.child.endpoints.ParentEndpointChoice;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.parent.child.endpoints.parent.endpoint.choice.ParentContainmentEndpointCase;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.parent.child.endpoints.parent.endpoint.choice.ParentEndpointCase;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.parent.child.endpoints.parent.endpoint.choice.parent.containment.endpoint._case.ParentContainmentEndpoint;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.parent.child.endpoints.parent.endpoint.choice.parent.endpoint._case.ParentEndpoint;
25 public class EndpointUtils {
27 public static AddressEndpointKey createAddressEndpointKey(ChildEndpoint child) {
28 return new AddressEndpointKey(child.getAddress(), child.getAddressType(), child.getContextId(),
29 child.getContextType());
32 public static AddressEndpointKey createAddressEndpointKey(ParentEndpoint parent) {
33 return new AddressEndpointKey(parent.getAddress(), parent.getAddressType(), parent.getContextId(),
34 parent.getContextType());
37 public static @Nonnull List<ParentContainmentEndpoint> getParentContainmentEndpoints(
38 @Nullable ParentEndpointChoice parentEndpointChoice) {
39 if (parentEndpointChoice instanceof ParentContainmentEndpointCase) {
40 ParentContainmentEndpointCase parentCeCase = (ParentContainmentEndpointCase) parentEndpointChoice;
41 List<ParentContainmentEndpoint> parentContainmentEndpoints = parentCeCase.getParentContainmentEndpoint();
42 if (parentContainmentEndpoints != null) {
43 return parentContainmentEndpoints;
46 return Collections.emptyList();
49 public static @Nonnull List<ParentEndpoint> getParentEndpoints(
50 @Nullable ParentEndpointChoice parentEndpointChoice) {
51 if (parentEndpointChoice instanceof ParentEndpointCase) {
52 ParentEndpointCase parentEpCase = (ParentEndpointCase) parentEndpointChoice;
53 List<ParentEndpoint> parentEndpoints = parentEpCase.getParentEndpoint();
54 if (parentEndpoints != null) {
55 return parentEndpoints;
58 return Collections.emptyList();