package com.facebook.presto.sql.compiler;

public class Slot
{
    private final int id;
    private final Type type;

    public Slot(int id, Type type)
    {
        this.id = id;
        this.type = type;
    }

    public String getName()
    {
        return "$" + id;
    }

    public Type getType()
    {
        return type;
    }

    @Override
    public String toString()
    {
        return getName();
    }
}

@@ -40,379 +40,1223 @@
 r;%0A%0A
-public class Slot%0A%7B%0A    private final int id;%0A    private final Type type;%0A%0A    public Slot(int id, Type type)%0A    %7B%0A        this.id = id;%0A        this.type = type;%0A    %7D%0A%0A    public String getName()%0A    %7B%0A        return %22$%22 + id;%0A    %7D%0A%0A    public Type getType()%0A    %7B%0A        return type;%0A    %7D%0A%0A    @Override%0A    public String toString()%0A    %7B%0A        return getName()
+import com.google.common.base.Preconditions;%0A%0A/**%0A * A slot is a unique identifier for a source of data. E.g., a column in a table or an attribute in a subquery%0A */%0Apublic class Slot%0A%7B%0A    private final int id;%0A    private final Type type;%0A%0A    public Slot(int id, Type type)%0A    %7B%0A        Preconditions.checkArgument(id %3E= 0, %22Id must be positive%22);%0A        Preconditions.checkNotNull(type, %22type is null%22);%0A%0A        this.id = id;%0A        this.type = type;%0A    %7D%0A%0A    public String getName()%0A    %7B%0A        return %22$%22 + id;%0A    %7D%0A%0A    public Type getType()%0A    %7B%0A        return type;%0A    %7D%0A%0A    @Override%0A    public String toString()%0A    %7B%0A        return getName();%0A    %7D%0A%0A    @Override%0A    public boolean equals(Object o)%0A    %7B%0A        if (this == o) %7B%0A            return true;%0A        %7D%0A        if (o == null %7C%7C getClass() != o.getClass()) %7B%0A            return false;%0A        %7D%0A%0A        Slot slot = (Slot) o;%0A%0A        if (id != slot.id) %7B%0A            return false;%0A        %7D%0A        if (type != slot.type) %7B%0A            return false;%0A        %7D%0A%0A        return true;%0A    %7D%0A%0A    @Override%0A    public int hashCode()%0A    %7B%0A        int result = id;%0A        result = 31 * result + type.hashCode();%0A        return result
 ;%0A  

Implement equals and hashCode for Slot and add preconditions