Class ImmutablePreferenceImpl
- java.lang.Object
-
- io.github.oliviercailloux.j_voting.preferences.classes.ImmutablePreferenceImpl
-
- All Implemented Interfaces:
ImmutablePreference
,Preference
- Direct Known Subclasses:
ImmutableAntiSymmetricPreferenceImpl
public class ImmutablePreferenceImpl extends Object implements ImmutablePreference
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ImmutablePreferenceImpl(Voter voter, Graph<Alternative> graph)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ImmutableGraph<Alternative>
asGraph()
In the graph : a relation from a to b means "a is at least as good as b".static ImmutablePreference
asImmutablePreference(Voter voter, Graph<Alternative> graph)
ImmutableGraph<Alternative>
asIntransitiveGraph()
static ImmutablePreference
copyOf(Preference preference)
Transform Preference to ImmutablePreferenceImmutableSet<Alternative>
getAlternatives()
The returned set reads through this object: if this object is mutable, any modification to this object modifies the returned set, and conversely.Voter
getVoter()
-
-
-
Constructor Detail
-
ImmutablePreferenceImpl
protected ImmutablePreferenceImpl(Voter voter, Graph<Alternative> graph)
- Parameters:
voter
-not null
graph
-not null
graph with ordered Alternatives
-
-
Method Detail
-
asImmutablePreference
public static ImmutablePreference asImmutablePreference(Voter voter, Graph<Alternative> graph)
- Parameters:
voter
-not null
graph
-not null
graph with ordered Alternatives- Returns:
- new ImmutablePreference
-
copyOf
public static ImmutablePreference copyOf(Preference preference)
Transform Preference to ImmutablePreference- Parameters:
preference
-not null
- Returns:
- ImmutablePreference
-
asGraph
public ImmutableGraph<Alternative> asGraph()
Description copied from interface:ImmutablePreference
In the graph : a relation from a to b means "a is at least as good as b". This graph can’t be modified, but is not necessarily immutable. Reflexive and transitive. This graph is immutable.- Specified by:
asGraph
in interfaceImmutablePreference
- Specified by:
asGraph
in interfacePreference
- Returns:
- the Graph corresponding to the Preference.
-
asIntransitiveGraph
public ImmutableGraph<Alternative> asIntransitiveGraph()
-
getAlternatives
public ImmutableSet<Alternative> getAlternatives()
Description copied from interface:ImmutablePreference
The returned set reads through this object: if this object is mutable, any modification to this object modifies the returned set, and conversely. This set is immutable.- Specified by:
getAlternatives
in interfaceImmutablePreference
- Specified by:
getAlternatives
in interfacePreference
- Returns:
- alternatives's set
-
getVoter
public Voter getVoter()
- Specified by:
getVoter
in interfacePreference
- Returns:
Voter
instance of the preference, Returns the voter 0 if no specific voter is associated to this preference
-
-