eclipse-uprotocol / up-java

uProtocol Language Specific Library for Java
Apache License 2.0
8 stars 14 forks source link

Add UriFilter #147

Closed stevenhartley closed 2 months ago

stevenhartley commented 2 months ago

Transports can take advantage of a UriFilter that will check to see if the source and sink URI matches that in the UMessage. Below is the proposed code from Misha:

public record UriFilter (@NonNull UUri source, @NonNull UUri sink) {
    public boolean matches(UAttributes attributes) {
        if (attributes == null) {
            return false;
        }
        return UriValidator.matches(source, attributes.getSource()) && UriValidator.matches(sink, attributes.getSink());
    }