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)
| 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 |
no test coverage detected