// 
// Decompiled by Procyon v0.6.0
// 

package com.hypixel.hytale.math.shape;

import javax.annotation.Nullable;
import javax.annotation.Nonnull;
import com.hypixel.hytale.math.vector.Vector2d;

public class Rectangle
{
    private Vector2d min;
    private Vector2d max;
    
    public Rectangle() {
        this(new Vector2d(), new Vector2d());
    }
    
    public Rectangle(final double minX, final double minY, final double maxX, final double maxY) {
        this(new Vector2d(minX, minY), new Vector2d(maxX, maxY));
    }
    
    public Rectangle(final Vector2d min, final Vector2d max) {
        this.min = min;
        this.max = max;
    }
    
    public Rectangle(@Nonnull final Rectangle other) {
        this(other.getMinX(), other.getMinY(), other.getMaxX(), other.getMaxY());
    }
    
    public Vector2d getMin() {
        return this.min;
    }
    
    public Vector2d getMax() {
        return this.max;
    }
    
    public double getMinX() {
        return this.min.x;
    }
    
    public double getMinY() {
        return this.min.y;
    }
    
    public double getMaxX() {
        return this.max.x;
    }
    
    public double getMaxY() {
        return this.max.y;
    }
    
    @Nonnull
    public Rectangle assign(final double minX, final double minY, final double maxX, final double maxY) {
        this.min.x = minX;
        this.min.y = minY;
        this.max.x = maxX;
        this.max.y = maxY;
        return this;
    }
    
    public boolean hasArea() {
        return this.min.x < this.max.x && this.min.y < this.max.y;
    }
    
    @Override
    public boolean equals(@Nullable final Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || this.getClass() != o.getClass()) {
            return false;
        }
        final Rectangle that = (Rectangle)o;
        if (this.min != null) {
            if (this.min.equals(that.min)) {
                return (this.max != null) ? this.max.equals(that.max) : (that.max == null);
            }
        }
        else if (that.min == null) {
            return (this.max != null) ? this.max.equals(that.max) : (that.max == null);
        }
        return false;
    }
    
    @Override
    public int hashCode() {
        int result = (this.min != null) ? this.min.hashCode() : 0;
        result = 31 * result + ((this.max != null) ? this.max.hashCode() : 0);
        return result;
    }
    
    @Nonnull
    @Override
    public String toString() {
        return "Rectangle2d{min=" + String.valueOf(this.min) + ", max=" + String.valueOf(this.max);
    }
}
