I have stream (magnitude 10s of millions) of entities, say Item which is modeled as below:

```
class Item {
 String id;
 Double price;
 Double profitPercentage;
 Country originCountry;
 Country destinationCountry;
 ...
}

```

All the attributes of this entity are well defined, and are restricted to Price related information + metadata.

I'd like to give a user the ability to create Buckets, which are nothing but a set of constraints on the attribute (e.g. price > 1000, originCountry == Country.USA, profitPercentage between 5 and 20), but with the condition that an **Entity cannot fall into two buckets** (The same should detected when an attempt is made to create such a conflicting Bucket).

The operations on each type of Entity are also well defined e.g. Double can only be used in comparisons (>,<,=,range),Country (which logically represents a member of a well-defined set of values) in some set etc)

This is mainly because each bucket is associated with an automated action, such as payment,rejection or refund, and resolution of overlapping actions is non-trivial.

The obvious solution to this problem is to allow the user to define priorities on the Buckets created (implies that multiple Buckets can match a given Entity), but this is something I would like to avoid, since it requires that there can never be two buckets having same priority, and such an occurrence would fail at runtime.

I am looking for solutions which could be used to detect the conflicts during creation time, but I have no clue where to begin. Others have suggested some sort of SMT Solver (Z3 was recommended), but I am not aware if this is at all feasible.