package leaf.data;

public class Pair<CarClass extends Comparable<CarClass>, CdrClass> implements Comparable<Pair<CarClass, CdrClass>>
{

	private final CarClass car;
	private final CdrClass cdr;

	public Pair(CarClass car, CdrClass cdr)
	{
		this.car = car;
		this.cdr = cdr;
	}

	public CarClass getCar()
	{
		return car;
	}

	public CdrClass getCdr()
	{
		return cdr;
	}

	@Override
	public int compareTo( Pair<CarClass, CdrClass> toPair )
	{
		if(toPair == null)
		{
			return 1;
		}
		else if(car == null && toPair.getCar() == null)
		{
			return 0;
		}
		else
		{
			return getCar().compareTo( toPair.getCar() );
		}
	}
	
	@Override
	public String toString()
	{
		return "(" + (car == null ? "" : car.toString()) + ", "+ (cdr == null ? "" : cdr.toString()) + ")";
	}

}
