package ch.usi.inf.sp.dbi.profiler;

import java.util.Objects;

public class Frame implements IFrame {
    private final String className;
    private final String methodName;
    private final String methodDescriptor;

    public Frame(String className, String methodName, String methodDescriptor) {
        this.className = className;
        this.methodName = methodName;
        this.methodDescriptor = methodDescriptor;
    }

    @Override
    public String getName() {
        return String.format("%s.%s%s", className, methodName, methodDescriptor);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Frame frame = (Frame) o;
        return Objects.equals(className, frame.className) &&
                Objects.equals(methodName, frame.methodName) &&
                Objects.equals(methodDescriptor, frame.methodDescriptor);
    }

    @Override
    public int hashCode() {
        return Objects.hash(className, methodName, methodDescriptor);
    }
}
