adds a new set to the composed key set
returns a new ComposedKeySet with the list of KeySets of the current one, plus the extra ones given
returns a new one with all the elements of the same type as union
eg
Compacted(ALL, ALL, SOME(1, 2), ALL, ALL_EXCEPT_SOME(3, 4), NONE, SOME(3), ALL_EXCEPT_SOME(3, 4, 5)) => Compacted(ALL, ALL_EXCEPT_SOME(3, 4, 5), NONE)
returns a new one with all the elements of the same type as union
eg
Compacted(ALL, ALL, SOME(1, 2), ALL, ALL_EXCEPT_SOME(3, 4), NONE, SOME(3), ALL_EXCEPT_SOME(3, 4, 5)) => Compacted(ALL, SOME(1, 2, 3), ALL_EXCEPT_SOME(3, 4), NONE)
true if ALL sets contain the element
returns a ComposedKeySet with the list of sets that survive the given filter
it returns a ComposedKeySet with a single ALL if the resulting list is empty
alias of contains
returns the list of complementary KeySets, of the opposite type, representing the elements that this set does not include
All -> None None -> All Some -> AllExceptSome AllExceptSome -> Some
returns true if the list is the same (not taking into account the order)
removes the given key set from the list, if it exists (using isEqual)
it returns a ComposedKeySet with a single ALL if the resulting list is empty
removes all the given key sets from the list, if any exists (using isEqual)
it returns a ComposedKeySet with a single ALL if the resulting list is empty
Composition of a list of KeySets.
On a normal use case, this is not needed and it can be solved with
first.intersect(second)
. But there are other cases where we have to be explicit about the 2 sets that we are intersecting.e.g. We have a list of items with labels, where an item can have multiple labels. We need to filter the items with labels A, B and C but that do not have labels D.
We cannot use
some(A, B, C).intersect(allExceptSome(D))
since that would end up with justsome(A, B, C)
. So we usecomposedKeySet([some(A, B, C), allExceptSome(D)])
.This way, if we have a search engine that translates key sets like this:
All
=>WHERE 1=1
None
=>WHERE 1=0
Some
=>WHERE list.contains(elements)
AllExceptSome
=>WHERE not list.contains(elements)
then the composed key set above will end up with
WHERE items.labels.contains(A, B, or C) AND NOT items.labels.contains(D)