private String firstMatching(String type, Properties required, AppResources appResources) { List<String> resourceIds = getResourceIds(appResources, type, required); String idd = null; if (resourceIds.size() > 0) { idd = resourceIds.get(0); } return idd; }
private String firstMatching(final String prefix, final String type, final Properties required, final AppResources appResources) { final List<String> resourceIds = getResourceIds(appResources, type, required); if(resourceIds.isEmpty()){ return null; } return Collections.min(resourceIds, new Comparator<String>() { // sort from webapp to global resources @Override public int compare(final String o1, final String o2) { // don't change global order, just put app scoped resource before others if (o1.startsWith(prefix) && o2.startsWith(prefix)) { return resourceIds.indexOf(o1) - resourceIds.indexOf(o2); } else if (o1.startsWith(prefix)) { return -1; } else if (o2.startsWith(prefix)) { return 1; } // make it stable with prefixed comparison + keep existing ordering (bck compat) return resourceIds.indexOf(o1) - resourceIds.indexOf(o2); } }); }
private String findResourceId(final String resourceId, final String type, final Properties required, final AppResources appResources) { if (resourceId == null) { return null; } return findResourceId(getResourceIds(appResources, type, required), resourceId); }
private String findResourceId(final String resourceId, final String type, final Properties required, final AppResources appResources) { if (resourceId == null) { return null; } return findResourceId(getResourceIds(appResources, type, required), resourceId); }
private String firstMatching(final String prefix, final String type, final Properties required, final AppResources appResources) { final List<String> resourceIds = new ArrayList<String>(getResourceIds(appResources, type, required)); Collections.sort(resourceIds, new Comparator<String>() { // sort from webapp to global resources @Override public int compare(final String o1, final String o2) { // don't change global order, just put app scoped resource before others if (o1.startsWith(prefix) && o2.startsWith(prefix)) { return resourceIds.indexOf(o1) - resourceIds.indexOf(o2); } else if (o1.startsWith(prefix)) { return -1; } else if (o2.startsWith(prefix)) { return 1; } // make it stable with prefixed comparison + keep existing ordering (bck compat) return resourceIds.indexOf(o1) - resourceIds.indexOf(o2); } }); String idd = null; if (resourceIds.size() > 0) { idd = resourceIds.get(0); } return idd; }
private String findResourceId(String resourceId, String type, Properties required, AppResources appResources) { if (resourceId == null) return null; resourceId = normalizeResourceId(resourceId); // check for existing resource with specified resourceId List<String> resourceIds = getResourceIds(appResources, type, required); for (String id : resourceIds) { if (id.equalsIgnoreCase(resourceId)) return id; } // check for existing resource with shortName String shortName = toShortName(resourceId); for (String id : resourceIds) { if (id.equalsIgnoreCase(shortName)) return id; } return null; }
List<String> resourceEnvIds = getResourceIds(appResources, type, null); for (String id : resourceEnvIds) { if (id.equalsIgnoreCase(resourceId)) return id;
final List<String> resourceEnvIds = getResourceIds(appResources, type, null); for (final String id : resourceEnvIds) { if (id.equalsIgnoreCase(resourceId)) {
final List<String> resourceEnvIds = getResourceIds(appResources, type, null); for (final String id : resourceEnvIds) { if (id.equalsIgnoreCase(resourceId)) {