This is an automated email from the ASF dual-hosted git repository.
doebele pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/empire-db.git
The following commit(s) were added to refs/heads/master by this push:
new 65fb42a7 EMPIREDB-431 Options: append function added
65fb42a7 is described below
commit 65fb42a7deaa8673075f3561999bb08c8ff4aadb
Author: Rainer Döbele <[email protected]>
AuthorDate: Mon Feb 17 18:10:33 2025 +0100
EMPIREDB-431
Options: append function added
---
.../java/org/apache/empire/commons/Options.java | 23 ++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/empire-db/src/main/java/org/apache/empire/commons/Options.java
b/empire-db/src/main/java/org/apache/empire/commons/Options.java
index 962bc7a4..3b70727c 100644
--- a/empire-db/src/main/java/org/apache/empire/commons/Options.java
+++ b/empire-db/src/main/java/org/apache/empire/commons/Options.java
@@ -158,9 +158,9 @@ public class Options extends AbstractSet<OptionEntry>
implements Cloneable, Seri
Top, Bottom, Sort
}
- private final ArrayList<OptionEntry> list;
+ protected final ArrayList<OptionEntry> list;
- private OptionGroupResolver optionGroupResolver;
+ protected OptionGroupResolver optionGroupResolver;
public Options()
{ // Default constructor
@@ -424,7 +424,7 @@ public class Options extends AbstractSet<OptionEntry>
implements Cloneable, Seri
}
else
{ // add new Option
- list.add(createOptionEntry(value, text, (active!=null ? active
:true )));
+ append(value, text, (active!=null ? active :true ));
}
}
@@ -467,17 +467,28 @@ public class Options extends AbstractSet<OptionEntry>
implements Cloneable, Seri
@Override
public boolean add(OptionEntry option)
{
- if (option==null || option.getText() == null)
+ if (option==null)
throw new InvalidArgumentException("option", option);
// find and add or replace
OptionEntry oe = getEntry(option.getValue());
if (oe!=null)
list.set(getIndex(oe), option);
else
- list.add(option);
+ append(option);
return true;
}
+ /**
+ * Appends an option
+ * Useful for fast loading when it is certain that there are no duplicates
+ * WARNING: Does not check if the entry already exists
+ * @param option the option to append
+ */
+ public void append(OptionEntry option)
+ {
+ list.add(option);
+ }
+
/**
* Appends an option
* Useful for fast loading when it is certain that there are no duplicates
@@ -490,7 +501,7 @@ public class Options extends AbstractSet<OptionEntry>
implements Cloneable, Seri
{
if (text == null)
text = StringUtils.EMPTY;
- list.add(createOptionEntry(value, text, active));
+ append(createOptionEntry(value, text, active));
}
@Override