Class DataMappingUtils
java.lang.Object
com.priint.pubserver.comet.bridge.datamapping.DataMappingUtils
The type Data mapping utils.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanAll boolean.static booleancheckRange(List<?> values, List<Integer> range) Check range boolean.Empty list list.static voidfailIfInputEmpty(Object caller, List<?> in) Fail if input empty.static voidfailIfSizeDiffer(Object caller, List<?> input, List<?> output, String entityModelIdentifier, String entityId, String parentBucketId, String recordGroupIdentifier, String resultEntityId, Context context, String searchStr) Fail if size differ.static <T> voidfailIfTargetEmpty(Object caller, T target, Class<?> clazz, String entityModelIdentifier, String entityId, String parentBucketId, String recordGroupIdentifier, String resultEntityId, Context context, String searchStr, int... range) Fail if target empty.filterByKey(List<KeyValue> values, String key) Filter by key list.static StringgetDelimiter(String delimiter, int pos, int size) Adds delimiter after each but not the last element of the returned stringstatic <T> TgetListElement(List<T> input, int index) Gets list element.static MediaObjectgetMediaObjectByTypeAndMedia(MediaAsset asset, String type, String media) Gets media object by type and media.static <T> TGets nth of.static <T> TgetNthOf(T[] in, int nth) Gets nth of.getRecordIndexList(String[] record, int listSize) Returns list of indexesstatic <T> List<T>getSubList(List<T> values, List<Integer> range) Gets sub list.static IntegergetZBasedIndex(int pos, int listSize) Returns index of the requested recordstatic StringList size string.parseNumberList(String input) Parse number list list.parseNumberList(String input, char fieldSeparator) Parse number list list.parseQuotedList(String input) Parse quoted list list.parseQuotedList(String input, char fieldSeparator, char fieldDelimiter) Parse quoted list list.static StringPop front string.static StringPop tail string.processRange(List<?> values, String input) Process range list.static Stringrange(int... range) Range string.static <T> TrequireNthOf(List<T> in, int nth) Require nth of t.static <T> TrequireNthOf(T[] in, int nth) Require nth of t.static String[]Split string [ ].stringList(String... strings) Converts a string array or several strings to a string liststatic StringReturns the string given or empty string if null was given.static booleanValidates correctness of the requested records list, list can contain positive and negative Integers, or the String 'all'
-
Field Details
-
LAST
public static final int LASTThe constant LAST.- See Also:
-
FIRST
public static final int FIRSTThe constant FIRST.- See Also:
-
-
Method Details
-
emptyList
Empty list list.- Returns:
- a String List containing one (empty) string
-
stringList
Converts a string array or several strings to a string list
- Parameters:
strings- zero, one or more strings- Returns:
- a string list containing all strings provided as argument
-
getListElement
Gets list element.- Type Parameters:
T- the type parameter- Parameters:
input- the inputindex- the index- Returns:
- the list element
-
processRange
Process range list.- Parameters:
values- the valuesinput- the input- Returns:
- the list
-
getSubList
Gets sub list.- Type Parameters:
T- the type parameter- Parameters:
values- the valuesrange- the range- Returns:
- the sub list
-
checkRange
Check range boolean.- Parameters:
values- the valuesrange- the range- Returns:
- the boolean
-
getRecordIndexList
Returns list of indexes- Parameters:
record- list of requested records, delimited by ',' (comma), can contain- string 'all' whole list will be returned
- positive numbers - returns, value decremented by one e.g 1 will return index of 0
- negative numbers - returns element count from the end of the list, e.g -1 will return index of the last element
- 0 (zero) - returns index of the first element, the same result as 1
listSize- length of list from which records are requested- Returns:
- list of indexes from the parameter list, requested by record
-
validList
Validates correctness of the requested records list, list can contain positive and negative Integers, or the String 'all'- Parameters:
records- array of values to be checked- Returns:
- true if text is not null and is not empty and all values are correct
-
getDelimiter
Adds delimiter after each but not the last element of the returned string- Parameters:
delimiter- delimiter to be addedpos- position of the element, when 0 (zero) returns empty stringsize- number of all elements in the list- Returns:
- delimiter or empty stringreturn (pos == 0 ? "" : (pos + 1 < size ? delimiter : ""));
-
parseQuotedList
Parse quoted list list.- Parameters:
input- the inputfieldSeparator- the field separatorfieldDelimiter- the field delimiter- Returns:
- the list
-
parseQuotedList
Parse quoted list list.- Parameters:
input- the input- Returns:
- the list
-
parseNumberList
Parse number list list.- Parameters:
input- the inputfieldSeparator- the field separator- Returns:
- the list
-
parseNumberList
Parse number list list.- Parameters:
input- the input- Returns:
- the list
-
toString
Returns the string given or empty string if null was given.Use this to prevent Null Pointer Exceptions.
- Parameters:
input- the input- Returns:
- string
-
getNthOf
Gets nth of.- Type Parameters:
T- the type parameter- Parameters:
in- the innth- the nth- Returns:
- the nth of
-
getNthOf
public static <T> T getNthOf(T[] in, int nth) Gets nth of.- Type Parameters:
T- the type parameter- Parameters:
in- the innth- the nth- Returns:
- the nth of
-
requireNthOf
Require nth of t.- Type Parameters:
T- the type parameter- Parameters:
in- the innth- the nth- Returns:
- the t
- Throws:
PubServerException- the pub server exception
-
requireNthOf
Require nth of t.- Type Parameters:
T- the type parameter- Parameters:
in- the innth- the nth- Returns:
- the t
- Throws:
PubServerException- the pub server exception
-
filterByKey
Filter by key list.- Parameters:
values- the valueskey- the key- Returns:
- the list
-
split
Split string [ ].- Parameters:
value- the valueseparator- the separator- Returns:
- the string [ ]
-
popFront
Pop front string.- Parameters:
from- the fromprefix- the prefix- Returns:
- the string
-
popTail
Pop tail string.- Parameters:
from- the fromsuffix- the suffix- Returns:
- the string
-
failIfInputEmpty
Fail if input empty.- Parameters:
caller- the callerin- the in- Throws:
PubServerException- the pub server exception
-
failIfTargetEmpty
public static <T> void failIfTargetEmpty(Object caller, T target, Class<?> clazz, String entityModelIdentifier, String entityId, String parentBucketId, String recordGroupIdentifier, String resultEntityId, Context context, String searchStr, int... range) throws PubServerException Fail if target empty.- Type Parameters:
T- the type parameter- Parameters:
caller- the callertarget- the targetclazz- the clazzentityModelIdentifier- the entity model identifierentityId- the entity idparentBucketId- the parent bucket idrecordGroupIdentifier- the record group identifierresultEntityId- the result entity idcontext- the contextsearchStr- the search strrange- the range- Throws:
PubServerException- the pub server exception
-
listSize
List size string.- Parameters:
list- the list- Returns:
- the string
-
failIfSizeDiffer
public static void failIfSizeDiffer(Object caller, List<?> input, List<?> output, String entityModelIdentifier, String entityId, String parentBucketId, String recordGroupIdentifier, String resultEntityId, Context context, String searchStr) throws PubServerException Fail if size differ.- Parameters:
caller- the callerinput- the inputoutput- the outputentityModelIdentifier- the entity model identifierentityId- the entity idparentBucketId- the parent bucket idrecordGroupIdentifier- the record group identifierresultEntityId- the result entity idcontext- the contextsearchStr- the search str- Throws:
PubServerException- the pub server exception
-
range
Range string.- Parameters:
range- the range- Returns:
- the string
-
all
All boolean.- Parameters:
records- the records- Returns:
- the boolean
-
getZBasedIndex
Returns index of the requested record- Parameters:
pos- requested position of the record- positive number - returns, value decremented by one e.g 1 will return index of 0
- negative number - returns element count from the end of the list, e.g -1 will return index of the last element
- 0 (zero) - returns index of the first element, the same result as 1
listSize- number of all elements in the array- Returns:
- index of the requested record
-
getMediaObjectByTypeAndMedia
Gets media object by type and media.- Parameters:
asset- the assettype- the typemedia- the media- Returns:
- the media object by type and media
-