Re structuring property

This commit is contained in:
2026-03-20 20:14:24 +01:00
parent 00d8ca5f50
commit 1a79309d04
10 changed files with 198 additions and 181 deletions
@@ -0,0 +1,37 @@
package org.saturnclient.config.property;
import org.saturnclient.config.property.Property.PropertyType;
public class SelectProperty extends Property {
public final int value;
public final int defaultValue;
public final String[] availableValues;
public SelectProperty(int defaultValue, String... availableValues) {
this.value = defaultValue;
this.defaultValue = defaultValue;
this.availableValues = availableValues;
}
public void next() {
int i = (Integer) value;
setValue((i < availableValues.length - 1) ? i + 1 : 0);
}
public void prev() {
if (type == PropertyType.SELECT) {
int i = (Integer) value;
setValue((i > 0) ? i - 1 : availableValues.length - 1);
}
}
public void setSelection(int selection) {
if (type == PropertyType.SELECT && selection >= 0 && selection < availableValues.length) {
setValue(selection);
}
}
public String getSelection() {
return (type == PropertyType.SELECT) ? availableValues[(Integer) value] : null;
}
}