Class SlotOwner

java.lang.Object
marauroa.common.game.Attributes
marauroa.common.game.SlotOwner
All Implemented Interfaces:
Cloneable, Iterable<String>, Serializable
Direct Known Subclasses:
RPEvent, RPObject

public abstract class SlotOwner extends Attributes
interface for RP-classes that own slots
Author:
hendrik
  • Field Details

    • slots

      protected List<RPSlot> slots
      a list of slots that this object contains
  • Constructor Details

    • SlotOwner

      public SlotOwner(RPClass rpclass)
      creates a new SlowOwner
      Parameters:
      rpclass - RPClass definition
  • Method Details

    • fill

      public Object fill(Attributes attr)
      Description copied from class: Attributes
      This method fills this object with data from the attributes object passed as param
      Overrides:
      fill in class Attributes
      Parameters:
      attr - the attribute object to use to fill this one.
      Returns:
      the object itself.
    • hasSlot

      public boolean hasSlot(String name)
      This method returns true if the object has that slot
      Parameters:
      name - the name of the slot
      Returns:
      true if slot exists or false otherwise
    • addSlot

      public void addSlot(String name) throws SlotAlreadyAddedException
      This method add the slot to the object
      Parameters:
      name - the RPSlot name to be added
      Throws:
      SlotAlreadyAddedException - if the slot already exists
    • addSlot

      public void addSlot(RPSlot slot) throws SlotAlreadyAddedException
      This method add the slot to the object
      Parameters:
      slot - the RPSlot to be added
      Throws:
      SlotAlreadyAddedException - if the slot already exists
    • removeSlot

      public RPSlot removeSlot(String name)
      This method is used to remove an slot of the object
      Parameters:
      name - the name of the slot
      Returns:
      the removed slot if it is found or null if it is not found.
    • getSlot

      public RPSlot getSlot(String name)
      This method returns a slot whose name is name
      Parameters:
      name - the name of the slot
      Returns:
      the slot or null if the slot is not found
    • slotsIterator

      public Iterator<RPSlot> slotsIterator()
      Returns a iterator over the slots
      Returns:
      an iterator over the slots
    • slots

      public List<RPSlot> slots()
      Returns an unmodifiable list of the slots
      Returns:
      a list of the slots
    • serializeRPSlots

      protected void serializeRPSlots(OutputSerializer out, DetailLevel level) throws IOException
      Throws:
      IOException
    • writeToJson

      public void writeToJson(StringBuilder out, DetailLevel level)
      This method serialize the object with the given level of detail.
      Overrides:
      writeToJson in class Attributes
      Parameters:
      out - the output buffer
      level - the level of Detail
    • deserializeRPSlots

      protected void deserializeRPSlots(InputSerializer in) throws IOException
      Throws:
      IOException
    • toString

      public String toString()
      Description copied from class: Attributes
      This method returns a String that represent the object
      Overrides:
      toString in class Attributes
      Returns:
      a string representing the object.