@Override @SuppressWarnings("unchecked") public <T extends ModuleType> T get(String moduleTypeUID, Locale locale) { Entry<Provider<ModuleType>, ModuleType> mType = getValueAndProvider(moduleTypeUID); if (mType == null) { return null; } else { ModuleType mt = locale == null ? mType.getValue() : ((ModuleTypeProvider) mType.getKey()).getModuleType(mType.getValue().getUID(), locale); return (T) createCopy(mt); } }
@Override @SuppressWarnings("unchecked") public <T extends ModuleType> Collection<T> getByTags(Locale locale, String... tags) { Set<String> tagSet = tags != null ? new HashSet<String>(Arrays.asList(tags)) : null; Collection<T> result = new ArrayList<T>(20); forEach((provider, mType) -> { ModuleType mt = locale == null ? mType : ((ModuleTypeProvider) provider).getModuleType(mType.getUID(), locale); if (tagSet == null) { result.add((T) createCopy(mt)); } else if (mt.getTags().containsAll(tagSet)) { result.add((T) createCopy(mt)); } }); return result; }
@Override @SuppressWarnings("unchecked") public <T extends ModuleType> Collection<T> getByTag(String moduleTypeTag, Locale locale) { Collection<T> result = new ArrayList<T>(20); forEach((provider, mType) -> { ModuleType mt = locale == null ? mType : ((ModuleTypeProvider) provider).getModuleType(mType.getUID(), locale); Collection<String> tags = mt.getTags(); if (moduleTypeTag == null) { result.add((T) createCopy(mt)); } else if (tags.contains(moduleTypeTag)) { result.add((T) createCopy(mt)); } }); return result; }