-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add filter, sort and exists support for feature definition field
Signed-off-by: Dominik Guggemos <dominik.guggemos@bosch.io>
- Loading branch information
Showing
13 changed files
with
238 additions
and
34 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
...ery/src/main/java/org/eclipse/ditto/rql/query/expression/FeatureDefinitionExpression.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (c) 2022 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.eclipse.ditto.rql.query.expression; | ||
|
||
/** | ||
* Field expression for feature definition with a given feature id. | ||
* | ||
* @since 3.0.0 | ||
*/ | ||
public interface FeatureDefinitionExpression extends SortFieldExpression, FilterFieldExpression, ExistsFieldExpression { | ||
|
||
/** | ||
* Creates an expression for existence of a feature definition. | ||
* | ||
* @param featureId the feature id. | ||
* @return the created FeatureExpression | ||
* @throws NullPointerException if {@code featureId} is {@code null}. | ||
*/ | ||
static FeatureDefinitionExpression of(final String featureId) { | ||
return new FeatureDefinitionExpressionImpl(featureId); | ||
} | ||
|
||
/** | ||
* @return the feature id. | ||
*/ | ||
String getFeatureId(); | ||
|
||
} |
89 changes: 89 additions & 0 deletions
89
...src/main/java/org/eclipse/ditto/rql/query/expression/FeatureDefinitionExpressionImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* Copyright (c) 2017 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.eclipse.ditto.rql.query.expression; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
import java.util.Objects; | ||
|
||
import javax.annotation.concurrent.Immutable; | ||
|
||
import org.eclipse.ditto.rql.query.expression.visitors.ExistsFieldExpressionVisitor; | ||
import org.eclipse.ditto.rql.query.expression.visitors.FieldExpressionVisitor; | ||
import org.eclipse.ditto.rql.query.expression.visitors.FilterFieldExpressionVisitor; | ||
import org.eclipse.ditto.rql.query.expression.visitors.SortFieldExpressionVisitor; | ||
|
||
/** | ||
* Immutable implementation of {@link FeatureDefinitionExpression}. | ||
*/ | ||
@Immutable | ||
final class FeatureDefinitionExpressionImpl implements FeatureDefinitionExpression { | ||
|
||
private final String featureId; | ||
|
||
FeatureDefinitionExpressionImpl(final String featureId) { | ||
this.featureId = requireNonNull(featureId); | ||
} | ||
|
||
@Override | ||
public <T> T acceptExistsVisitor(final ExistsFieldExpressionVisitor<T> visitor) { | ||
return visitor.visitFeatureDefinition(featureId); | ||
} | ||
|
||
@Override | ||
public <T> T accept(final FieldExpressionVisitor<T> visitor) { | ||
return visitor.visitFeatureDefinition(featureId); | ||
} | ||
|
||
@Override | ||
public <T> T acceptFilterVisitor(final FilterFieldExpressionVisitor<T> visitor) { | ||
return visitor.visitFeatureDefinition(featureId); | ||
} | ||
|
||
@Override | ||
public <T> T acceptSortVisitor(final SortFieldExpressionVisitor<T> visitor) { | ||
return visitor.visitFeatureDefinition(featureId); | ||
} | ||
|
||
@Override | ||
public String getFeatureId() { | ||
return featureId; | ||
} | ||
|
||
@SuppressWarnings("squid:MethodCyclomaticComplexity") | ||
@Override | ||
public boolean equals(final Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
final FeatureDefinitionExpressionImpl that = (FeatureDefinitionExpressionImpl) o; | ||
return Objects.equals(featureId, that.featureId); | ||
} | ||
|
||
@SuppressWarnings("squid:S109") | ||
@Override | ||
public int hashCode() { | ||
return Objects.hash(featureId); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return getClass().getSimpleName() + " [" + | ||
"featureId=" + featureId + | ||
"]"; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.