@Override public ExistsFieldExpression existsByFeatureId(final String featureId) { return new FeatureExpressionImpl(featureId); }
@Override public ExistsFieldExpression existsBy(final String propertyName) throws IllegalArgumentException { return FieldExpressionUtil.parseFeatureField(requireNonNull(propertyName)) .map(f -> f.getFeatureId() .map(id -> f.getProperty() // we have a feature id and a property path .map(property -> (ExistsFieldExpression) new FeatureIdPropertyExpressionImpl(id, property)) // we have a feature id but no property path .orElseGet(() -> new FeatureExpressionImpl(id)) ) // we have a feature field but no feature id, means it must be a property path .orElseGet(() -> (ExistsFieldExpression) f.getProperty() .map((String property) -> (ExistsFieldExpression) new FeaturePropertyExpressionImpl( property)) // at this point, we know that there must be a property, so the following throw should // never happen and is only there to make the compiler happy: .orElseThrow(() -> new IllegalStateException("Illegal state while parsing feature property path.")) ) ) // we have no feature at all, continue with the other possibilities .orElseGet(() -> (ExistsFieldExpression) common(propertyName)); }