io.annot8.common.implementations.annotations.AbstractAnnotation Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of annot8-common-implementations Show documentation
Show all versions of annot8-common-implementations Show documentation
Common functionality used by Annot8 implementations
/* Annot8 (annot8.io) - Licensed under Apache-2.0. */
package io.annot8.common.implementations.annotations;
import java.util.Objects;
import io.annot8.core.annotations.Annotation;
import io.annot8.core.properties.Properties;
/**
* Abstract implementation of Annotation, providing correct implementations of equals, hashCode and
* toString.
*
* Two annotations are taken to be equal if the following properties are all equal. The actual
* implementation of the annotation is seen to be irrelevant and not checked.
*
*
* - id
*
- type
*
- properties
*
- bounds
*
- contentName
*
*/
public abstract class AbstractAnnotation implements Annotation {
@Override
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (other == null) {
return false;
}
if (!(other instanceof Annotation)) {
return false;
}
Annotation a = (Annotation) other;
return Objects.equals(getId(), a.getId())
&& Objects.equals(getType(), a.getType())
&& Properties.equals(getProperties(), a.getProperties())
&& Objects.equals(getBounds(), a.getBounds())
&& Objects.equals(getContentId(), a.getContentId());
}
@Override
public int hashCode() {
return Objects.hash(
getId(), getType(), Properties.hashCode(getProperties()), getBounds(), getContentId());
}
@Override
public String toString() {
return this.getClass().getName()
+ " [id="
+ getId()
+ ", type="
+ getType()
+ ", contentName="
+ getContentId()
+ ", bounds="
+ getBounds()
+ ", properties="
+ getProperties()
+ "]";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy