package org.sigmah.server.domain; /* * #%L * Sigmah * %% * Copyright (C) 2010 - 2016 URD * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% */ import javax.persistence.Column; import javax.persistence.Embeddable; import org.apache.commons.lang3.builder.ToStringBuilder; import org.sigmah.server.domain.base.EmbeddableEntity; import org.sigmah.server.domain.util.EntityConstants; /** * <p> * Embeddable bounds coordinates. * Not an entity. * </p> * * @author Denis Colliot (dcolliot@ideia.fr) */ @Embeddable public class Bounds implements EmbeddableEntity { /** * Serial version UID. */ private static final long serialVersionUID = 8477170799666981683L; @Column(name = EntityConstants.BOUNDS_COLUMN_X1) private double x1; @Column(name = EntityConstants.BOUNDS_COLUMN_Y1) private double y1; @Column(name = EntityConstants.BOUNDS_COLUMN_X2) private double x2; @Column(name = EntityConstants.BOUNDS_COLUMN_Y2) private double y2; public Bounds() { // TODO Auto-generated constructor stub } // -------------------------------------------------------------------------------- // // METHODS. // // -------------------------------------------------------------------------------- /** * {@inheritDoc} */ @Override public String toString() { final ToStringBuilder builder = new ToStringBuilder(this); builder.append("x1", x1); builder.append("y1", y1); builder.append("x2", x2); builder.append("y2", y2); return builder.toString(); } /** * {@inheritDoc} */ @Override public int hashCode() { final int prime = 31; int result = 1; long temp; temp = Double.doubleToLongBits(x1); result = prime * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(x2); result = prime * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(y1); result = prime * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(y2); result = prime * result + (int) (temp ^ (temp >>> 32)); return result; } /** * {@inheritDoc} */ @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof Bounds)) { return false; } Bounds other = (Bounds) obj; if (Double.doubleToLongBits(x1) != Double.doubleToLongBits(other.x1)) { return false; } if (Double.doubleToLongBits(x2) != Double.doubleToLongBits(other.x2)) { return false; } if (Double.doubleToLongBits(y1) != Double.doubleToLongBits(other.y1)) { return false; } if (Double.doubleToLongBits(y2) != Double.doubleToLongBits(other.y2)) { return false; } return true; } // -------------------------------------------------------------------------------- // // GETTERS & SETTERS. // // -------------------------------------------------------------------------------- public double getX1() { return x1; } public void setX1(double x1) { this.x1 = x1; } public double getY1() { return y1; } public void setY1(double y1) { this.y1 = y1; } public double getX2() { return x2; } public void setX2(double x2) { this.x2 = x2; } public double getY2() { return y2; } public void setY2(double y2) { this.y2 = y2; } }