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.renderer.vpp.policy;
11 import javax.annotation.Nonnull;
12 import javax.annotation.concurrent.Immutable;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.EndpointPolicyParticipation;
16 import com.google.common.base.Preconditions;
19 public class RendererResolvedPolicy implements Comparable<RendererResolvedPolicy> {
21 private final EndpointPolicyParticipation rendererEndpointParticipation;
22 private final ResolvedRuleGroup ruleGroup;
24 public RendererResolvedPolicy(@Nonnull EndpointPolicyParticipation rendererEndpointParticipation,
25 @Nonnull ResolvedRuleGroup ruleGroupInfo) {
26 this.rendererEndpointParticipation = Preconditions.checkNotNull(rendererEndpointParticipation);
27 this.ruleGroup = Preconditions.checkNotNull(ruleGroupInfo);
30 public EndpointPolicyParticipation getRendererEndpointParticipation() {
31 return rendererEndpointParticipation;
34 public ResolvedRuleGroup getRuleGroup() {
39 public int compareTo(RendererResolvedPolicy resolvedPolicy) {
40 int comp = ruleGroup.compareTo(resolvedPolicy.getRuleGroup());
41 if (comp == 0 && (rendererEndpointParticipation.getIntValue() != resolvedPolicy
42 .getRendererEndpointParticipation().getIntValue())) {
49 public int hashCode() {
52 result = prime * result
53 + ((rendererEndpointParticipation == null) ? 0 : rendererEndpointParticipation.hashCode());
54 result = prime * result + ((ruleGroup == null) ? 0 : ruleGroup.hashCode());
59 public boolean equals(Object obj) {
64 if (getClass() != obj.getClass())
66 RendererResolvedPolicy other = (RendererResolvedPolicy) obj;
67 if (rendererEndpointParticipation != other.rendererEndpointParticipation)
69 if (ruleGroup == null) {
70 if (other.ruleGroup != null)
72 } else if (!ruleGroup.equals(other.ruleGroup))
78 public String toString() {
79 return "RendererResolvedPolicy [rendererEndpointParticipation=" + rendererEndpointParticipation + ", ruleGroup="