package org.bdgp.MMSlide.DB;

import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;

@DatabaseTable
public class PoolSlide implements Comparable<PoolSlide> {
    @DatabaseField(generatedId=true, canBeNull=false)
    private int id;
    @DatabaseField(canBeNull=false, uniqueCombo=true)
    private int poolId;
    @DatabaseField(canBeNull=false, uniqueCombo=true)
    private int cartridgePosition;
    @DatabaseField(canBeNull=false, uniqueCombo=true)
    private int slidePosition;
    @DatabaseField
    private int slideId;
    
    public PoolSlide() {}
    public PoolSlide(int poolId, int cartridgePosition, int slidePosition, int slideId) {
        this.poolId = poolId;
        this.cartridgePosition = cartridgePosition;
        this.slidePosition = slidePosition;
        this.slideId = slideId;
    }

    public int getId() { return id; }
    public int getPoolId() { return poolId; }
    public int getCartridgePosition() { return cartridgePosition; }
    public int getSlidePosition() { return slidePosition; }
    public int getSlideId() { return slideId; }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + cartridgePosition;
        result = prime * result + slidePosition;
        return result;
    }
    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        PoolSlide other = (PoolSlide) obj;
        if (cartridgePosition != other.cartridgePosition)
            return false;
        if (slidePosition != other.slidePosition)
            return false;
        return true;
    }

    @Override
    public int compareTo(PoolSlide o) {
        int result = this.cartridgePosition-o.cartridgePosition;
        if (result == 0) {
            result = this.slidePosition-o.slidePosition;
        }
        return result;
    }
    
    public String toString() {
    	return String.format("%s(id=%d, poolId=%d, cartridgePosition=%d, slidePosition=%d, slideId=%d)",
    			this.getClass().getSimpleName(), this.poolId, this.cartridgePosition, this.slidePosition, this.slideId);
    }
}

@@ -2205,16 +2205,40 @@
 Name(), 
+%0A    %09%09%09this.id,%0A    %09%09%09
 this.poo
@@ -2242,16 +2242,24 @@
 poolId, 
+%0A    %09%09%09
 this.car
@@ -2266,32 +2266,40 @@
 tridgePosition, 
+%0A    %09%09%09
 this.slidePositi
@@ -2302,16 +2302,24 @@
 sition, 
+%0A    %09%09%09
 this.sli

fix PoolSlide.toString()