/** * Constructs a new instance of {@link IndexDefinition} defined with the given {@link Index}. * * @param index {@link Index} on which this definition is defined; must not be {@literal null}. * @throws IllegalArgumentException if {@link Index} is {@literal null}. * @see org.apache.geode.cache.query.Index */ protected IndexDefinition(Index index) { super(Optional.ofNullable(index).map(Index::getName) .orElseThrow(() -> newIllegalArgumentException("Index is required"))); this.index = index; }
public IndexDefinition having(String expression) { this.expression = Optional.ofNullable(expression).filter(StringUtils::hasText) .orElseThrow(() -> newIllegalArgumentException("Expression is required")); return this; }
public IndexDefinition having(String expression) { this.expression = Optional.ofNullable(expression).filter(StringUtils::hasText) .orElseThrow(() -> newIllegalArgumentException("Expression is required")); return this; }
public IndexDefinition on(String fromClause) { this.fromClause = Optional.ofNullable(fromClause).filter(StringUtils::hasText) .orElseThrow(() -> newIllegalArgumentException("From Clause is required")); return this; }
/** * Constructs a new instance of {@link SchemaObjectDefinition} initialized with the specified {@link String name}. * * @param name {@link String name} given to the GemFire/Geode schema object; must not be {@literal null}. * @throws IllegalArgumentException if name is not specified. */ public SchemaObjectDefinition(String name) { this.name = Optional.ofNullable(name).filter(StringUtils::hasText) .orElseThrow(() -> newIllegalArgumentException("Name [%s] is required", name)); }
public IndexDefinition on(String fromClause) { this.fromClause = Optional.ofNullable(fromClause).filter(StringUtils::hasText) .orElseThrow(() -> newIllegalArgumentException("From Clause is required")); return this; }
/** * Constructs a new instance of {@link RegionDefinition} defined with the given {@link Region}. * * @param region {@link Region} on which this definition is defined; must not be {@literal null}. * @throws IllegalArgumentException if {@link Region} is {@literal null}. * @see org.apache.geode.cache.Region */ protected RegionDefinition(Region<?, ?> region) { super(Optional.ofNullable(region).map(Region::getName) .orElseThrow(() -> newIllegalArgumentException("Region is required"))); this.region = region; }
@Override public TypeFilter getFilter(String expression, ClassLoader classLoader) throws ClassNotFoundException { Class<?> filterClass = classLoader.loadClass(expression); if (!TypeFilter.class.isAssignableFrom(filterClass)) { throw newIllegalArgumentException("Class is not assignable to [%s]: %s", TypeFilter.class.getName(), expression); } return (TypeFilter) BeanUtils.instantiateClass(filterClass); } };
private ClientCache resolveCache(GemFireCache gemfireCache) { return Optional.ofNullable(gemfireCache) .filter(GemfireUtils::isClient) .map(cache -> (ClientCache) cache) .orElseThrow(() -> newIllegalArgumentException("ClientCache is required")); }
private ClientCache resolveCache(GemFireCache gemfireCache) { return Optional.ofNullable(gemfireCache) .filter(GemfireUtils::isClient) .map(cache -> (ClientCache) cache) .orElseThrow(() -> newIllegalArgumentException("ClientCache is required")); }
private Cache resolveCache(GemFireCache gemfireCache) { return Optional.ofNullable(gemfireCache) .filter(cache -> cache instanceof Cache) .map(cache -> (Cache) cache) .orElseThrow(() -> newIllegalArgumentException("Peer Cache is required")); }
private Cache resolveCache(GemFireCache gemfireCache) { return Optional.ofNullable(gemfireCache) .filter(cache -> cache instanceof Cache) .map(cache -> (Cache) cache) .orElseThrow(() -> newIllegalArgumentException("Peer Cache is required")); }
protected String getAndValidatePoolName(Map<String, Object> enablePoolAttributes) { return Optional.ofNullable((String) enablePoolAttributes.get("name")) .filter(StringUtils::hasText) .orElseThrow(() -> newIllegalArgumentException("Pool name is required")); }
String resolveIndexName() { return Optional.ofNullable(this.name).filter(StringUtils::hasText) .orElseGet(() -> Optional.ofNullable(getBeanName()).filter(StringUtils::hasText) .orElseThrow(() -> newIllegalArgumentException("Index name is required"))); }
public static VcapPropertySource from(PropertySource<?> propertySource) { return Optional.ofNullable(propertySource) .filter(it -> VCAP_PROPERTY_SOURCE_NAME.equals(it.getName())) .filter(it -> it instanceof EnumerablePropertySource) .filter(VCAP_REQUIRED_PROPERTIES_PREDICATE) .map(it -> (EnumerablePropertySource) it) .map(VcapPropertySource::new) .orElseThrow(() -> newIllegalArgumentException( "A valid EnumerablePropertySource named [%s] with VCAP properties is required", VCAP_PROPERTY_SOURCE_NAME)); }
String resolveIndexName() { return Optional.ofNullable(this.name).filter(StringUtils::hasText) .orElseGet(() -> Optional.ofNullable(getBeanName()).filter(StringUtils::hasText) .orElseThrow(() -> newIllegalArgumentException("Index name is required"))); }
private static Object constructInstance(Class<?> type, Object... constructorArguments) { return org.springframework.data.util.ReflectionUtils.findConstructor(type, constructorArguments) .map(constructor -> BeanUtils.instantiateClass(constructor, constructorArguments)) .orElseThrow(() -> newIllegalArgumentException( "No suitable constructor was found for type [%s] having parameters [%s]", type.getName(), stream(nullSafeArray(constructorArguments, Object.class)) .map(ObjectUtils::nullSafeClassName) .collect(Collectors.toList()))); }
public static Component valueOfName(String name) { return Arrays.stream(values()) .filter(component -> component.name().equalsIgnoreCase(String.valueOf(name).trim())) .findFirst() .orElseThrow(() -> newIllegalArgumentException("Name [%s] is not a valid component", name)); }
@SuppressWarnings("all") protected int resolveEnableTransactionManagementOrder(AnnotationMetadata importMetadata) { AnnotationAttributes enableTransactionManagementAttributes = resolveEnableTransactionManagementAttributes(importMetadata); Integer order = enableTransactionManagementAttributes.getNumber("order"); return Optional.ofNullable(order) .filter(it -> !(it == Integer.MAX_VALUE || it == Integer.MIN_VALUE)) .orElseThrow(() -> newIllegalArgumentException( "The @%1$s(order) attribute value [%2$s] must be explicitly set to a value" + " other than Integer.MAX_VALUE or Integer.MIN_VALUE", EnableTransactionManagement.class.getSimpleName(), String.valueOf(order))); }
private static @NonNull String findByMethodName(@NonNull Class<?> type, @NonNull String methodName) { return Arrays.stream(type.getDeclaredMethods()) .map(Method::getName) .filter(declaredMethodName -> declaredMethodName.startsWith(methodName)) .findFirst() .orElseThrow(() -> newIllegalArgumentException("No method with name [%1$s] was found on class [%2$s]", methodName, type.getName())); }