fixed duplicate filter bindings

This commit is contained in:
Sebastian Sdorra
2017-01-15 19:33:22 +01:00
parent 1591ab43b3
commit cbc6dad0fe
2 changed files with 53 additions and 1 deletions

View File

@@ -38,6 +38,7 @@ import sonia.scm.xml.XmlArrayStringAdapter;
//~--- JDK imports ------------------------------------------------------------
import java.util.Arrays;
import java.util.Objects;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
@@ -46,6 +47,8 @@ import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
/**
* Descriptor for web elements such as filter or servlets. A web element can be registered by using the
* {@link sonia.scm.filter.WebElement} annotation.
*
* @author Sebastian Sdorra
* @since 2.0.0
@@ -136,6 +139,30 @@ public final class WebElementDescriptor
return regex;
}
@Override
public int hashCode() {
return Objects.hash(clazz, pattern, Arrays.hashCode(morePatterns), regex);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final WebElementDescriptor other = (WebElementDescriptor) obj;
return Objects.equals(clazz, other.clazz)
&& Objects.equals(pattern, other.pattern)
&& Arrays.equals(morePatterns, other.morePatterns)
&& this.regex == other.regex;
}
//~--- fields ---------------------------------------------------------------
/** Field description */

View File

@@ -28,12 +28,15 @@
*/
package sonia.scm.filter;
import java.util.Objects;
import sonia.scm.plugin.WebElementDescriptor;
/**
*
* @author Sebastian Sdorra
* @param <T>
* @since 2.0.0
*/
public final class TypedWebElementDescriptor<T>
{
@@ -57,4 +60,26 @@ public final class TypedWebElementDescriptor<T>
return descriptor;
}
@Override
public int hashCode() {
return Objects.hash(clazz, descriptor);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final TypedWebElementDescriptor other = (TypedWebElementDescriptor) obj;
return Objects.equals(clazz, other.clazz)
&& Objects.equals(descriptor, other.descriptor);
}
}