com.oliveryasuna.beanbag.event.ElementsAddedEvent Maven / Gradle / Ivy
The newest version!
package com.oliveryasuna.beanbag.event;
import com.oliveryasuna.beanbag.AbstractObservableCollection;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import java.util.Collection;
public class ElementsAddedEvent, SRC extends AbstractObservableCollection> extends CollectionEvent {
// Constructors
//--------------------------------------------------
public ElementsAddedEvent(final SRC source, final Collection elements) {
super(source);
this.elements = elements;
}
// Fields
//--------------------------------------------------
private final Collection elements;
// Getters/setters
//--------------------------------------------------
public Collection getElements() {
return elements;
}
// Object methods
//--------------------------------------------------
@Override
public boolean equals(final Object other) {
if(this == other) return true;
if(other == null || getClass() != other.getClass()) return false;
final ElementsAddedEvent, ?, ?> otherCasted = (ElementsAddedEvent, ?, ?>)other;
return new EqualsBuilder()
.appendSuper(super.equals(other))
.append(getElements(), otherCasted.getElements())
.isEquals();
}
@Override
public int hashCode() {
return new HashCodeBuilder(17, 37)
.appendSuper(super.hashCode())
.append(getElements())
.toHashCode();
}
}