Merges two versions of an entity, each changed since a common base: mine, the version being edited, and theirs,
the row as changed by someone else, for example the one an update failed on with an
EntityModifiedException.
Lists the attributes whose values differ between the two, each with the side its value is taken from. A side is
pre-selected where the base tells which version changed the value, see EntityMerge.Change. The result,
merged(), is theirs with the values chosen from mine, updatable over theirs.
The attributes compared by default are the updatable columns, apart from the primary key and the columns of
foreign keys, and the foreign keys whose columns are all updatable. An attribute mine does not have is not
compared, and one mine has, theirs must have as well, a lazy column included, see EntityMerge.Builder.build(). A foreign
key is compared by its columns, its value being the referenced entity, as loaded.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceAn attribute whose value differs between mine and theirsstatic interfaceBuilds aEntityMergestatic enumWhich version changed an attribute value, according to the basestatic enumThe version an attribute value is taken from -
Method Summary
Modifier and TypeMethodDescriptionbase()static EntityMerge.Builder.MineStepbuilder()complete()merged()Returns theirs with the values of the attributes for which mine is chosen, theirs' values being its original ones, so that it is modified where a chosen value of mine differs, and updatable over theirs.mine()theirs()
-
Method Details
-
mine
Entity mine()- Returns:
- mine, the version being edited, an immutable copy
-
theirs
Entity theirs()- Returns:
- theirs, the row as changed by someone else, an immutable copy
-
base
- Returns:
- the base, the version both changed, an immutable copy, an empty Optional in case none was given
-
attributes
List<EntityMerge.AttributeMerge<?>> attributes()- Returns:
- the attributes whose values differ between mine and theirs, in the order compared
-
complete
ObservableState complete()- Returns:
- a state active while each attribute has a side
-
merged
Entity merged()Returns theirs with the values of the attributes for which mine is chosen, theirs' values being its original ones, so that it is modified where a chosen value of mine differs, and updatable over theirs. Unmodified in case mine is chosen for no attribute.- Returns:
- a new mutable entity, the merge result
- Throws:
IllegalStateException- in case an attribute has no side- See Also:
-
builder
- Returns:
- a new
EntityMerge.Builder.MineStep
-