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
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal doublecalculatePercentage(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.booleanfinal StringThe description of this rhythm parameter.final StringgetDisplayValue(Set<String> value) Get a short String representation of the value.final StringgetId()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.inthashCode()booleanisCompatibleWith(RhythmParameter<?> rp) Indicate if rp is compatible with this RhythmParameter.booleanIndicate if this RhythmParameter is a primary parameter for its rhythm.final booleanisValidValue(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:RhythmParameterIndicate 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:
isPrimaryin interfaceRhythmParameter<Set<String>>- Returns:
-
hashCode
public int hashCode() -
equals
-
getId
- Specified by:
getIdin interfaceRhythmParameter<Set<String>>- Returns:
- A unique identifier. Usually the english name.
-
getDefaultValue
- Specified by:
getDefaultValuein 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:
isValidValuein interfaceRhythmParameter<Set<String>>- Parameters:
value-- Returns:
-
calculateValue
Calculate a Set from p as produced by calculatePercentage().- Specified by:
calculateValuein 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:
calculatePercentagein interfaceRpEnumerable<Set<String>>- Returns:
- [0-1]
-
getDescription
Description copied from interface:RhythmParameterThe description of this rhythm parameter.- Specified by:
getDescriptionin interfaceRhythmParameter<Set<String>>- Returns:
-
getMaxValue
- Specified by:
getMaxValuein interfaceRpEnumerable<Set<String>>- Returns:
- A set with all the possible items.
-
getMinValue
- Specified by:
getMinValuein interfaceRpEnumerable<Set<String>>- Returns:
- An empty set.
-
getDisplayName
- Specified by:
getDisplayNamein interfaceRhythmParameter<Set<String>>- Returns:
- The localized display name of the rhythm parameter.
-
getNextValue
Description copied from interface:RpEnumerableGet the next value after specified value.- Specified by:
getNextValuein interfaceRpEnumerable<Set<String>>- Returns:
- Object
-
getPreviousValue
Description copied from interface:RpEnumerableGet the next value before specified value.- Specified by:
getPreviousValuein 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:
getPossibleValuesin interfaceRpEnumerable<Set<String>>- Returns:
-
saveAsString
Description copied from interface:RhythmParameterTry to convert the specified RhythmParameter value to a string.- Specified by:
saveAsStringin interfaceRhythmParameter<Set<String>>- Parameters:
value-- Returns:
- A string with format "[v1,v2,v5]"
- See Also:
-
loadFromString
Description copied from interface:RhythmParameterTry to convert the specified string to a RhythmParameter value.- Specified by:
loadFromStringin interfaceRhythmParameter<Set<String>>- Parameters:
s- A string produced by valueToString().- Returns:
- Can be null if conversion failed.
- See Also:
-
getValueDescription
Description copied from interface:RhythmParameterProvide an optional description or help text associated to the specified value.- Specified by:
getValueDescriptionin interfaceRhythmParameter<Set<String>>- Returns:
- Can be null.
-
toString
-
isCompatibleWith
Description copied from interface:RhythmParameterIndicate 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:
isCompatibleWithin interfaceRhythmParameter<Set<String>>- Returns:
- True if a rp's value can be converted to a value for this RhythmParameter.
-
convertValue
Description copied from interface:RhythmParameterConvert the value of a compatible RhythmParameter to a value for this RhythmParameter.- Specified by:
convertValuein 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:RhythmParameterGet a short String representation of the value.- Specified by:
getDisplayValuein interfaceRhythmParameter<Set<String>>- Returns:
- Can be an empty String.
-