package com.openosrs.client.api.types;

public class Path {
    private final Position[] steps;
    private final int length;

    public Path(Position[] steps) {
        this.steps = steps != null ? steps : new Position[0];
        this.length = this.steps.length;
    }

    public Position[] getSteps() { return steps.clone(); }
    public int getLength() { return length; }
    public boolean isEmpty() { return length == 0; }

    public Position getStep(int index) {
        if (index >= 0 && index < length) {
            return steps[index];
        }
        return null;
    }

    public Position getFirstStep() {
        return length > 0 ? steps[0] : null;
    }

    public Position getLastStep() {
        return length > 0 ? steps[length - 1] : null;
    }

    @Override
    public String toString() {
        return String.format("Path[%d steps]", length);
    }
}
