public void path() { // tag::path[] Path<String> stringPath = Path.of("pathName", String.class); // <1> String name = stringPath.getName(); // <2> boolean root = stringPath.isRootPath(); // <3> Path<String> hierarchicalPath = Path.of("subName", String.class).parent(stringPath); // <4> String fullName = hierarchicalPath.fullName(); // <5> // end::path[] }
/** * Constructor. * @param expression Filter expression (not null) * @param from Minimum value * @param to Maximum value */ public BetweenFilter(TypedExpression<T> expression, T from, T to) { super(expression, FilterOperator.BETWEEN, CollectionConstantExpression.create(expression, from, to)); }
/** * Build a validator that checks that a value is less than or equal to given <code>compareTo</code> value, and uses * default {@link ValidationMessage#LESS_OR_EQUAL} message as validation error message. Supported data types: * {@link Comparable}. * @param <T> Value and validator type * @param compareTo Value to compare * @return Validator */ static <T extends Comparable<T>> Validator<T> lessOrEqual(T compareTo) { return lessOrEqual(compareTo, ValidationMessage.LESS_OR_EQUAL); }
/** * Convenience method to obtain the current {@link LocalizationContext} made available as {@link Context} resource, * using default {@link ClassLoader}. * <p> * See {@link Context#resource(String, Class)} for details about context resources availability conditions. * </p> * @return Optional LocalizationContext, empty if not available as context resource */ static Optional<LocalizationContext> getCurrent() { return Context.get().resource(CONTEXT_KEY, LocalizationContext.class); }
/** * Gets the <em>relative</em> path name, separated by a dot <code>.</code> character, i.e. exclude any * {@link FinalPath} path instance from path name composition. * @return Path relative name, en empty String if this Path is a {@link FinalPath} itself. */ default String relativeName() { return relativeName(p -> p.getName()); }
@Override public void validate() throws InvalidExpressionException { if (value == null) { throw new InvalidExpressionException("Kay value must be not null"); } }
/** * Set given <code>path</code> to given constant value. * @param <T> Path type * @param path Path to be updated (not null) * @param value value to set * @return this * @see #setNull(Path) */ default <T> O set(Path<T> path, T value) { return set(path, (value == null) ? NullExpression.create(path) : ConstantConverterExpression.create(path, value)); }
@SuppressWarnings("rawtypes") @Override public Iterable<ExpressionResolver> getExpressionResolvers() { return expressionResolverRegistry.getExpressionResolvers(); }
@Override public <E extends Expression, R extends Expression> Optional<R> resolve(E expression, Class<R> resolutionType, ResolutionContext context) throws InvalidExpressionException { return expressionResolverRegistry.resolve(expression, resolutionType, context); }
@Override public <E extends Expression, R extends Expression> void addExpressionResolver( ExpressionResolver<E, R> expressionResolver) { expressionResolverRegistry.addExpressionResolver(expressionResolver); }
@Override public <E extends Expression, R extends Expression> void removeExpressionResolver( ExpressionResolver<E, R> expressionResolver) { expressionResolverRegistry.removeExpressionResolver(expressionResolver); }
/** * Build a validator that checks that the value is a valid e-mail address using RFC822 format rules, and uses * default {@link ValidationMessage#EMAIL} message as validation error message. * <p> * Supported data types: {@link CharSequence} * </p> * @param <T> Value and validator type * @return Validator */ static <T extends CharSequence> Validator<T> email() { return email(ValidationMessage.EMAIL); }
/** * Create a new {@link ExpressionResolverRegistry}. * @return A new {@link ExpressionResolverRegistry} instance */ static ExpressionResolverRegistry create() { return create(true); }
/** * Build a validator that checks that given {@link Number} value is not negative, using default * {@link ValidationMessage#NOT_NEGATIVE} message as validation error message. * <p> * Supported data types: {@link Number} * </p> * @param <T> Validator type * @return Validator */ static <T extends Number> Validator<T> notNegative() { return notNegative(ValidationMessage.NOT_NEGATIVE); }
/** * Build a validator that checks that given {@link Number} value is not <code>0</code>, using default * {@link ValidationMessage#NOT_ZERO} message as validation error message. * <p> * Supported data types: {@link Number} * </p> * @param <T> Validator type * @return Validator */ static <T extends Number> Validator<T> notZero() { return notZero(ValidationMessage.NOT_ZERO); }
@Override public void validate() throws InvalidExpressionException { // <2> if (expression == null) { throw new InvalidExpressionException("Null function expression"); } }
@SuppressWarnings("rawtypes") @Override public Iterable<ExpressionResolver> getExpressionResolvers() { return expressionResolverRegistry.getExpressionResolvers(); }
@Override public void validate() throws InvalidExpressionException { // <4> if (nullableValue == null) { throw new InvalidExpressionException("Missing nullable expression"); } if (fallbackValue == null) { throw new InvalidExpressionException("Missing fallback expression"); } }