java.lang.Object
org.tweetyproject.logics.petri.syntax.PetriNetNode
org.tweetyproject.logics.petri.syntax.Place
All Implemented Interfaces:
Comparable<Place>, Node

public class Place extends PetriNetNode implements Comparable<Place>
A class to describe places in a Petri net
Author:
Benedikt Knopp
  • Constructor Details

    • Place

      public Place(String id)
      Create a new instance
      Parameters:
      id - a unique identifier
    • Place

      public Place(String id, String name)
      Create a new instance
      Parameters:
      id - a unique identifier
      name - a pretty name
  • Method Details

    • getId

      public String getId()
      Overrides:
      getId in class PetriNetNode
      Returns:
      the id
    • setId

      public void setId(String id)
      Overrides:
      setId in class PetriNetNode
      Parameters:
      id - the id to set
    • getTokens

      public int getTokens()
      Returns:
      the number of tokens currently at this place
    • setTokens

      public void setTokens(int tokens)
      Parameters:
      tokens - the number of tokens currently at this place
    • getMaxtokens

      public int getMaxtokens()
      Returns:
      the maximal number of tokens that this place can hold
    • setMaxtokens

      public void setMaxtokens(int maxtokens)
      Parameters:
      maxtokens - the maximal number of tokens that this place can hold
    • addTokens

      public void addTokens(int tokens)
      Parameters:
      tokens - the number of tokens to be added to this place
      Throws:
      IllegalArgumentException - if this number of tokens can not be added
    • removeTokens

      public void removeTokens(int tokens)
      Parameters:
      tokens - the number of tokens to be removed from this place
      Throws:
      IllegalArgumentException - if this number of tokens can not be removed
    • canAddTokens

      public boolean canAddTokens(int tokens)
      Parameters:
      tokens - the number of tokens to be added to this place
      Returns:
      true if this number can be added with respect to the token limit and the current number of tokens
    • canRemoveTokens

      public boolean canRemoveTokens(int tokens)
      Parameters:
      tokens - the number of tokens to be removed from this place
      Returns:
      true if this number can be removed with respect to current number of tokens
    • compareTo

      public int compareTo(Place that)
      Specified by:
      compareTo in interface Comparable<Place>
    • isInitial

      public boolean isInitial()
      check if this place is a designated initial place
      Returns:
      true iff this place is a designated initial place
    • setInitial

      public void setInitial()
      specify that this place is a designated initial place
    • isFinal

      public boolean isFinal()
      check if this place is a designated final place
      Returns:
      true iff this place is a designated final place
    • setFinal

      public void setFinal()
      specify that this place is a designated final place