Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify unicast event routing #1317

Merged
merged 13 commits into from
Oct 26, 2020
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ the [Spine Examples][spine-examples] GitHub organization.

Building Spine modules and libraries requires JDK 8.

The support of JDK 11 is planned for the [version 2.0.0][v2] of the framework.
The support of JDK 11 is planned for the [version 3.0][v3] of the framework.

Gradle is used as a build and dependency management system.

Expand Down Expand Up @@ -64,5 +64,5 @@ If you need to use API with one of these annotations, please [contact us][email-
[quick-start]: https://spine.io/docs/quick-start
[spine-examples]: https://github.com/spine-examples
[todo-list]: https://github.com/spine-examples/todo-list
[v2]: https://github.com/orgs/SpineEventEngine/projects/11
[v3]: https://github.com/orgs/SpineEventEngine/projects/11
[config]: https://github.com/SpineEventEngine/config/
17 changes: 0 additions & 17 deletions core/src/test/java/io/spine/change/IntMismatchTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

package io.spine.change;

import com.google.common.testing.NullPointerTester;
import io.spine.testing.UtilityClassTest;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
Expand All @@ -33,9 +32,6 @@
import static io.spine.change.IntMismatch.unpackActual;
import static io.spine.change.IntMismatch.unpackExpected;
import static io.spine.change.IntMismatch.unpackNewValue;
import static io.spine.testing.DisplayNames.HAVE_PARAMETERLESS_CTOR;
import static io.spine.testing.DisplayNames.NOT_ACCEPT_NULLS;
import static io.spine.testing.Tests.assertHasPrivateParameterlessCtor;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

Expand All @@ -51,19 +47,6 @@ class IntMismatchTest extends UtilityClassTest<IntMismatch> {
super(IntMismatch.class);
}

@Test
@DisplayName(HAVE_PARAMETERLESS_CTOR)
void haveUtilityConstructor() {
assertHasPrivateParameterlessCtor(IntMismatch.class);
}

@Test
@DisplayName(NOT_ACCEPT_NULLS)
void passNullToleranceCheck() {
new NullPointerTester()
.testAllPublicStaticMethods(IntMismatch.class);
}

@Nested
@DisplayName("create ValueMismatch instance")
class Create {
Expand Down
32 changes: 16 additions & 16 deletions license-report.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


# Dependencies of `io.spine:spine-client:1.6.5`
# Dependencies of `io.spine:spine-client:1.6.6`

## Runtime
1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4
Expand Down Expand Up @@ -406,12 +406,12 @@
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Thu Oct 22 19:37:44 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
This report was generated on **Mon Oct 26 20:11:39 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine:spine-core:1.6.5`
# Dependencies of `io.spine:spine-core:1.6.6`

## Runtime
1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2
Expand Down Expand Up @@ -777,12 +777,12 @@ This report was generated on **Thu Oct 22 19:37:44 EEST 2020** using [Gradle-Lic
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Thu Oct 22 19:37:45 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
This report was generated on **Mon Oct 26 20:11:40 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine.tools:spine-model-assembler:1.6.5`
# Dependencies of `io.spine.tools:spine-model-assembler:1.6.6`

## Runtime
1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4
Expand Down Expand Up @@ -1183,12 +1183,12 @@ This report was generated on **Thu Oct 22 19:37:45 EEST 2020** using [Gradle-Lic
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Thu Oct 22 19:37:46 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
This report was generated on **Mon Oct 26 20:11:40 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine.tools:spine-model-verifier:1.6.5`
# Dependencies of `io.spine.tools:spine-model-verifier:1.6.6`

## Runtime
1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4
Expand Down Expand Up @@ -1659,12 +1659,12 @@ This report was generated on **Thu Oct 22 19:37:46 EEST 2020** using [Gradle-Lic
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Thu Oct 22 19:37:46 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
This report was generated on **Mon Oct 26 20:11:41 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine:spine-server:1.6.5`
# Dependencies of `io.spine:spine-server:1.6.6`

## Runtime
1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4
Expand Down Expand Up @@ -2082,12 +2082,12 @@ This report was generated on **Thu Oct 22 19:37:46 EEST 2020** using [Gradle-Lic
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Thu Oct 22 19:37:47 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
This report was generated on **Mon Oct 26 20:11:41 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine:spine-testutil-client:1.6.5`
# Dependencies of `io.spine:spine-testutil-client:1.6.6`

## Runtime
1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4
Expand Down Expand Up @@ -2542,12 +2542,12 @@ This report was generated on **Thu Oct 22 19:37:47 EEST 2020** using [Gradle-Lic
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Thu Oct 22 19:37:49 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
This report was generated on **Mon Oct 26 20:11:43 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine:spine-testutil-core:1.6.5`
# Dependencies of `io.spine:spine-testutil-core:1.6.6`

## Runtime
1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4
Expand Down Expand Up @@ -3010,12 +3010,12 @@ This report was generated on **Thu Oct 22 19:37:49 EEST 2020** using [Gradle-Lic
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Thu Oct 22 19:37:51 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
This report was generated on **Mon Oct 26 20:11:44 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine:spine-testutil-server:1.6.5`
# Dependencies of `io.spine:spine-testutil-server:1.6.6`

## Runtime
1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4
Expand Down Expand Up @@ -3514,4 +3514,4 @@ This report was generated on **Thu Oct 22 19:37:51 EEST 2020** using [Gradle-Lic
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Thu Oct 22 19:37:54 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
This report was generated on **Mon Oct 26 20:11:46 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
38 changes: 29 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->

<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>

Expand All @@ -12,7 +32,7 @@ all modules and does not describe the project structure per-subproject.

<groupId>io.spine</groupId>
<artifactId>spine-core-java</artifactId>
<version>1.6.5</version>
<version>1.6.6</version>

<inceptionYear>2015</inceptionYear>

Expand Down Expand Up @@ -70,7 +90,7 @@ all modules and does not describe the project structure per-subproject.
<dependency>
<groupId>io.spine</groupId>
<artifactId>spine-base</artifactId>
<version>1.6.5</version>
<version>1.6.6</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand All @@ -82,13 +102,13 @@ all modules and does not describe the project structure per-subproject.
<dependency>
<groupId>io.spine.tools</groupId>
<artifactId>spine-model-compiler</artifactId>
<version>1.6.5</version>
<version>1.6.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.spine.tools</groupId>
<artifactId>spine-plugin-base</artifactId>
<version>1.6.5</version>
<version>1.6.6</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -130,7 +150,7 @@ all modules and does not describe the project structure per-subproject.
<dependency>
<groupId>io.spine</groupId>
<artifactId>spine-testlib</artifactId>
<version>1.6.5</version>
<version>1.6.6</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -142,13 +162,13 @@ all modules and does not describe the project structure per-subproject.
<dependency>
<groupId>io.spine.tools</groupId>
<artifactId>spine-mute-logging</artifactId>
<version>1.6.5</version>
<version>1.6.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.spine.tools</groupId>
<artifactId>spine-plugin-testlib</artifactId>
<version>1.6.5</version>
<version>1.6.6</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -204,12 +224,12 @@ all modules and does not describe the project structure per-subproject.
<dependency>
<groupId>io.spine.tools</groupId>
<artifactId>spine-javadoc-filter</artifactId>
<version>1.6.5</version>
<version>1.6.6</version>
</dependency>
<dependency>
<groupId>io.spine.tools</groupId>
<artifactId>spine-protoc-plugin</artifactId>
<version>1.6.5</version>
<version>1.6.6</version>
</dependency>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
Expand Down
66 changes: 66 additions & 0 deletions server/src/main/java/io/spine/server/route/EventFnRoute.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* 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.server.route;

import io.spine.base.EventMessage;
import io.spine.core.EventContext;

import java.util.Set;
import java.util.function.BiFunction;
import java.util.function.Function;

import static com.google.common.base.Preconditions.checkNotNull;

/**
* An event route with one target entity ID of which is obtained as a function
* on an event message or {@code BiFunction} on an event message and its context.
*
* @param <I>
* the type of the target entity ID
* @param <E>
* the type of the event message
*/
final class EventFnRoute<I, E extends EventMessage> implements EventRoute<I, E> {

private static final long serialVersionUID = 0L;
private final BiFunction<E, EventContext, I> fn;

/**
* Creates a new event route which obtains target entity ID from an event message.
*/
EventFnRoute(Function<E, I> fn) {
this((e, ctx) -> fn.apply(e));
}

/**
* Creates an event route which obtains target entity ID from an event message and
* a its context.
*/
EventFnRoute(BiFunction<E, EventContext, I> fn) {
this.fn = checkNotNull(fn);
}

@Override
public Set<I> apply(E message, EventContext context) {
I id = fn.apply(message, context);
return EventRoute.withId(id);
}
}
Loading