package be.iminds.ilabt.jfed.rspec.model;

import be.iminds.ilabt.jfed.rspec.parser.ExtraXml;
import be.iminds.ilabt.jfed.util.GeniUrn;

import java.util.List;

/**
 * RspecInterface
 */
public interface RspecInterface {



    void overwritePropertiesWith(RspecInterface other, boolean overwriteWithNull);

    /**
     * set the link for an rspec created without link.
     * This may only be called once, and only if the appropriate constructor was used.
     * This is used for multi-step construction of an interface. (useful when parsing)
     * @param rspecLink
     */
    void bindLink(RspecLink rspecLink);

    /**
     * set the node for an rspec created without node.
     * This may only be called once, and only if the appropriate constructor was used.
     * This is used for multi-step construction of an interface. (useful when parsing)
     * @param rspecNode
     */
    void bindNode(RspecNode rspecNode);

    /**
     * Move an interface at least bound to a node, to another node.
     * @param rspecNode
     */
    void moveToNode(RspecNode rspecNode);

    /**
     * Move an interface at least bound to a link, to another link.
     * @param rspecLink
     */
    void moveToLink(RspecLink rspecLink);

    boolean isBound();
    boolean isUnbound();

    boolean isLinkUnbound();
    boolean isNodeUnbound();
    boolean isLinkBound();
    boolean isNodeBound();

    String getUniqueId();

    String getClientId();

    void setClientId(String clientId);

    String getComponentId();

    String getComponentName();
    String getRole();
    String getPublicIpv4();

    void setComponentId(String componentId);

    void setComponentName(String componentName);
    void setRole(String role);
    void setPublicIpv4(String publicIpv4);

    GeniUrn getSliverId();

    void setSliverId(String sliverId);

    void setSliverId(GeniUrn sliverId);

    String getMacAddress();

    void setMacAddress(String value);

    List<IpAddress> getIpAddresses();

    List<ExtraXml> getExtraXml();
    List<ExtraXml> getRefExtraXml();

    RspecNode getNode();

    RspecLink getLink();

    /**
     * Deletes the interface from the model
     *
     * This also deletes interfaces that are only partially bound, without throwing an exception. It returns true in that case.
     *
     * @return Returns true when the interface (or partial interface) was successfully deleted. When false is returned,
     * the interface was already deleted
     */
    boolean delete();

    ModelRspec getRspec();

    void setFelixVlan(Integer felixVlan);

    Integer getFelixVlan();


    class IpAddress {
        public static final String TYPE_IPV4 = "ipv4";
        public static final String TYPE_IPV6 = "ipv6";


        private final String address;
        private final String netmask;
        private final String type;

        public IpAddress(String address, String netmask, String type) {
            this.address = address;
            this.netmask = netmask;
            this.type = type;
        }

        public String getAddress() {
            return address;
        }

        public String getNetmask() {
            return netmask;
        }

        public String getType() {
            return type;
        }
    }
}
