return LazyMap.lazyMap(map, factory);
/** * Factory method to create a lazily instantiated map. * * @param <K> the key type * @param <V> the value type * @param map the map to decorate, must not be null * @param factory the factory to use, must not be null * @return a new lazy map * @throws NullPointerException if map or factory is null * @since 4.0 */ public static <V, K> LazyMap<K, V> lazyMap(final Map<K, V> map, final Transformer<? super K, ? extends V> factory) { return new LazyMap<>(map, factory); }
return LazyMap.lazyMap(map, transformerFactory);
/** * Factory method to create a lazily instantiated map. * * @param <K> the key type * @param <V> the value type * @param map the map to decorate, must not be null * @param factory the factory to use, must not be null * @return a new lazy map * @throws NullPointerException if map or factory is null * @since 4.0 */ public static <K, V> LazyMap<K, V> lazyMap(final Map<K, V> map, final Factory< ? extends V> factory) { return new LazyMap<>(map, factory); }
/** * The lazy Map creates messages objects with a fall back to the default locale. */ protected void initMap() { // LazyMap will instantiate bundles on demand. final Map map = LazyMap.lazyMap(new HashMap(), new Transformer() { // this transformer will wrap the Messages in a MessagesChain which // will fall back to a Messages instance for the same bundle with // default locale. @Override public Object transform(Object input) { final MessagesID id = (MessagesID) input; return newMessages(id); } }); messages = Collections.synchronizedMap(map); }
protected static Map<String, Object> prepareParams(Map<String, ?> parameterValues) { Map<String, Object> parameterValuesWithStats = new HashMap<>(parameterValues); BeansWrapper beansWrapper = new BeansWrapperBuilder(Configuration.DEFAULT_INCOMPATIBLE_IMPROVEMENTS).build(); parameterValuesWithStats.put("statics", beansWrapper.getStaticModels()); @SuppressWarnings("unchecked") Map<String, Object> params = LazyMap.lazyMap(parameterValuesWithStats, propertyName -> { for (String appProperty : AppContext.getPropertyNames()) { if (appProperty.replace(".", "_").equals(propertyName)) { return AppContext.getProperty(propertyName); } } return null; }); return params; } }