package be.iminds.ilabt.jfed.lowlevel.stitching.info;

import be.iminds.ilabt.jfed.lowlevel.stitching.StitchingCallData;
import be.iminds.ilabt.jfed.lowlevel.stitching.VlanRange;

import java.util.Collections;
import java.util.List;

/**
 * Hop info.
 *
 * This is *informative* data generated by StitchingDirector.
 *
 * It is not used by StitchingDirector internally.
 */
public class Hop {
    private final String linkName;
    private final String authUrn;
    private final StitchingCallData.State authState;
    private final String hopUrn;
    private final VlanRange availableVlans;
    private final VlanRange unavailableVlans;
    private final Integer suggestedVlan;
    private final Integer confirmedVlan;
    private final boolean importsVlans;

    private final List<Hop> dependsOn;
    private final List<Hop> dependingOnThis;

    public Hop(String linkName,
               String authUrn,
               StitchingCallData.State authState,
               String hopUrn,
               VlanRange availableVlans,
               VlanRange unavailableVlans,
               Integer suggestedVlan,
               Integer confirmedVlan,
               boolean importsVlans,
               List<Hop> dependsOn,
               List<Hop> dependingOnThis) {
        this.linkName = linkName;
        this.authUrn = authUrn;
        this.authState = authState;
        this.hopUrn = hopUrn;
        this.availableVlans = availableVlans;
        this.unavailableVlans = unavailableVlans;
        this.suggestedVlan = suggestedVlan;
        this.confirmedVlan = confirmedVlan;
        this.importsVlans = importsVlans;
        this.dependsOn = dependsOn;
        this.dependingOnThis = dependingOnThis;
    }

    /**
     * partial copy constructor
     * @param hop               hop to copy all non dependency data from
     * @param dependsOn         List of other hops this hop depends on
     * @param dependingOnThis   List of hops depending on this hop
     */
    public Hop(Hop hop,
               List<Hop> dependsOn,
               List<Hop> dependingOnThis) {
        this.linkName = hop.linkName;
        this.authUrn = hop.authUrn;
        this.authState = hop.authState;
        this.hopUrn = hop.hopUrn;
        this.availableVlans = hop.availableVlans;
        this.unavailableVlans = hop.unavailableVlans;
        this.suggestedVlan = hop.suggestedVlan;
        this.confirmedVlan = hop.confirmedVlan;
        this.importsVlans = hop.importsVlans;
        this.dependsOn = dependsOn;
        this.dependingOnThis = dependingOnThis;
    }

    public String getLinkName() {
        return linkName;
    }

    public String getAuthUrn() {
        return authUrn;
    }

    public StitchingCallData.State getAuthState() {
        return authState;
    }

    public String getHopUrn() {
        return hopUrn;
    }

    public VlanRange getAvailableVlans() {
        return availableVlans;
    }

    public VlanRange getUnavailableVlans() {
        return unavailableVlans;
    }

    public Integer getSuggestedVlan() {
        return suggestedVlan;
    }

    public Integer getConfirmedVlan() {
        return confirmedVlan;
    }

    public boolean isImportsVlans() {
        return importsVlans;
    }

    public List<Hop> getDependsOn() {
        return Collections.unmodifiableList(dependsOn);
    }

    public List<Hop> getDependingOnThis() {
        return Collections.unmodifiableList(dependingOnThis);
    }
}
