/** * Implementation of {@link #putValues} that calls through to {@link #putSharedValues} and {@link * #putPrivateValues}. * * @param cache instance * @param values values to put * @param filter cache select filter */ public static void putValuesBatched( final ViewComputationCache cache, final Collection<? extends ComputedValue> values, final CacheSelectHint filter) { List<ComputedValue> privateValues = null; List<ComputedValue> sharedValues = null; for (ComputedValue value : values) { if (filter.isPrivateValue(value.getSpecification())) { if (privateValues == null) { privateValues = new ArrayList<ComputedValue>(values.size()); } privateValues.add(value); } else { if (sharedValues == null) { sharedValues = new ArrayList<ComputedValue>(values.size()); } sharedValues.add(value); } } if (sharedValues != null) { if (sharedValues.size() == 1) { cache.putSharedValue(sharedValues.get(0)); } else { cache.putSharedValues(sharedValues); } } if (privateValues != null) { if (privateValues.size() == 1) { cache.putPrivateValue(privateValues.get(0)); } else { cache.putPrivateValues(privateValues); } } }
public static void putValue( final ViewComputationCache cache, final ComputedValue value, final CacheSelectHint filter) { if (filter.isPrivateValue(value.getSpecification())) { cache.putPrivateValue(value); } else { cache.putSharedValue(value); } }
/** * Implementation of {@link #putValues} that calls through to {@link #putValue}. * * @param cache instance * @param values values to put * @param filter cache select filter */ public static void putValuesDirect( final ViewComputationCache cache, final Collection<ComputedValue> values, final CacheSelectHint filter) { for (ComputedValue value : values) { cache.putValue(value, filter); } }
public static Collection<Pair<ValueSpecification, Object>> getValues( final ViewComputationCache cache, final Collection<ValueSpecification> specifications) { final Collection<Pair<ValueSpecification, Object>> values = new ArrayList<Pair<ValueSpecification, Object>>(specifications.size()); for (ValueSpecification specification : specifications) { values.add(Pair.of(specification, cache.getValue(specification))); } return values; }
public static void putPrivateValues( final ViewComputationCache cache, final Collection<? extends ComputedValue> values) { for (ComputedValue value : values) { cache.putPrivateValue(value); } }