package de.terrestris.shogun2.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

/**
 * This class represents a data source for a {@link Layer}. As this class only
 * provides basic information, a {@link Layer} would usually use a more concrete
 * version of a {@link LayerDataSource} (i.e. a subclass of this class).
 */
@Entity
@Table
@Inheritance(strategy = InheritanceType.JOINED)
public class LayerDataSource extends PersistentObject {

	private static final long serialVersionUID = 1L;

	/**
	 * 
	 */
	@Column
	private String name;

	/**
	 * Explicitly adding the default constructor as this is important, e.g. for
	 * Hibernate: http://goo.gl/3Cr1pw
	 */
	public LayerDataSource() {
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @see java.lang.Object#hashCode()
	 * 
	 *      According to http://stackoverflow.com/q/27581 it is recommended to
	 *      use only getter-methods when using ORM like Hibernate
	 */
	@Override
	public int hashCode() {
		// two randomly chosen prime numbers
		return new HashCodeBuilder(11, 23).appendSuper(super.hashCode())
				.append(getName()).toHashCode();
	}

	/**
	 * @see java.lang.Object#equals(java.lang.Object)
	 * 
	 *      According to http://stackoverflow.com/q/27581 it is recommended to
	 *      use only getter-methods when using ORM like Hibernate
	 */
	@Override
	public boolean equals(Object obj) {
		if (!(obj instanceof LayerDataSource))
			return false;
		LayerDataSource other = (LayerDataSource) obj;

		return new EqualsBuilder().appendSuper(super.equals(other))
				.append(getName(), other.getName()).isEquals();
	}

	/**
	 * @see java.lang.Object#equals(java.lang.Object)
	 * 
	 *      Using Apache Commons String Builder.
	 */
	public String toString() {
		return new ToStringBuilder(this, ToStringStyle.DEFAULT_STYLE)
				.appendSuper(super.toString()).append("name", getName())
				.toString();
	}

}

@@ -851,18 +851,17 @@
 %09/**%0A%09 *
- 
 %0A
+
 %09 */%0A%09@C
@@ -889,16 +889,69 @@
  name;%0A%0A
+%09/**%0A%09 *%0A%09 */%0A%09@Column%0A%09private String attribution;%0A%0A
 %09/**%0A%09 *
@@ -1283,32 +1283,289 @@
 ame = name;%0A%09%7D%0A%0A
+%09/**%0A%09 * @return the attribution%0A%09 */%0A%09public String getAttribution() %7B%0A%09%09return attribution;%0A%09%7D%0A%0A%09/**%0A%09 * @param attribution%0A%09 *            the attribution to set%0A%09 */%0A%09public void setAttribution(String attribution) %7B%0A%09%09this.attribution = attribution;%0A%09%7D%0A%0A
 %09/**%0A%09 * @see ja
@@ -1589,25 +1589,24 @@
 shCode()%0A%09 *
- 
 %0A%09 *      Ac
@@ -1903,16 +1903,41 @@
 Name()).
+append(getAttribution()).
 toHashCo
@@ -1997,33 +1997,32 @@
 lang.Object)%0A%09 *
- 
 %0A%09 *      Accord
@@ -2407,16 +2407,70 @@
 tName())
+%0A%09%09%09%09.append(getAttribution(), other.getAttribution())
 .isEqual
@@ -2534,20 +2534,19 @@
 Object)%0A
+
 %09 *
- 
 %0A%09 *    

Add attribution property to LayerDataSource