Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
97 additions
and
23 deletions.
There are no files selected for viewing
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
@@ -0,0 +1,67 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The SF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
package org.apache.aries.events.api; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
import java.util.function.Consumer; | ||
|
||
import javax.annotation.ParametersAreNonnullByDefault; | ||
|
||
@ParametersAreNonnullByDefault | ||
public class SubscribeRequest { | ||
private final String topic; | ||
private final Consumer<Received> callback; | ||
private Position position; | ||
private Seek seek = Seek.latest; | ||
|
||
public SubscribeRequest(String topic, Consumer<Received> callback) { | ||
this.topic = topic; | ||
this.callback = callback; | ||
} | ||
|
||
public static SubscribeRequest to(String topic, Consumer<Received> callback) { | ||
return new SubscribeRequest(topic, callback); | ||
} | ||
|
||
public SubscribeRequest startAt(Position position) { | ||
this.position = position; | ||
return this; | ||
} | ||
|
||
public SubscribeRequest seek(Seek seek) { | ||
this.seek = requireNonNull(seek, "Seek must not be null"); | ||
return this; | ||
} | ||
|
||
public String getTopic() { | ||
return topic; | ||
} | ||
|
||
public Position getPosition() { | ||
return position; | ||
} | ||
|
||
public Seek getSeek() { | ||
return seek; | ||
} | ||
|
||
public Consumer<Received> getCallback() { | ||
return callback; | ||
} | ||
} |
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