MCPcopy Create free account
hub / github.com/boxbeam/RedLib / getMatchingCaches

Method getMatchingCaches

src/redempt/redlib/sql/SQLHelper.java:151–169  ·  view source on GitHub ↗

Gets the caches matching a pattern @param pattern The pattern to match. Should be formatted as "tableName.primaryKeyColumnName". Use to indicate all for either tableName or columnName. Use | to indicate or. Primary key column name matches any primary key with the given column name. U

(String pattern)

Source from the content-addressed store, hash-verified

149 * @return The list of matching caches
150 */
151 public List<SQLCache> getMatchingCaches(String pattern) {
152 List<SQLCache> list = new ArrayList<>();
153 String[] split = pattern.split("\\.");
154 if (split.length != 2) {
155 throw new IllegalArgumentException("Pattern to match caches must match tableName.columnName (use * to match all of either)");
156 }
157 String[] tableName = split[0].split("\\|");
158 String[] columnName = split[1].split("\\|");
159 for (SQLCache cache : caches) {
160 if (!(tableName[0].equals("*") || Arrays.stream(tableName).anyMatch(s -> s.equals(cache.getTableName())))) {
161 continue;
162 }
163 if (!(columnName[0].equals("*") || cache.keyNamesMatch(columnName))) {
164 continue;
165 }
166 list.add(cache);
167 }
168 return list;
169 }
170
171 /**
172 * @return The list of caches for this SQLHelper

Callers 3

flushMatchingCachesMethod · 0.95

Calls 6

splitMethod · 0.80
getTableNameMethod · 0.80
keyNamesMatchMethod · 0.80
equalsMethod · 0.45
streamMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected