/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.facebook.presto.operator.window;

import com.facebook.presto.sql.tree.FrameBound;
import com.facebook.presto.sql.tree.WindowFrame;

import java.util.Optional;

import static com.google.common.base.MoreObjects.toStringHelper;
import static java.util.Objects.requireNonNull;

public class FrameInfo
{
    private final WindowFrame.Type type;
    private final FrameBound.Type startType;
    private final int startChannel;
    private final FrameBound.Type endType;
    private final int endChannel;

    public FrameInfo(
            WindowFrame.Type type,
            FrameBound.Type startType,
            Optional<Integer> startChannel,
            FrameBound.Type endType,
            Optional<Integer> endChannel)
    {
        this.type = requireNonNull(type, "type is null");
        this.startType = requireNonNull(startType, "startType is null");
        this.startChannel = requireNonNull(startChannel, "startChannel is null").orElse(-1);
        this.endType = requireNonNull(endType, "endType is null");
        this.endChannel = requireNonNull(endChannel, "endChannel is null").orElse(-1);
    }

    public WindowFrame.Type getType()
    {
        return type;
    }

    public FrameBound.Type getStartType()
    {
        return startType;
    }

    public int getStartChannel()
    {
        return startChannel;
    }

    public FrameBound.Type getEndType()
    {
        return endType;
    }

    public int getEndChannel()
    {
        return endChannel;
    }

    @Override
    public String toString()
    {
        return toStringHelper(this)
                .add("type", type)
                .add("startType", startType)
                .add("startChannel", startChannel)
                .add("endType", endType)
                .add("endChannel", endChannel)
                .toString();
    }
}

@@ -699,16 +699,42 @@
 Frame;%0A%0A
+import java.util.Objects;%0A
 import j
@@ -2074,24 +2074,752 @@
 nel;%0A    %7D%0A%0A
+    @Override%0A    public int hashCode()%0A    %7B%0A        return Objects.hash(type, startType, startChannel, endType, endChannel);%0A    %7D%0A%0A    @Override%0A    public boolean equals(Object obj)%0A    %7B%0A        if (this == obj) %7B%0A            return true;%0A        %7D%0A%0A        if (obj == null %7C%7C getClass() != obj.getClass()) %7B%0A            return false;%0A        %7D%0A%0A        FrameInfo other = (FrameInfo) obj;%0A%0A        return Objects.equals(this.type, other.type) &&%0A                Objects.equals(this.startType, other.startType) &&%0A                Objects.equals(this.startChannel, other.startChannel) &&%0A                Objects.equals(this.endType, other.endType) &&%0A                Objects.equals(this.endChannel, other.endChannel);%0A    %7D%0A%0A
     @Overrid

Add missing hashCode and equals to FrameInfo