Package overit.geocall.ui
Class ListAttribute
- All Implemented Interfaces:
com.esotericsoftware.kryo.KryoSerializable,Serializable,Cloneable,Iterable<String>,Collection<String>,List<String>,RandomAccess,SequencedCollection<String>
public class ListAttribute
extends ArrayList<String>
implements com.esotericsoftware.kryo.KryoSerializable
This class implements an utility object typically used for setting attributes.
It is possible to pass to the constructor a string containing values, separated by a customizable delimiter character (the default one is the character |), in order to automatically obtain a list containing the values.
The class exposes the getter methods to find the values in a smart way; it is possible to query the list even on positions greater than the size of the list itself; in that case a default value will be returned, that can be global or local, both customizable.
It is possible to pass to the constructor a string containing values, separated by a customizable delimiter character (the default one is the character |), in order to automatically obtain a list containing the values.
The class exposes the getter methods to find the values in a smart way; it is possible to query the list even on positions greater than the size of the list itself; in that case a default value will be returned, that can be global or local, both customizable.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringThe defaultValue is the last attribute value of the collection if presentFields inherited from class java.util.AbstractList
modCount -
Constructor Summary
ConstructorsConstructorDescriptionConstructs an empty ListAttributeListAttribute(String values) Constructs a ListAttribute starting from the string passed as parameter.ListAttribute(String values, char delim) Constructs a ListAttribute starting from the string passed as parameter. -
Method Summary
Modifier and TypeMethodDescriptionGets the default global value for the attribute listgetdouble(int i, double def) Extracts a double value from the list.Extracts a Double value from the list.longgetlong(int i, long def) Extracts a long value from the list.Extracts a Long value from the list.Extracts a String from the list.voidread(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Input input) voidsetDefault(String def) Sets the global default value, that isnullby defaultTranslates the values of the listTranslates the values of the list, considering them as labelsvoidwrite(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Output output) Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, addFirst, addLast, clear, clone, contains, ensureCapacity, equals, forEach, get, getFirst, getLast, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeFirst, removeIf, removeLast, removeRange, replaceAll, retainAll, size, sort, spliterator, subList, toArray, toArray, trimToSizeMethods inherited from class java.util.AbstractCollection
containsAll, toStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, stream, toArrayMethods inherited from interface java.util.List
containsAll, reversed
-
Field Details
-
defaultValue
The defaultValue is the last attribute value of the collection if present
-
-
Constructor Details
-
ListAttribute
public ListAttribute()Constructs an empty ListAttribute -
ListAttribute
Constructs a ListAttribute starting from the string passed as parameter. Every element must be separated from the others with the default separator character, that is | (pipe)- Parameters:
values- The string that defines the values, separated with the | character
-
ListAttribute
Constructs a ListAttribute starting from the string passed as parameter. Every element must be separated from the others with the separator character, passed as second parameter- Parameters:
values- The string that defines the valuesdelim- The character used as separator between the values
-
-
Method Details
-
setDefault
Sets the global default value, that isnullby default- Parameters:
def- The value to set
-
getDefault
Gets the default global value for the attribute list- Returns:
- the default value
-
translate
Translates the values of the list- Parameters:
t- TheTeacherthat will manage the translations- Returns:
thisinstance of ListAttribute with the translated values
-
translateLabel
Translates the values of the list, considering them as labels- Parameters:
t- TheTeacherthat will manage the translations- Returns:
thisinstance of ListAttribute with the translated values
-
getString
Extracts a String from the list.- Parameters:
i- The position of the String to extractdef- The default value returned if the String in the desired position isnull, or when the position is greater than the size of the list and the global default value isnull- Returns:
- The String in the desired position. If the String is
nullit returns the default value passed as parameter. If the position is greater than the size of the list and the global default value (the one set with the methodsetDefault(java.lang.String)) isnull, it returns the default value passed as parameter; if the position is greater than the size of the list and the global default value is notnull, it returns the global default value
-
getDouble
Extracts a Double value from the list.- Parameters:
i- The position of the Double to extractdef- The default value returned if the Double in the desired position isnull, or when the position is greater than the size of the list and the global default value isnull- Returns:
- The Double in the desired position. If the Double is
nullit returns the default value passed as parameter. If the position is greater than the size of the list and the global default value (the one set with the methodsetDefault(java.lang.String)) isnull, it returns the default value passed as parameter; if the position is greater than the size of the list and the global default value is notnull, it returns the global default value
-
getdouble
Extracts a double value from the list.- Parameters:
i- The position of the double to extractdef- The default value returned if the double in the desired position isnull, or when the position is greater than the size of the list and the global default value isnull- Returns:
- The double in the desired position. If the double is
nullit returns the default value passed as parameter. If the position is greater than the size of the list and the global default value (the one set with the methodsetDefault(java.lang.String)) isnull, it returns the default value passed as parameter; if the position is greater than the size of the list and the global default value is notnull, it returns the global default value
-
getLong
Extracts a Long value from the list.- Parameters:
i- The position of the Long to extractdef- The default value returned if the Long in the desired position isnull, or when the position is greater than the size of the list and the global default value isnull- Returns:
- The Long in the desired position. If the Long is
nullit returns the default value passed as parameter. If the position is greater than the size of the list and the global default value (the one set with the methodsetDefault(java.lang.String)) isnull, it returns the default value passed as parameter; if the position is greater than the size of the list and the global default value is notnull, it returns the global default value
-
getlong
public long getlong(int i, long def) Extracts a long value from the list.- Parameters:
i- The position of the long to extractdef- The default value returned if the long in the desired position isnull, or when the position is greater than the size of the list and the global default value isnull- Returns:
- The long in the desired position. If the long is
nullit returns the default value passed as parameter. If the position is greater than the size of the list and the global default value (the one set with the methodsetDefault(java.lang.String)) isnull, it returns the default value passed as parameter; if the position is greater than the size of the list and the global default value is notnull, it returns the global default value
-
set
-
write
public void write(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Output output) - Specified by:
writein interfacecom.esotericsoftware.kryo.KryoSerializable
-
read
public void read(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Input input) - Specified by:
readin interfacecom.esotericsoftware.kryo.KryoSerializable
-