Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
8be9639
Clarify doc
dmitrykuzmin Jan 3, 2020
766d8e1
Fix a typo
dmitrykuzmin Jan 3, 2020
22203d6
Add usage of `EntityColumn` and `SubscribableField` to `Filters` tool
dmitrykuzmin Jan 3, 2020
fda46d8
Introduce stricter typing for `where(...)`
dmitrykuzmin Jan 8, 2020
112ca00
Fix the `Filters` test
dmitrykuzmin Jan 8, 2020
e7836e6
Migrate to new `SubscribableField`
dmitrykuzmin Jan 13, 2020
cd26df2
Merge branch 'master' of https://github.com/SpineEventEngine/core-jav…
dmitrykuzmin Jan 13, 2020
6aac0b9
Merge branch 'master' of https://github.com/SpineEventEngine/core-jav…
dmitrykuzmin Jan 17, 2020
a304380
Migrate to the latest generated fields format from `base`
dmitrykuzmin Jan 19, 2020
58d5b71
Introduce the typed filter hierarchy to distinguish targeted fields
dmitrykuzmin Jan 22, 2020
b4da058
Reword doc
dmitrykuzmin Jan 23, 2020
b616685
Static import a utility method
dmitrykuzmin Jan 23, 2020
87b163f
Improve formatting
dmitrykuzmin Jan 23, 2020
783ac4a
Static import methods
dmitrykuzmin Jan 23, 2020
d8c69cc
Update the format of filtering by context in tests
dmitrykuzmin Jan 23, 2020
73b320c
Add todos about updating doc
dmitrykuzmin Jan 23, 2020
15131c3
Extract common filter traits to the abstract base classes
dmitrykuzmin Jan 23, 2020
14e6922
Deprecate the old `where` methods and get rid of their usages
dmitrykuzmin Jan 23, 2020
79efd55
Add tests for strongly-typed filter creation
dmitrykuzmin Jan 23, 2020
f9a9646
Rename `FilterHolder` -> `TypedFilter`
dmitrykuzmin Jan 24, 2020
6f44181
Add a missing filter creation method
dmitrykuzmin Jan 24, 2020
5fac0e7
Migrate to the latest packaging changes from `base`
dmitrykuzmin Jan 28, 2020
502e689
Merge branch 'master' of https://github.com/SpineEventEngine/core-jav…
dmitrykuzmin Jan 28, 2020
d4998d9
Fix method ordering
dmitrykuzmin Jan 28, 2020
02daeca
Rename `CompositeFilterHolder` -> `TypedCompositeFilter`
dmitrykuzmin Jan 28, 2020
97fc8d4
Move filter creation methods to corresponding filter types
dmitrykuzmin Jan 28, 2020
3271ad5
Cover typed filters and their creation methods with doc
dmitrykuzmin Jan 28, 2020
7ed5135
Cover composite filters with doc
dmitrykuzmin Jan 28, 2020
c16384a
Add clarification doc to the constructor
dmitrykuzmin Jan 28, 2020
54098af
Improve typed filter tests and move them to the respective test types
dmitrykuzmin Jan 28, 2020
c052bce
Reformat doc
dmitrykuzmin Jan 28, 2020
26aca4d
Remove a redundant test case which is already checked
dmitrykuzmin Jan 28, 2020
8422fd5
Enable generated columns usage in `QueryRequest.orderBy(...)`
dmitrykuzmin Jan 28, 2020
93f9eb6
Update outdated doc
dmitrykuzmin Jan 28, 2020
f980f07
Reword doc
dmitrykuzmin Jan 28, 2020
89b1e4d
Fix old API usage in the doc
dmitrykuzmin Jan 28, 2020
bab9e0e
Fix a compilation error in test
dmitrykuzmin Jan 28, 2020
b4f0c5e
Remove redundant configurations of a `NullPointerTester` instance
dmitrykuzmin Jan 28, 2020
91e1c51
Add doc to the new `where(...)` methods
dmitrykuzmin Jan 28, 2020
fd0eed4
Bump Spine version, update `base` and `time` dependencies
dmitrykuzmin Jan 28, 2020
0db238b
Reword doc in `filters.proto`
dmitrykuzmin Jan 28, 2020
4009682
Fix a string literal duplication
dmitrykuzmin Jan 28, 2020
6ca1f9b
Migrate to the new field and column generation config format
dmitrykuzmin Feb 6, 2020
5cf3f3e
Migrate to singular names of generated column/field containers
dmitrykuzmin Feb 7, 2020
a6e9c48
Reword deprecation doc
dmitrykuzmin Feb 8, 2020
40a0fbd
Fix the outdated generated type names in doc
dmitrykuzmin Feb 8, 2020
6018744
Add doc to `EventContextField`
dmitrykuzmin Feb 8, 2020
648779b
Document the additional field generation configurations
dmitrykuzmin Feb 8, 2020
81b9d52
Merge branch 'master' of https://github.com/SpineEventEngine/core-jav…
dmitrykuzmin Feb 8, 2020
efa7fe8
Reword doc
dmitrykuzmin Feb 8, 2020
a589a63
Reword doc
dmitrykuzmin Feb 8, 2020
8542b51
Weaken the param type
dmitrykuzmin Feb 8, 2020
a6352a4
Document a test message type
dmitrykuzmin Feb 8, 2020
8953980
Reword doc
dmitrykuzmin Feb 8, 2020
2f0339a
Reword doc
dmitrykuzmin Feb 8, 2020
894b54e
Update Spine base version to `1.4.5`
dmitrykuzmin Feb 8, 2020
2ff7414
Update to the latest `config`
dmitrykuzmin Feb 14, 2020
7c12e52
Merge remote-tracking branch 'origin/strongly-typed-columns' into str…
dmitrykuzmin Feb 14, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Copyright 2020, TeamDev. All rights reserved.
*
* Redistribution and use in source and/or binary forms, with or without
* modification, must retain the above copyright notice and the following
* disclaimer.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

package io.spine.client;

import io.spine.base.EntityState;
import io.spine.client.CompositeFilter.CompositeOperator;

import java.util.Collection;

import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.Lists.asList;
import static io.spine.client.CompositeFilter.CompositeOperator.ALL;
import static io.spine.client.CompositeFilter.CompositeOperator.EITHER;

/**
* A subscription filter which aggregates one or more {@link EntityState} filters.
*/
public final class CompositeEntityStateFilter extends TypedCompositeFilter<EntityState> {

private static final long serialVersionUID = 0L;

private CompositeEntityStateFilter(Collection<EntityStateFilter> filters,
CompositeOperator operator) {
super(filters, operator);
}

/**
* Creates a new conjunction composite filter.
*
* <p>A record is considered matching this filter if and only if it matches all of the
* passed filters.
*/
public static CompositeEntityStateFilter
all(EntityStateFilter first, EntityStateFilter... rest) {
checkNotNull(first);
checkNotNull(rest);
return new CompositeEntityStateFilter(asList(first, rest), ALL);
}

/**
* Creates a new disjunction composite filter.
*
* <p>A record is considered matching this filter if it matches at least one of the passed
* filters.
*/
public static CompositeEntityStateFilter
either(EntityStateFilter first, EntityStateFilter... rest) {
checkNotNull(first);
checkNotNull(rest);
return new CompositeEntityStateFilter(asList(first, rest), EITHER);
}

}
70 changes: 33 additions & 37 deletions client/src/main/java/io/spine/client/CompositeEventFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,57 +20,53 @@

package io.spine.client;

import com.google.common.collect.ImmutableList;
import io.spine.client.CompositeFilter.CompositeOperator;
import io.spine.core.Event;

import java.util.List;
import java.util.Collection;

import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.ImmutableList.toImmutableList;
import static com.google.common.collect.Lists.asList;
import static io.spine.client.CompositeFilter.CompositeOperator.ALL;
import static io.spine.client.CompositeFilter.CompositeOperator.EITHER;

/**
* Filters events by composite criteria which can test both event messages and their contexts.
* A composite subscription filter which can aggregate both event message and event context
* filters.
*/
final class CompositeEventFilter implements CompositeMessageFilter<Event> {
public final class CompositeEventFilter extends TypedCompositeFilter<Event> {

/** The filter data as composed when creating a topic. */
private final CompositeFilter filter;
/** Filters adopted to filter events basing on the passed filter data. */
private final ImmutableList<MessageFilter<Event>> filters;
private static final long serialVersionUID = 0L;

CompositeEventFilter(CompositeFilter filter) {
this.filter = checkNotNull(filter);
this.filters =
filter.getFilterList()
.stream()
.map(EventFilter::new)
.collect(toImmutableList());
}

@Override
public List<MessageFilter<Event>> filters() {
return filters;
private CompositeEventFilter(Collection<EventFilter> filters, CompositeOperator operator) {
super(filters, operator);
}

@Override
public CompositeFilter.CompositeOperator operator() {
return filter.operator();
CompositeEventFilter(CompositeFilter filter) {
super(checkNotNull(filter), EventFilter::new);
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
CompositeEventFilter other = (CompositeEventFilter) o;
return filter.equals(other.filter);
/**
* Creates a new conjunction composite filter.
*
* <p>A record is considered matching this filter if and only if it matches all of the passed
* filters.
*/
public static CompositeEventFilter all(EventFilter first, EventFilter... rest) {
checkNotNull(first);
checkNotNull(rest);
return new CompositeEventFilter(asList(first, rest), ALL);
}

@Override
public int hashCode() {
return filter.hashCode();
/**
* Creates a new disjunction composite filter.
*
* <p>A record is considered matching this filter if it matches at least one of the passed
* filters.
*/
public static CompositeEventFilter either(EventFilter first, EventFilter... rest) {
checkNotNull(first);
checkNotNull(rest);
return new CompositeEventFilter(asList(first, rest), EITHER);
}
}
68 changes: 68 additions & 0 deletions client/src/main/java/io/spine/client/CompositeQueryFilter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Copyright 2020, TeamDev. All rights reserved.
*
* Redistribution and use in source and/or binary forms, with or without
* modification, must retain the above copyright notice and the following
* disclaimer.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

package io.spine.client;

import io.spine.base.EntityState;
import io.spine.client.CompositeFilter.CompositeOperator;

import java.util.Collection;

import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.Lists.asList;
import static io.spine.client.CompositeFilter.CompositeOperator.ALL;
import static io.spine.client.CompositeFilter.CompositeOperator.EITHER;

/**
* A composite query filter which targets one or more entity
* {@link io.spine.base.EntityColumn columns}.
*/
public final class CompositeQueryFilter extends TypedCompositeFilter<EntityState> {

private static final long serialVersionUID = 0L;

private CompositeQueryFilter(Collection<QueryFilter> filters, CompositeOperator operator) {
super(filters, operator);
}

/**
* Creates a new conjunction composite filter.
*
* <p>A record is considered matching this filter if and only if it matches all of the
* passed filters.
*/
public static CompositeQueryFilter all(QueryFilter first, QueryFilter... rest) {
checkNotNull(first);
checkNotNull(rest);
return new CompositeQueryFilter(asList(first, rest), ALL);
}

/**
* Creates a new disjunction composite filter.
*
* <p>A record is considered matching this filter if it matches at least one of the passed
* filters.
*/
public static CompositeQueryFilter either(QueryFilter first, QueryFilter... rest) {
checkNotNull(first);
checkNotNull(rest);
return new CompositeQueryFilter(asList(first, rest), EITHER);
}
}
132 changes: 132 additions & 0 deletions client/src/main/java/io/spine/client/EntityStateFilter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/*
* Copyright 2020, TeamDev. All rights reserved.
*
* Redistribution and use in source and/or binary forms, with or without
* modification, must retain the above copyright notice and the following
* disclaimer.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

package io.spine.client;

import io.spine.base.EntityState;
import io.spine.base.EntityStateField;
import io.spine.client.Filter.Operator;

import static com.google.common.base.Preconditions.checkNotNull;
import static io.spine.client.Filter.Operator.EQUAL;
import static io.spine.client.Filter.Operator.GREATER_OR_EQUAL;
import static io.spine.client.Filter.Operator.GREATER_THAN;
import static io.spine.client.Filter.Operator.LESS_OR_EQUAL;
import static io.spine.client.Filter.Operator.LESS_THAN;
import static io.spine.client.Filters.checkSupportedOrderingComparisonType;
import static io.spine.client.Filters.createFilter;

/**
* A subscription filter which targets an {@link EntityState}.
*/
public final class EntityStateFilter extends TypedFilter<EntityState> {

private static final long serialVersionUID = 0L;

private EntityStateFilter(EntityStateField field, Object expected, Operator operator) {
super(createFilter(field.getField(), expected, operator));
}

/**
* Creates a new equality filter.
*
* @param field
* the message field from which the actual value is taken
* @param value
* the expected value
*/
public static EntityStateFilter eq(EntityStateField field, Object value) {
checkNotNull(field);
checkNotNull(value);
return new EntityStateFilter(field, value, EQUAL);
}

/**
* Creates a new "greater than" filter.
*
* <p>NOTE: not all value types are supported for ordering comparison. See {@link Filters} for
* details.
*
* @param field
* the message field from which the actual value is taken
* @param value
* the expected value
*/
public static EntityStateFilter gt(EntityStateField field, Object value) {
checkNotNull(field);
checkNotNull(value);
checkSupportedOrderingComparisonType(value.getClass());
return new EntityStateFilter(field, value, GREATER_THAN);
}

/**
* Creates a new "less than" filter.
*
* <p>NOTE: not all value types are supported for ordering comparison. See {@link Filters} for
* details.
*
* @param field
* the message field from which the actual value is taken
* @param value
* the expected value
*/
public static EntityStateFilter lt(EntityStateField field, Object value) {
checkNotNull(field);
checkNotNull(value);
checkSupportedOrderingComparisonType(value.getClass());
return new EntityStateFilter(field, value, LESS_THAN);
}

/**
* Creates a new "greater than or equals" filter.
*
* <p>NOTE: not all value types are supported for ordering comparison. See {@link Filters} for
* details.
*
* @param field
* the message field from which the actual value is taken
* @param value
* the expected value
*/
public static EntityStateFilter ge(EntityStateField field, Object value) {
checkNotNull(field);
checkNotNull(value);
checkSupportedOrderingComparisonType(value.getClass());
return new EntityStateFilter(field, value, GREATER_OR_EQUAL);
}

/**
* Creates a new "less than or equals" filter.
*
* <p>NOTE: not all value types are supported for ordering comparison. See {@link Filters} for
* details.
*
* @param field
* the message field from which the actual value is taken
* @param value
* the expected value
*/
public static EntityStateFilter le(EntityStateField field, Object value) {
checkNotNull(field);
checkNotNull(value);
checkSupportedOrderingComparisonType(value.getClass());
return new EntityStateFilter(field, value, LESS_OR_EQUAL);
}
}
Loading