de.uka.ipd.consensus.impl
Class TypeInstanceImpl

java.lang.Object
  extended byde.uka.ipd.consensus.impl.TypeInstanceImpl
All Implemented Interfaces:
Comparable, Rateable, Serializable, TypeInstance

public class TypeInstanceImpl
extends Object
implements TypeInstance

TODO

Version:
2006-06-14
Author:
Thomas Much
See Also:
Serialized Form

Constructor Summary
protected TypeInstanceImpl(Topic instance, Topic type, Association assoc)
           
 
Method Summary
 Rating addRating(User rater, double value)
          Adds a rating for the given user to this element.
 int compareTo(Object other)
           
 boolean equals(Object other)
           
 double getAverageRatingValue()
          Returns the average value (the arithmetic mean) of all current ratings for this element.
 String getId()
          Returns the id of the element that is unique within the ontology.
 Topic getInstance()
          Returns the instance topic of a type-instance-relationship between two topics.
 Rating getRating(User rater)
          Returns the rating of the given user for this element.
 Collection getRatings()
          Returns a collection of all current Rating objects (from different users) for this element.
 int getRatingsCount()
          Returns the number of ratings for this element.
 Topic getType()
          Returns the type topic of a type-instance-relationship between two topics.
 int hashCode()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TypeInstanceImpl

protected TypeInstanceImpl(Topic instance,
                           Topic type,
                           Association assoc)
Method Detail

getType

public Topic getType()
Description copied from interface: TypeInstance
Returns the type topic of a type-instance-relationship between two topics.

Specified by:
getType in interface TypeInstance
Returns:
the type topic, never null

getInstance

public Topic getInstance()
Description copied from interface: TypeInstance
Returns the instance topic of a type-instance-relationship between two topics.

Specified by:
getInstance in interface TypeInstance
Returns:
the instance topic, never null

getId

public String getId()
Description copied from interface: Rateable
Returns the id of the element that is unique within the ontology. This is used to distinguish concepts and users.

Specified by:
getId in interface Rateable
Returns:
the id (never empty, never null)

addRating

public Rating addRating(User rater,
                        double value)
                 throws RatingManagerException,
                        DynamicRightsManagerException
Description copied from interface: Rateable
Adds a rating for the given user to this element. If the user has rated the element already, only the rating's value is changed. Otherwise, this method creates and adds a new rating using suitable RatingManager methods.

Specified by:
addRating in interface Rateable
Parameters:
rater - the user who wants to add or change the rating
value - the new value
Returns:
the newly created or the existing but changed rating
Throws:
DynamicRightsManagerException - if the user is not allowed to rate this element
RatingManagerException - if the rating could not be created/changed
See Also:
RatingManager, DynamicRightsManager.mayAddRating(Rating, Rateable)

getRatings

public Collection getRatings()
Description copied from interface: Rateable
Returns a collection of all current Rating objects (from different users) for this element. This method exists just for convenience and delegates to one of the getRatings() methods of RatingManager.

Specified by:
getRatings in interface Rateable
Returns:
a possibly empty collection, never null
See Also:
Rating, RatingManager

getRatingsCount

public int getRatingsCount()
Description copied from interface: Rateable
Returns the number of ratings for this element. Each user can have only one current rating for each element, i.e. historical ratings do not count.

Specified by:
getRatingsCount in interface Rateable
Returns:
the number of ratings for this element.

getRating

public Rating getRating(User rater)
Description copied from interface: Rateable
Returns the rating of the given user for this element. This method exists just for convenience and delegates to one of the getRatings() methods of RatingManager.

Specified by:
getRating in interface Rateable
Parameters:
rater - the user who's rating shall be returned
Returns:
the rating of the user or null if the user hasn't rated this element yet
See Also:
RatingManager

getAverageRatingValue

public double getAverageRatingValue()
Description copied from interface: Rateable
Returns the average value (the arithmetic mean) of all current ratings for this element.

Specified by:
getAverageRatingValue in interface Rateable
Returns:
the arithmetic mean of all ratings for this element

equals

public boolean equals(Object other)

hashCode

public int hashCode()

compareTo

public int compareTo(Object other)
Specified by:
compareTo in interface Comparable

toString

public String toString()