Release version

This commit is contained in:
2025-11-07 14:01:03 +01:00
parent 909f62d19f
commit 44f03857d2
20 changed files with 46 additions and 95 deletions

View File

@@ -0,0 +1,46 @@
package com.kasetoatz.dacl.options;
import com.google.gson.JsonElement;
import com.kasetoatz.dacl.options.validators.AbstractValidator;
public class IntOption extends AbstractInputOption<Integer>
{
public IntOption(String text, String key, Integer defaultValue, AbstractValidator<Integer> validator)
{
super(text, key, defaultValue, validator);
}
public IntOption(String text, String key, Integer defaultValue)
{
super(text, key, defaultValue);
}
@Override
public boolean predicate(String text)
{
if (text.isEmpty() || text.equals("-")) {
return true;
}
try
{
Integer.parseInt(text);
return true;
}
catch (NumberFormatException exc)
{
return false;
}
}
@Override
public void changeListener(String text)
{
this.onChange((text.isEmpty() || text.equals("-")) ? 0 : Integer.parseInt(text));
}
@Override
public Integer asPrimitive(JsonElement element)
{
return element.getAsInt();
}
}