Package org.jjazz.rhythm.api
Class RP_StringSet
java.lang.Object
org.jjazz.rhythm.api.RP_StringSet
- All Implemented Interfaces:
RhythmParameter<Set<String>>
,RpEnumerable<Set<String>>
- Direct Known Subclasses:
RP_SYS_Mute
public class RP_StringSet
extends Object
implements RhythmParameter<Set<String>>, RpEnumerable<Set<String>>
A RhythmParameter composed of a set of strings.
All Set instances returned are immutable.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal double
calculatePercentage
(Set<String> value) A unique value for a set.calculateValue
(double p) Calculate a Set from p as produced by calculatePercentage().convertValue
(RhythmParameter<T> rp, T value) Convert the value of a compatible RhythmParameter to a value for this RhythmParameter.boolean
final String
The description of this rhythm parameter.final String
getDisplayValue
(Set<String> value) Get a short String representation of the value.final String
getId()
getNextValue
(Set<String> value) Get the next value after specified value.Return a single-element list containing one set with all possible values.getPreviousValue
(Set<String> value) Get the next value before specified value.getValueDescription
(Set<String> value) Provide an optional description or help text associated to the specified value.int
hashCode()
boolean
isCompatibleWith
(RhythmParameter<?> rp) Indicate if rp is compatible with this RhythmParameter.boolean
Indicate if this RhythmParameter is a primary parameter for its rhythm.final boolean
isValidValue
(Set<String> value) True if all elements of value are one of the possible values, or if value is empty.Try to convert the specified string to a RhythmParameter value.saveAsString
(Set<String> value) Try to convert the specified RhythmParameter value to a string.toString()
Methods inherited from interface org.jjazz.rhythm.api.RhythmParameter
cloneValue
-
Field Details
-
MAX_SET_SIZE
public static final int MAX_SET_SIZE- See Also:
-
-
Constructor Details
-
RP_StringSet
public RP_StringSet(String id, String name, String description, boolean isPrimary, Set<String> defaultValue, String... possibleValues) Create a RP_StringSet.Created instance is primary by default.
- Parameters:
id
-name
- The name of the RhythmParameter.description
-isPrimary
-defaultValue
- All members of the Set must be one of the possibleValuespossibleValues
- String[] The possible values which can be used in a Set (max MAX_SET_SIZE). By convention, min value is set to the 1st possible value, max value to the last one. The empty string must not be one of the possible values.
-
-
Method Details
-
isPrimary
public boolean isPrimary()Description copied from interface:RhythmParameter
Indicate if this RhythmParameter is a primary parameter for its rhythm.This information is made available mainly for the user interface, e.g. to select which RhythmParameters to show first.
Default implementation returns true.
- Specified by:
isPrimary
in interfaceRhythmParameter<Set<String>>
- Returns:
-
hashCode
public int hashCode() -
equals
-
getId
- Specified by:
getId
in interfaceRhythmParameter<Set<String>>
- Returns:
- A unique identifier. Usually the english name.
-
getDefaultValue
- Specified by:
getDefaultValue
in interfaceRhythmParameter<Set<String>>
- Returns:
- Object The default value.
-
isValidValue
True if all elements of value are one of the possible values, or if value is empty.- Specified by:
isValidValue
in interfaceRhythmParameter<Set<String>>
- Parameters:
value
-- Returns:
-
calculateValue
Calculate a Set from p as produced by calculatePercentage().- Specified by:
calculateValue
in interfaceRpEnumerable<Set<String>>
- Parameters:
p
- [0-1]- Returns:
-
calculatePercentage
A unique value for a set.1/ Construct and int value : each bit correspond to the presence of not of the possibleValues.
2/ Divide this value by 10000 to make sure it's between 0 and 1.- Specified by:
calculatePercentage
in interfaceRpEnumerable<Set<String>>
- Returns:
- [0-1]
-
getDescription
Description copied from interface:RhythmParameter
The description of this rhythm parameter.- Specified by:
getDescription
in interfaceRhythmParameter<Set<String>>
- Returns:
-
getMaxValue
- Specified by:
getMaxValue
in interfaceRpEnumerable<Set<String>>
- Returns:
- A set with all the possible items.
-
getMinValue
- Specified by:
getMinValue
in interfaceRpEnumerable<Set<String>>
- Returns:
- An empty set.
-
getDisplayName
- Specified by:
getDisplayName
in interfaceRhythmParameter<Set<String>>
- Returns:
- The localized display name of the rhythm parameter.
-
getNextValue
Description copied from interface:RpEnumerable
Get the next value after specified value.- Specified by:
getNextValue
in interfaceRpEnumerable<Set<String>>
- Returns:
- Object
-
getPreviousValue
Description copied from interface:RpEnumerable
Get the next value before specified value.- Specified by:
getPreviousValue
in interfaceRpEnumerable<Set<String>>
- Returns:
- Object
-
getPossibleValues
Return a single-element list containing one set with all possible values.Note: this does not return all the possible combinations of the set.
- Specified by:
getPossibleValues
in interfaceRpEnumerable<Set<String>>
- Returns:
-
saveAsString
Description copied from interface:RhythmParameter
Try to convert the specified RhythmParameter value to a string.- Specified by:
saveAsString
in interfaceRhythmParameter<Set<String>>
- Parameters:
value
-- Returns:
- A string with format "[v1,v2,v5]"
- See Also:
-
loadFromString
Description copied from interface:RhythmParameter
Try to convert the specified string to a RhythmParameter value.- Specified by:
loadFromString
in interfaceRhythmParameter<Set<String>>
- Parameters:
s
- A string produced by valueToString().- Returns:
- Can be null if conversion failed.
- See Also:
-
getValueDescription
Description copied from interface:RhythmParameter
Provide an optional description or help text associated to the specified value.- Specified by:
getValueDescription
in interfaceRhythmParameter<Set<String>>
- Returns:
- Can be null.
-
toString
-
isCompatibleWith
Description copied from interface:RhythmParameter
Indicate if rp is compatible with this RhythmParameter.NOTE: if rp1 is compatible with rp2, then rp2 must be compatible with rp1 as well.
- Specified by:
isCompatibleWith
in interfaceRhythmParameter<Set<String>>
- Returns:
- True if a rp's value can be converted to a value for this RhythmParameter.
-
convertValue
Description copied from interface:RhythmParameter
Convert the value of a compatible RhythmParameter to a value for this RhythmParameter.- Specified by:
convertValue
in interfaceRhythmParameter<Set<String>>
- Type Parameters:
T
- A RhythmParameter value- Parameters:
rp
- A compatible RhythmParametervalue
- The value to convert- Returns:
- The rpValue converted for this RhythmParameter. Can't be null.
-
getDisplayValue
Description copied from interface:RhythmParameter
Get a short String representation of the value.- Specified by:
getDisplayValue
in interfaceRhythmParameter<Set<String>>
- Returns:
- Can be an empty String.
-