Class UserState<U>

java.lang.Object
es.uam.eps.ir.relison.diffusion.simulation.UserState<U>
Type Parameters:
U - type of the user identifier.
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
FastUser

public abstract class UserState<U>
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable
Abstract representation for the users.
See Also:
Serialized Form
  • Field Details

    • userId

      private final U userId
      Identifier of the user.
  • Constructor Details

    • UserState

      public UserState​(U userId)
      Constructor.
      Parameters:
      userId - identifier of the user.
  • Method Details

    • getUserId

      public U getUserId()
      Obtains the identifier of the user.
      Returns:
      the identifier.
    • addOwnInformation

      protected abstract boolean addOwnInformation​(PropagatedInformation info)
      Adds a piece of information to the own created information pieces.
      Parameters:
      info - Information to add.
      Returns:
      true if everything is OK.
    • addReceivedInformation

      protected abstract boolean addReceivedInformation​(PropagatedInformation info)
      Adds a piece of information to the previously received information pieces. This information can only be added if it was previously on the newly received information data. This method also deletes the data from that list.
      Parameters:
      info - Information to add.
      Returns:
      true if everything is OK.
    • addSeenInformation

      protected abstract boolean addSeenInformation​(PropagatedInformation info)
      Adds a piece of information to the newly seen information pieces.
      Parameters:
      info - Information to add.
      Returns:
      true if everything is OK.
    • addDiscardedInformation

      protected abstract boolean addDiscardedInformation​(PropagatedInformation info)
      Adds a piece of information to the discarded information pieces. This information can only be
      Parameters:
      info - Information to add.
      Returns:
      true if everything is OK.
    • addPropagatedInformation

      protected abstract boolean addPropagatedInformation​(PropagatedInformation info)
      Adds a piece of information to the propagated information pieces.
      Parameters:
      info - Information to add.
      Returns:
      true if everything is OK.
    • addAllInformation

      protected abstract boolean addAllInformation​(PropagatedInformation info)
      Adds a piece of information to all the received information pieces.
      Parameters:
      info - Information to add.
      Returns:
      true if everything is OK.
    • getOwnInformation

      protected abstract PropagatedInformation getOwnInformation​(int info)
      Gets an individual piece of own created information.
      Parameters:
      info - The identifier of the information.
      Returns:
      The corresponding piece of information.
    • getReceivedInformation

      protected abstract PropagatedInformation getReceivedInformation​(int info)
      Gets an individual piece of received information.
      Parameters:
      info - The iodentifier of the information.
      Returns:
      The correspondiing piede of information.
    • getSeenInformation

      protected abstract PropagatedInformation getSeenInformation​(int info)
      Gets an individual piece of newly seen created information
      Parameters:
      info - The identifier of the information
      Returns:
      The corresponding piece of information.
    • getPropagatedInformation

      protected abstract PropagatedInformation getPropagatedInformation​(int info)
      Gets an individual piece of propagated information.
      Parameters:
      info - The identifier of the propagated information
      Returns:
      The corresponding piece of information.
    • getDiscardedInformation

      protected abstract PropagatedInformation getDiscardedInformation​(int info)
      Gets an individual piece of discarded information.
      Parameters:
      info - The identifier of the discarded information.
      Returns:
      The corresponding piece of information.
    • getAllInformation

      protected abstract PropagatedInformation getAllInformation​(int info)
      Gets an individual piece of the set of all previously received information
      Parameters:
      info - The identifier of the discarded information.
      Returns:
      The corresponding piece of information.
    • containsOwnInformation

      public abstract boolean containsOwnInformation​(int info)
      Gets an individual piece of own created information.
      Parameters:
      info - The identifier of the information.
      Returns:
      The corresponding piece of information.
    • containsReceivedInformation

      public abstract boolean containsReceivedInformation​(int info)
      Gets an individual piece of received information.
      Parameters:
      info - The iodentifier of the information.
      Returns:
      The correspondiing piede of information.
    • containsSeenInformation

      public abstract boolean containsSeenInformation​(int info)
      Gets an individual piece of newly seen information.
      Parameters:
      info - The identifier of the information.
      Returns:
      The corresponding piece of information.
    • containsPropagatedInformation

      public abstract boolean containsPropagatedInformation​(int info)
      Gets an individual piece of propagated information.
      Parameters:
      info - The identifier of the propagated information.
      Returns:
      The corresponding piece of information.
    • containsDiscardedInformation

      public abstract boolean containsDiscardedInformation​(int info)
      Gets an individual piece of discarded information.
      Parameters:
      info - The identifier of the discarded information.
      Returns:
      The corresponding piece of information.
    • containsAllInformation

      public abstract boolean containsAllInformation​(int info)
      Checks if an individual piece of all the previous information exists.
      Parameters:
      info - The identifier of the piece of information.
      Returns:
      true if exists, false if not.
    • deleteOwnInformation

      protected abstract boolean deleteOwnInformation​(int info)
      Deletes a piece of own created information.
      Parameters:
      info - The identifier of the own created information.
      Returns:
      true if the information is deleted, false if not.
    • deleteReceivedInformation

      protected abstract boolean deleteReceivedInformation​(int info)
      Deletes a piece of received information.
      Parameters:
      info - The identifier of the received information
      Returns:
      true if the information is deleted, false if not.
    • deleteSeenInformation

      protected abstract boolean deleteSeenInformation​(int info)
      Deletes a piece of newly seen information.
      Parameters:
      info - The identifier of the newly received information.
      Returns:
      true if the information is deleted, false if not.
    • deletePropagatedInformation

      protected abstract boolean deletePropagatedInformation​(int info)
      Deletes a piece of propagated information.
      Parameters:
      info - The identifier of the propagter information.
      Returns:
      true if the information is deleted, false if not.
    • deleteDiscardedInformation

      protected abstract boolean deleteDiscardedInformation​(int info)
      Deletes a piece of discarded information.
      Parameters:
      info - The identifier of the discarded information.
      Returns:
      true if the information is deleted, false if not.
    • resetOwnInformation

      public void resetOwnInformation​(java.util.stream.Stream<PropagatedInformation> information)
      Resets the list of own information.
      Parameters:
      information - The new own information.
    • updateSeenToReceived

      public void updateSeenToReceived​(UpdateMechanism update)
      Moves the valid elements from the new set of pieces of information to the received one.
      Parameters:
      update - The update mechanism.
    • updateSeenToReceived

      public void updateSeenToReceived​(int info, UpdateMechanism update)
      Updates an individual seen piece of information to received.
      Parameters:
      info - the information piece.
      update - the update mechanism.
    • updateReceivedToPropagated

      public void updateReceivedToPropagated​(java.util.stream.Stream<java.lang.Integer> toPropagate)
      Moves some received information to propagated information.
      Parameters:
      toPropagate - Information to propagate.
    • updateOwnToPropagated

      public void updateOwnToPropagated​(java.util.stream.Stream<java.lang.Integer> toPropagate)
      Moves some own created information to propagated information.
      Parameters:
      toPropagate - Information to propagate.
    • updateSeen

      public void updateSeen​(java.util.stream.Stream<PropagatedInformation> information)
      Adds and updates new information pieces to the new list.
      Parameters:
      information - A stream with all the information pieces to add.
    • discardReceivedInformation

      public void discardReceivedInformation​(java.util.stream.Stream<java.lang.Integer> information)
      Discards part of the received information.
      Parameters:
      information - the information to discard.
    • updateSeen

      public void updateSeen​(PropagatedInformation info)
      Adds and updates new information pieces to the new list. If it is own information or already propagated information, it is not added.
      Parameters:
      info - An information piece to add.
    • updateAll

      public void updateAll​(PropagatedInformation info)
      Adds and updates new information pieces to the list of all previously contained information.
      Parameters:
      info - An information piece to add.
    • getOwnInformationIds

      public java.util.stream.Stream<java.lang.Integer> getOwnInformationIds()
      Gets all the identifiers of the information created by this user. Every information contained in this list can be sent.
      Returns:
      The stream.
    • getReceivedInformationIds

      public java.util.stream.Stream<java.lang.Integer> getReceivedInformationIds()
      Gets all the identifiers of the information received by this user. Every information contained in this list can be sent.
      Returns:
      The stream.
    • getPropagatedInformationIds

      public java.util.stream.Stream<java.lang.Integer> getPropagatedInformationIds()
      Gets all the information previously propagated by this user.
      Returns:
      A stream with all the information identifiers.
    • getDiscardedInformationIds

      public java.util.stream.Stream<java.lang.Integer> getDiscardedInformationIds()
      Gets all the information previously discarded by this user.
      Returns:
      A stream with all the discarded information identifiers.
    • getSeenInformationIds

      public java.util.stream.Stream<java.lang.Integer> getSeenInformationIds()
      Gets all the new information seen by this user.
      Returns:
      A stream with all the identifiers.
    • getAllInformationIds

      public java.util.stream.Stream<java.lang.Integer> getAllInformationIds()
      Gets all the information that the user has received along time
      Returns:
      A stream with all the identifiers.
    • getOwnInformation

      public abstract java.util.stream.Stream<PropagatedInformation> getOwnInformation()
      Gets all the information created by this user. Every tweet contained in this list can be sent.
      Returns:
      The stream.
    • getReceivedInformation

      public abstract java.util.stream.Stream<PropagatedInformation> getReceivedInformation()
      Gets all the information received by this user. Every tweet contained in this list can be retweeted.
      Returns:
      A stream with all the information identifiers.
    • getPropagatedInformation

      public abstract java.util.stream.Stream<PropagatedInformation> getPropagatedInformation()
      Gets all the information previously propagated by this user.
      Returns:
      A stream with all the information identifiers.
    • getDiscardedInformation

      public abstract java.util.stream.Stream<PropagatedInformation> getDiscardedInformation()
      Gets all the information previously discarded by this user.
      Returns:
      A stream with all the discarded information identifiers.
    • getSeenInformation

      public abstract java.util.stream.Stream<PropagatedInformation> getSeenInformation()
      Gets all the new information received by this user.
      Returns:
      A stream with all the identifiers.
    • getAllInformation

      public abstract java.util.stream.Stream<PropagatedInformation> getAllInformation()
      Gets all the information that the user has received during the simulations
      Returns:
      A stream with all the information.
    • equals

      public boolean equals​(java.lang.Object object)
      Overrides:
      equals in class java.lang.Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class java.lang.Object
    • clear

      protected abstract void clear()
      Clears all the data for the user.
    • clearSeenInformation

      protected abstract void clearSeenInformation()
      Clears the seen information.
    • clone

      public UserState<U> clone() throws java.lang.CloneNotSupportedException
      Overrides:
      clone in class java.lang.Object
      Throws:
      java.lang.CloneNotSupportedException