java.lang.Object
edu.ntnu.idatt2001.paths.models.Link
Class link represents a link between two passages
The reference is a string that points to the name of the passage
- Version:
- 0.5 - 29.04.2023
- Author:
- Carl G. Callum G.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds an action to the list of actionsboolean
Two links are equal if they have the same reference This is to make the required map of links to passages point links with different text and actions to the same passageRetrieves the list of actionsRetrieves the passage reference.getText()
Retrieves the link text.int
hashCode()
Returns a hashcode for the link based on the referencetoString()
Returns a string representation of the link Uses text and reference example: Link 'Go to the kitchen' connects to 'kitchen'
-
Constructor Details
-
Link
public Link(String text, String reference, List<Action<?>> actions) throws NullPointerException, IllegalArgumentException Instantiates a new Link. Both text and reference should be set, but reference can be null if there is no passage to link to.- Parameters:
text
- String - text identification of the linkreference
- String - reference to the next passageactions
- List - group of actions which are executed when the link is used- Throws:
NullPointerException
- thrown if text is null, reference is null or actions is null or contains nullIllegalArgumentException
- thrown if text or reference is blank
-
Link
Instantiates a new Link. Both text and reference should be set, but reference can be null if there is no passage to link to.- Parameters:
text
- String - text identification of the linkreference
- String - reference to the next passage- Throws:
NullPointerException
- thrown if text or reference is nullIllegalArgumentException
- thrown if text or reference is only whitespace
-
-
Method Details
-
getText
Retrieves the link text.- Returns:
- String - text identification of the link
-
getReference
Retrieves the passage reference.- Returns:
- String - reference to the next passage
-
getActions
Retrieves the list of actions- Returns:
- List - list of actions to execute
-
addAction
Adds an action to the list of actions- Parameters:
action
- Action - action to add- Throws:
NullPointerException
- thrown if the action is null
-
toString
Returns a string representation of the link Uses text and reference example: Link 'Go to the kitchen' connects to 'kitchen' -
equals
Two links are equal if they have the same reference This is to make the required map of links to passages point links with different text and actions to the same passage -
hashCode
public int hashCode()Returns a hashcode for the link based on the reference
-