net.sf.jabb.dstream.SimpleStreamDataSupplierWithId Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jabb-core-java8 Show documentation
Show all versions of jabb-core-java8 Show documentation
Additions to jabb-core that require Java 8
The newest version!
/**
*
*/
package net.sf.jabb.dstream;
import java.time.Instant;
import org.apache.commons.lang3.Validate;
/**
* Simple data structure for a StreamDataSupplier and an ID.
* @author James Hu
*
* @param type of the message object
*/
public class SimpleStreamDataSupplierWithId implements StreamDataSupplierWithId {
protected String id;
protected StreamDataSupplier supplier;
public SimpleStreamDataSupplierWithId(){
}
public SimpleStreamDataSupplierWithId(String id, StreamDataSupplier supplier){
this.id = id;
this.supplier = supplier;
}
@Override
public StreamDataSupplierWithIdAndPositionRange withRange(String fromPosition, String toPosition){
if (fromPosition != null && toPosition != null){
Validate.isTrue(supplier.isInRange(fromPosition, toPosition), "fromPosition cannot be after toPosition");
}
return new StreamDataSupplierWithIdAndPositionRange<>(id, supplier, fromPosition, toPosition);
}
@Override
public StreamDataSupplierWithIdAndEnqueuedTimeRange withRange(Instant fromTime, Instant toTime){
if (fromTime != null && toTime != null){
Validate.isTrue(supplier.isInRange(fromTime, toTime), "fromTime cannot be after toTime");
}
return new StreamDataSupplierWithIdAndEnqueuedTimeRange<>(id, supplier, fromTime, toTime);
}
@Override
public String toString(){
return (id == null ? "" : id) + ": " + supplier;
}
@Override
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
@Override
public StreamDataSupplier getSupplier() {
return supplier;
}
public void setSupplier(StreamDataSupplier supplier) {
this.supplier = supplier;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy