public OptionsServiceContextImpl(List<OptionValueSource> sources) { this.sources = sources; globalOptions = OptionsContextImpl.forGlobal(sources); entityContexts = new ConcurrentHashMap<Class<?>, OptionsContext>(); propertyContexts = new ConcurrentHashMap<PropertyKey, OptionsContext>(); }
private OptionsContext getAndCacheEntityOptions(Class<?> entityType) { OptionsContext entityOptions = OptionsContextImpl.forEntity(sources, entityType); OptionsContext cachedOptions = entityContexts.putIfAbsent(entityType, entityOptions); if (cachedOptions != null) { entityOptions = cachedOptions; } return entityOptions; }
private OptionsContext getAndCachePropertyOptions(PropertyKey key) { OptionsContext propertyOptions = OptionsContextImpl.forProperty(sources, key.getEntity(), key.getProperty()); OptionsContext cachedOptions = propertyContexts.putIfAbsent(key, propertyOptions); if (cachedOptions != null) { propertyOptions = cachedOptions; } return propertyOptions; }