BUG-6650: ep-ip/sgt, propose initial template provider api
[groupbasedpolicy.git] / sxp-integration / sxp-ep-provider / src / main / java / org / opendaylight / groupbasedpolicy / sxp / ep / provider / impl / dao / EpPolicyTemplateValueKey.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.sxp.ep.provider.impl.dao;
10
11 import java.util.List;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ConditionName;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.EndpointGroupId;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.TenantId;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.renderer.policy.configuration.endpoints.AddressEndpointWithLocation;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.groupbasedpolicy.sxp.integration.sxp.ep.provider.model.rev160302.sxp.ep.mapper.EndpointPolicyTemplateBySgt;
17
18 /**
19  * Purpose: composite key holder for {@link EndpointPolicyTemplateBySgt}
20  */
21 public class EpPolicyTemplateValueKey {
22
23     private final TenantId tenantId;
24     private final List<EndpointGroupId> epgId;
25     private final List<ConditionName> conditionName;
26
27     public EpPolicyTemplateValueKey(final TenantId tenantId, final List<EndpointGroupId> epgId, final List<ConditionName> conditionName) {
28         this.tenantId = tenantId;
29         this.epgId = epgId;
30         this.conditionName = conditionName;
31     }
32
33     public EpPolicyTemplateValueKey(AddressEndpointWithLocation endpoint) {
34         this(endpoint.getTenant(), endpoint.getEndpointGroup(), endpoint.getCondition());
35     }
36
37     public TenantId getTenantId() {
38         return tenantId;
39     }
40
41     public List<EndpointGroupId> getEpgId() {
42         return epgId;
43     }
44
45     public List<ConditionName> getConditionName() {
46         return conditionName;
47     }
48
49     @Override
50     public boolean equals(final Object o) {
51         if (this == o) return true;
52         if (o == null || getClass() != o.getClass()) return false;
53
54         final EpPolicyTemplateValueKey that = (EpPolicyTemplateValueKey) o;
55
56         if (tenantId != null ? !tenantId.equals(that.tenantId) : that.tenantId != null) return false;
57         if (epgId != null ? !epgId.equals(that.epgId) : that.epgId != null) return false;
58         return conditionName != null ? conditionName.equals(that.conditionName) : that.conditionName == null;
59
60     }
61
62     @Override
63     public int hashCode() {
64         return tenantId != null ? tenantId.hashCode() : 0;
65     }
66 }