Class SubjectApiUtils
java.lang.Object
edu.internet2.middleware.subject.util.SubjectApiUtils
utility methods for subject api
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> List<T>
retrieve a batch by 0 index.static int
batchNumberOfBatches
(int count, int batchSize) Deprecated.use batchNumberOfBatches(Collection<?> collection, int batchSize, boolean haveAtLeastOne)static int
batchNumberOfBatches
(int count, int batchSize, boolean haveAtLeastOne) If batching this is the number of batchesstatic int
batchNumberOfBatches
(Collection<?> collection, int batchSize) Deprecated.use batchNumberOfBatches(Collection<?> collection, int batchSize, boolean haveAtLeastOne)static int
batchNumberOfBatches
(Collection<?> collection, int batchSize, boolean haveAtLeastOne) If batching this is the number of batches, will return at least 1static String
convertToInClauseForSqlStatic
(Collection<String> collection) convert a collection of strings (no parens) to an in clausestatic String
convertUrlToDriverClassIfNeeded
(String connectionUrl, String driverClassName) if there is no driver class specified, then try to derive it from the URLstatic boolean
see if the config file seems to be hsqlstatic boolean
see if the config file seems to be mysqlstatic boolean
see if the config file seems to be oraclestatic boolean
isPostgres
(String connectionUrl) see if the config file seems to be postgresstatic boolean
isSQLServer
(String connectionUrl) see if the config file seems to be sql serverstatic int
Null safe array length or mapstatic <T> Collection<T>
nonNull
(Collection<T> list) make sure a collection is non null.static <T> List<T>
make sure a list is non null.static <K,
V> Map<K, V> make sure it is non null, if null, then give new mapstatic <T> Set<T>
make sure a list is non null.static <T> T[]
make sure a array is non null.static String
subjectToString
(Subject subject) convert a subject to string safelystatic <T> Set<T>
toSet
(T... objects) return a set of objects from varargs.
-
Constructor Details
-
SubjectApiUtils
public SubjectApiUtils()
-
-
Method Details
-
subjectToString
convert a subject to string safely- Parameters:
subject
-- Returns:
- the string value of subject (might be null)
-
length
Null safe array length or map- Parameters:
arrayOrCollection
-- Returns:
- the length of the array (0 for null)
-
toSet
return a set of objects from varargs.- Type Parameters:
T
- template type of the objects- Parameters:
objects
-- Returns:
- the set
-
convertUrlToDriverClassIfNeeded
if there is no driver class specified, then try to derive it from the URL- Parameters:
connectionUrl
-driverClassName
-- Returns:
- the driver class
-
isHsql
see if the config file seems to be hsql- Parameters:
connectionUrl
- url to check against- Returns:
- see if hsql
-
isMysql
see if the config file seems to be mysql- Parameters:
connectionUrl
-- Returns:
- see if mysql
-
isOracle
see if the config file seems to be oracle- Parameters:
connectionUrl
-- Returns:
- see if oracle
-
isPostgres
see if the config file seems to be postgres- Parameters:
connectionUrl
-- Returns:
- see if postgres
-
isSQLServer
see if the config file seems to be sql server- Parameters:
connectionUrl
-- Returns:
- see if sql server
-
batchList
retrieve a batch by 0 index. Will return an array of size batchSize or the remainder. the array will be full of elements. Note, this requires an ordered input (so use linkedhashset not hashset if doing sets)- Type Parameters:
T
- template type- Parameters:
collection
-batchSize
-batchIndex
-- Returns:
- the list This never returns null, only empty list
-
batchNumberOfBatches
public static int batchNumberOfBatches(int count, int batchSize, boolean haveAtLeastOne) If batching this is the number of batches- Parameters:
count
- is size of setbatchSize
-haveAtLeastOne
- is true if there should be at least one run even if the collection is empty (e.g. for queries based on other things)- Returns:
- the number of batches
-
batchNumberOfBatches
Deprecated.use batchNumberOfBatches(Collection<?> collection, int batchSize, boolean haveAtLeastOne)If batching this is the number of batches. Will return at least 1- Parameters:
count
- is size of setbatchSize
-- Returns:
- the number of batches
-
batchNumberOfBatches
Deprecated.use batchNumberOfBatches(Collection<?> collection, int batchSize, boolean haveAtLeastOne)If batching this is the number of batches, will return at least 1- Parameters:
collection
-batchSize
-- Returns:
- the number of batches
-
batchNumberOfBatches
public static int batchNumberOfBatches(Collection<?> collection, int batchSize, boolean haveAtLeastOne) If batching this is the number of batches, will return at least 1- Parameters:
collection
-batchSize
-haveAtLeastOne
- is true if there should be at least one run even if the collection is empty (e.g. for queries based on other things)- Returns:
- the number of batches
-
convertToInClauseForSqlStatic
convert a collection of strings (no parens) to an in clause- Parameters:
collection
-- Returns:
- the string of in clause (without parens)
-
nonNull
make sure a collection is non null. If null, then return an empty list- Type Parameters:
T
-- Parameters:
list
-- Returns:
- the list or empty list if null
-
nonNull
make sure a list is non null. If null, then return an empty list- Type Parameters:
T
-- Parameters:
list
-- Returns:
- the list or empty list if null
-
nonNull
make sure it is non null, if null, then give new map- Type Parameters:
K
- key of mapV
- value of map- Parameters:
map
- is map- Returns:
- set non null
-
nonNull
make sure a list is non null. If null, then return an empty set- Type Parameters:
T
-- Parameters:
set
-- Returns:
- the set or empty set if null
-
nonNull
make sure a array is non null. If null, then return an empty array.- Type Parameters:
T
-- Parameters:
array
-theClass
- to make array from- Returns:
- the list or empty list if null
-