Class LinkImpl

  • All Implemented Interfaces:
    Serializable, Comparable<Edge>, Edge, Link

    public class LinkImpl
    extends EdgeImpl
    implements Link
    Link class connecting two nodes via some geometry. Each link has one or two underlying link segments in a particular direction which may carry additional information for each particular direction of the link.
    Author:
    markr
    See Also:
    Serialized Form
    • Field Detail

      • linkId

        protected final long linkId
        unique internal identifier
      • externalId

        protected Object externalId
        External Id of the physical link
    • Constructor Detail

      • LinkImpl

        public LinkImpl​(IdGroupingToken groupId,
                        Node nodeA,
                        Node nodeB,
                        double length,
                        String name)
                 throws PlanItException
        Constructor which injects link length directly
        Parameters:
        groupId - , contiguous id generation within this group for instances of this class
        nodeA - the first node in the link
        nodeB - the second node in the link
        length - the length of the link
        name - the name of the link
        Throws:
        PlanItException - thrown if there is an error
    • Method Detail

      • generateLinkId

        protected static long generateLinkId​(IdGroupingToken groupId)
        generate unique link id
        Parameters:
        groupId - , contiguous id generation within this group for instances of this class
        Returns:
        linkId
      • registerLinkSegment

        public LinkSegment registerLinkSegment​(LinkSegment linkSegment,
                                               boolean directionAB)
                                        throws PlanItException
        Register linkSegment. If there already exists a linkSegment for that direction it is replaced and returned
        Specified by:
        registerLinkSegment in interface Link
        Parameters:
        linkSegment - the link segment to be registered
        directionAB - direction of travel
        Returns:
        the replaced LinkSegment
        Throws:
        PlanItException - thrown if there is an error
      • getLinkId

        public long getLinkId()
        Description copied from interface: Link
        Return id of this instance. This id is expected to be generated using the org.planit.utils.misc.IdGenerator
        Specified by:
        getLinkId in interface Link
        Returns:
        linkId
      • setExternalId

        public void setExternalId​(Object externalId)
        Description copied from interface: Link
        Set the external id
        Specified by:
        setExternalId in interface Link
        Parameters:
        externalId - the external id to set
      • getExternalId

        public Object getExternalId()
        Description copied from interface: Link
        Collect the external id
        Specified by:
        getExternalId in interface Link
        Returns:
        externalID
      • hasExternalId

        public boolean hasExternalId()
        Description copied from interface: Link
        Returns whether the external Id has been set
        Specified by:
        hasExternalId in interface Link
        Returns:
        true if the external Id has been set, false otherwise