blob: 1b7731f5d393000db537ed81ab6c05b79a8fb65f [file] [log] [blame]
karthik1977bc5ea1e2023-01-02 19:25:14 +05301/*
2 * Copyright 2023-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.netflow;
17
18import java.util.Objects;
19import com.google.common.base.MoreObjects;
20
21/**
22 * SourceId is that identifies the Exporter Observation Domain.
23 * NetFlow Collectors SHOULD use the combination of the source IP
24 * address and the Source ID field to separate different export
25 * streams originating from the same Exporter.
26 * Ref: https://www.ietf.org/rfc/rfc3954.txt
27 */
28public class SourceId {
29
30 private String sourceIp;
31
32 private int id;
33
34 public SourceId(int id, String sourceIp) {
35 this.sourceIp = sourceIp;
36 this.id = id;
37 }
38
39 public SourceId(int id) {
40 this.id = id;
41 }
42
43 /**
44 * Returns exporter ip address.
45 *
46 * @return exporter ip address.
47 */
48 public String getSourceIp() {
49 return sourceIp;
50 }
51
52 /**
53 * Returns exporter unique id.
54 *
55 * @return exporter unique id.
56 */
57 public int getId() {
58 return id;
59 }
60
61 @Override
62 public int hashCode() {
63 int hash = 7;
64 hash = 23 * hash + Objects.hashCode(this.sourceIp);
65 hash = 23 * hash + this.id;
66 return hash;
67 }
68
69 @Override
70 public boolean equals(Object obj) {
71 if (this == obj) {
72 return true;
73 }
74 if (obj == null) {
75 return false;
76 }
77 if (getClass() != obj.getClass()) {
78 return false;
79 }
80 final SourceId other = (SourceId) obj;
81 if (this.id != other.id) {
82 return false;
83 }
84 return Objects.equals(this.sourceIp, other.sourceIp);
85 }
86
87 @Override
88 public String toString() {
89 return MoreObjects.toStringHelper(getClass())
90 .add("sourceIp", sourceIp)
91 .add("id", id)
92 .toString();
93 }
94
95}