Class DefaultFlowDataset<K extends Comparable<K>>

    • Constructor Detail

      • DefaultFlowDataset

        public DefaultFlowDataset()
        Creates a new dataset that is initially empty.
    • Method Detail

      • getSources

        public List<KgetSources​(int stage)
        Returns a list of the source nodes for the specified stage.
        Specified by:
        getSources in interface FlowDataset<K extends Comparable<K>>
        Parameters:
        stage - the stage (0 to getStageCount() - 1).
        Returns:
        A list of source nodes (possibly empty but never null).
      • getDestinations

        public List<KgetDestinations​(int stage)
        Returns a list of the destination nodes for the specified stage.
        Specified by:
        getDestinations in interface FlowDataset<K extends Comparable<K>>
        Parameters:
        stage - the stage (0 to getStageCount() - 1).
        Returns:
        A list of destination nodes (possibly empty but never null).
      • getNodeProperty

        public Object getNodeProperty​(NodeKey<K> nodeKey,
                                      String propertyKey)
        Returns the value of a property, if specified, for the specified node.
        Specified by:
        getNodeProperty in interface FlowDataset<K extends Comparable<K>>
        Parameters:
        nodeKey - the node key (null not permitted).
        propertyKey - the node key (null not permitted).
        Returns:
        The property value, or null.
      • setNodeProperty

        public void setNodeProperty​(NodeKey<K> nodeKey,
                                    String propertyKey,
                                    Object value)
        Sets a property for the specified node and notifies registered listeners that the dataset has changed.
        Parameters:
        nodeKey - the node key (null not permitted).
        propertyKey - the property key (null not permitted).
        value - the property value.
      • getFlow

        public Number getFlow​(int stage,
                              K source,
                              K destination)
        Returns the flow between a source node and a destination node at a specified stage. This must be 0 or greater. The dataset can return null to represent an unknown value.
        Specified by:
        getFlow in interface FlowDataset<K extends Comparable<K>>
        Parameters:
        stage - the stage index (0 to getStageCount() - 1).
        source - the source (null not permitted).
        destination - the destination (null not permitted).
        Returns:
        The flow (zero or greater, possibly null).
      • setFlow

        public void setFlow​(int stage,
                            K source,
                            K destination,
                            double flow)
        Sets the flow between a source node and a destination node at the specified stage. A new stage will be added if stage is equal to getStageCount().
        Parameters:
        stage - the stage (0 to getStageCount().
        source - the source (null not permitted).
        destination - the destination (null not permitted).
        flow - the flow (0 or greater).
      • getFlowProperty

        public Object getFlowProperty​(FlowKey<K> flowKey,
                                      String propertyKey)
        Returns the value of a property, if specified, for the specified flow.
        Specified by:
        getFlowProperty in interface FlowDataset<K extends Comparable<K>>
        Parameters:
        flowKey - flowKey (null not permitted).
        propertyKey - the property key (null not permitted).
        Returns:
        The property value, or null.
      • setFlowProperty

        public void setFlowProperty​(FlowKey<K> flowKey,
                                    String propertyKey,
                                    Object value)
        Sets a property for the specified flow and notifies registered listeners that the dataset has changed.
        Parameters:
        flowKey - the node key (null not permitted).
        propertyKey - the property key (null not permitted).
        value - the property value.
      • getStageCount

        public int getStageCount()
        Returns the number of flow stages. A flow dataset always has one or more stages, so this method will return 1 even for an empty dataset (one with no sources, destinations or flows defined).
        Specified by:
        getStageCount in interface FlowDataset<K extends Comparable<K>>
        Returns:
        The number of flow stages.
      • getInFlows

        public List<FlowKey<K>> getInFlows​(NodeKey nodeKey)
        Returns a list of flow keys for all the flows coming into this node.
        Parameters:
        nodeKey - the node key (null not permitted).
        Returns:
        A list of flow keys (possibly empty but never null).
      • getOutFlows

        public List<FlowKeygetOutFlows​(NodeKey nodeKey)
        Returns a list of flow keys for all the flows going out of this node.
        Parameters:
        nodeKey - the node key (null not permitted).
        Returns:
        A list of flow keys (possibly empty but never null).
      • equals

        public boolean equals​(Object obj)
        Tests this dataset for equality with an arbitrary object. This method will return true if the object implements the FlowDataset and defines the exact same set of nodes and flows as this dataset.
        Overrides:
        equals in class Object
        Parameters:
        obj - the object to test equality against (null permitted).
        Returns:
        A boolean.