public static <T> T safeGetValue(Supplier<T> valueSupplier) { return safeGetValue(valueSupplier, (T) null); }
public static <T> T safeGetValue(Supplier<T> valueSupplier, T defaultValue) { return safeGetValue(valueSupplier, (Supplier<T>) () -> defaultValue); }
public static <T> T safeGetValue(Supplier<T> valueSupplier) { return safeGetValue(valueSupplier, (T) null); }
public static <T> T safeGetValue(Supplier<T> valueSupplier, T defaultValue) { return safeGetValue(valueSupplier, (Supplier<T>) () -> defaultValue); }
public static <T> T safeGetValue(Supplier<T> valueSupplier, Supplier<T> defaultValueSupplier) { return safeGetValue(valueSupplier, (Function<Throwable, T>) exception -> defaultValueSupplier.get()); }
public static <T> T safeGetValue(Supplier<T> valueSupplier, Supplier<T> defaultValueSupplier) { return safeGetValue(valueSupplier, (Function<Throwable, T>) exception -> defaultValueSupplier.get()); }
@SuppressWarnings("all") private boolean eagerlyInitializePool(String poolName) { return Optional.ofNullable(PoolManager.find(poolName)) .map(it -> true) .orElseGet(() -> SpringUtils.safeGetValue(() -> getBeanFactory().getBean(poolName, Pool.class) != null, false)); }
@SuppressWarnings("all") private boolean eagerlyInitializePool(String poolName) { return Optional.ofNullable(PoolManager.find(poolName)) .map(it -> true) .orElseGet(() -> SpringUtils.safeGetValue(() -> getBeanFactory().getBean(poolName, Pool.class) != null, false)); }
/** * Safely reads the {@code pattern} attribute from the given {@link AnnotationAttributes} * and returns an empty array if the attribute is not present. * * @param filterAttributes {@link AnnotationAttributes} from which to extract the {@code pattern} attribute value. * @return a {@link String} array. */ private String[] nullSafeGetPatterns(AnnotationAttributes filterAttributes) { return SpringUtils.<String[]>safeGetValue(() -> nullSafeArray(filterAttributes.getStringArray("pattern"), String.class), () -> new String[0]); }
/** * Safely reads the {@code pattern} attribute from the given {@link AnnotationAttributes} * and returns an empty array if the attribute is not present. * * @param filterAttributes {@link AnnotationAttributes} from which to extract the {@code pattern} attribute value. * @return a {@link String} array. */ private String[] nullSafeGetPatterns(AnnotationAttributes filterAttributes) { return SpringUtils.<String[]>safeGetValue(() -> nullSafeArray(filterAttributes.getStringArray("pattern"), String.class), () -> new String[0]); }
/** * Resolves the name of the {@link LuceneIndex} required in the Lucene data access, query operations * when a {@link LuceneIndex} is not specifically provided. * * @return the name of the resolve {@link LuceneIndex}. * @throws IllegalStateException if the name of the {@link LuceneIndex} cannot be resolved. * @see org.apache.geode.cache.lucene.LuceneIndex#getName() * @see #getIndexName() * @see #getLuceneIndex() */ protected String resolveIndexName() { String resolvedIndexName = Optional.ofNullable(getIndexName()) .orElseGet(() -> safeGetValue(() -> getLuceneIndex().getName())); Assert.state(StringUtils.hasText(resolvedIndexName), "The name of the Lucene Index could not be resolved"); return resolvedIndexName; }
/** * Resolves the name of the {@link LuceneIndex} required in the Lucene data access, query operations * when a {@link LuceneIndex} is not specifically provided. * * @return the name of the resolve {@link LuceneIndex}. * @throws IllegalStateException if the name of the {@link LuceneIndex} cannot be resolved. * @see org.apache.geode.cache.lucene.LuceneIndex#getName() * @see #getIndexName() * @see #getLuceneIndex() */ protected String resolveIndexName() { String resolvedIndexName = Optional.ofNullable(getIndexName()) .orElseGet(() -> safeGetValue(() -> getLuceneIndex().getName())); Assert.state(StringUtils.hasText(resolvedIndexName), "The name of the Lucene Index could not be resolved"); return resolvedIndexName; }
/** * Resolves the fully-qualified pathname of the {@link Region} to which the Lucene data access, query operations * are performed and the {@link LuceneIndex} is applied, when a {@link String region path} * is not specifically provided. * * @return a {@link String} containing the fully-qualified pathname of the {@link Region} on which the Lucene * data access, query operations are performed and the {@link LuceneIndex} is applied. * @throws IllegalStateException if the fully-qualified pathname of the {@link Region} cannot be resolved. * @see #getRegionPath() * @see #getRegion() */ protected String resolveRegionPath() { String resolvedRegionPath = Optional.ofNullable(getRegionPath()) .orElseGet(() -> safeGetValue(() -> getRegion().getFullPath())); Assert.state(StringUtils.hasText(resolvedRegionPath), "Region path could not be resolved"); return resolvedRegionPath; }
/** * Resolves the fully-qualified pathname of the {@link Region} to which the Lucene data access, query operations * are performed and the {@link LuceneIndex} is applied, when a {@link String region path} * is not specifically provided. * * @return a {@link String} containing the fully-qualified pathname of the {@link Region} on which the Lucene * data access, query operations are performed and the {@link LuceneIndex} is applied. * @throws IllegalStateException if the fully-qualified pathname of the {@link Region} cannot be resolved. * @see #getRegionPath() * @see #getRegion() */ protected String resolveRegionPath() { String resolvedRegionPath = Optional.ofNullable(getRegionPath()) .orElseGet(() -> safeGetValue(() -> getRegion().getFullPath())); Assert.state(StringUtils.hasText(resolvedRegionPath), "Region path could not be resolved"); return resolvedRegionPath; }
/** * Resolves the {@link LuceneService} used by this {@link FactoryBean} to create the {@link LuceneIndex}. * * @return a reference to the {@link GemFireCache}, {@link LuceneService}. * @see org.springframework.beans.factory.BeanFactory#getBean(Class) * @see org.apache.geode.cache.lucene.LuceneService * @see #getBeanFactory() * @see #getLuceneService() * @see #resolveCache() * @see #resolveLuceneService(GemFireCache) */ protected LuceneService resolveLuceneService() { return Optional.ofNullable(getLuceneService()) .orElseGet(() -> Optional.ofNullable(getBeanFactory()) .map(it -> SpringUtils.safeGetValue(() -> it.getBean(LuceneService.class), (LuceneService) null)) .orElseGet(() -> resolveLuceneService(resolveCache()))); }
/** * Resolves the {@link LuceneService} used by this {@link FactoryBean} to create the {@link LuceneIndex}. * * @return a reference to the {@link GemFireCache}, {@link LuceneService}. * @see org.springframework.beans.factory.BeanFactory#getBean(Class) * @see org.apache.geode.cache.lucene.LuceneService * @see #getBeanFactory() * @see #getLuceneService() * @see #resolveCache() * @see #resolveLuceneService(GemFireCache) */ protected LuceneService resolveLuceneService() { return Optional.ofNullable(getLuceneService()) .orElseGet(() -> Optional.ofNullable(getBeanFactory()) .map(it -> SpringUtils.safeGetValue(() -> it.getBean(LuceneService.class), (LuceneService) null)) .orElseGet(() -> resolveLuceneService(resolveCache()))); }