
br.com.objectos.logging.Event Maven / Gradle / Ivy
/*
* Copyright (C) 2021 Objectos Software LTDA.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package br.com.objectos.logging;
public abstract class Event {
private final String key;
private final Level level;
private final Class> source;
Event(String key, Level level, Class> source) {
this.key = key;
this.level = level;
this.source = source;
}
@Override
public final boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof Event)) {
return false;
}
Event that;
that = (Event) obj;
return getClass().equals(that.getClass())
&& key.equals(that.key)
&& level == that.level
&& source.equals(that.source);
}
public final String getKey() {
return key;
}
public final Level getLevel() {
return level;
}
public final Class> getSource() {
return source;
}
@Override
public final int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((key == null) ? 0 : key.hashCode());
result = prime * result + ((level == null) ? 0 : level.hashCode());
result = prime * result + ((source == null) ? 0 : source.hashCode());
return result;
}
public final boolean isEnabled(Level level) {
return this.level.compareTo(level) >= 0;
}
@Override
public final String toString() {
StringBuilder sb = new StringBuilder();
Class extends Event> type;
type = getClass();
sb.append(type.getSimpleName());
sb.append('[');
sb.append(source.getCanonicalName());
sb.append(',');
sb.append(level.name());
sb.append(',');
sb.append(key);
sb.append(']');
return sb.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy