8af51a3859594a340ef43589c76706e3c251bffa
[lttng-ust.git] / liblttng-ust-java-agent / java / lttng-ust-agent-common / org / lttng / ust / agent / session / EventRule.java
1 /*
2 * Copyright (C) 2015 - EfficiOS Inc., Alexandre Montplaisir <alexmonthy@efficios.com>
3 *
4 * This library is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License, version 2.1 only,
6 * as published by the Free Software Foundation.
7 *
8 * This library is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11 * for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this library; if not, write to the Free Software Foundation,
15 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17
18 package org.lttng.ust.agent.session;
19
20 /**
21 * Event filtering rule present in a tracing session.
22 *
23 * It typically comes from a "lttng enable-event" command, and contains a
24 * domain, event name, log level and filter string.
25 *
26 * @author Alexandre Montplaisir
27 */
28 public class EventRule {
29
30 private final String eventName;
31 private final LogLevelSelector logLevelSelector;
32 private final String filterString;
33
34 /**
35 * Constructor.
36 *
37 * @param eventName
38 * The name of the tracepoint
39 * @param logLevelSelector
40 * The log level of the event rule
41 * @param filterString
42 * The filtering string. May be null if there is no extra filter.
43 */
44 public EventRule(String eventName, LogLevelSelector logLevelSelector, String filterString) {
45 this.eventName = eventName;
46 this.logLevelSelector = logLevelSelector;
47 this.filterString = filterString;
48 }
49
50 /**
51 * Get the event name of this rule.
52 *
53 * @return The event name
54 */
55 public String getEventName() {
56 return eventName;
57 }
58
59 /**
60 * Get the log level filter configuration of the rule.
61 *
62 * @return The log level selector
63 */
64 public LogLevelSelector getLogLevelSelector() {
65 return logLevelSelector;
66 }
67
68 /**
69 * Get the filter string associated with this rule.
70 *
71 * @return The filter string, may be null for no filter string.
72 */
73 public String getFilterString() {
74 return filterString;
75 }
76
77 // ------------------------------------------------------------------------
78 // Methods from Object
79 // ------------------------------------------------------------------------
80
81 @Override
82 public int hashCode() {
83 final int prime = 31;
84 int result = 1;
85 result = prime * result + ((eventName == null) ? 0 : eventName.hashCode());
86 result = prime * result + ((filterString == null) ? 0 : filterString.hashCode());
87 result = prime * result + ((logLevelSelector == null) ? 0 : logLevelSelector.hashCode());
88 return result;
89 }
90
91 @Override
92 public boolean equals(Object obj) {
93 if (this == obj) {
94 return true;
95 }
96 if (obj == null) {
97 return false;
98 }
99 if (getClass() != obj.getClass()) {
100 return false;
101 }
102 EventRule other = (EventRule) obj;
103
104 if (eventName == null) {
105 if (other.eventName != null) {
106 return false;
107 }
108 } else if (!eventName.equals(other.eventName)) {
109 return false;
110 }
111 /* else, continue */
112
113 if (filterString == null) {
114 if (other.filterString != null) {
115 return false;
116 }
117 } else if (!filterString.equals(other.filterString)) {
118 return false;
119 }
120 /* else, continue */
121
122 if (logLevelSelector == null) {
123 if (other.logLevelSelector != null) {
124 return false;
125 }
126 } else if (!logLevelSelector.equals(other.logLevelSelector)) {
127 return false;
128 }
129 /* else, continue */
130
131 return true;
132 }
133
134 @Override
135 public String toString() {
136 return "Event name = " + getEventName() +
137 ", Log level selector = (" + getLogLevelSelector().toString() + ")" +
138 ", Filter string = " + getFilterString();
139 }
140 }
This page took 0.030798 seconds and 3 git commands to generate.