org.mockserver.model.ObjectWithReflectiveEqualsHashCodeToString Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mockserver-core Show documentation
Show all versions of mockserver-core Show documentation
Functionality used by all MockServer modules for matching and expectations
package org.mockserver.model;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author jamesdbloom
*/
public abstract class ObjectWithReflectiveEqualsHashCodeToString {
protected Logger logger = LoggerFactory.getLogger(this.getClass());
static {
ReflectionToStringBuilder.setDefaultStyle(ToStringStyle.SHORT_PREFIX_STYLE);
}
protected String[] fieldsExcludedFromEqualsAndHashCode() {
return new String[]{"logger"};
}
@Override
public String toString() {
return ReflectionToStringBuilder.toStringExclude(this, fieldsExcludedFromEqualsAndHashCode());
}
@Override
public boolean equals(Object other) {
return EqualsBuilder.reflectionEquals(this, other, fieldsExcludedFromEqualsAndHashCode());
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this, fieldsExcludedFromEqualsAndHashCode());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy