Bug 491575 - Introduce ElementDelta.Builder API
Summary: Introduce ElementDelta.Builder API
Status: RESOLVED FIXED
Alias: None
Product: Handly
Classification: Technology
Component: Core (show other bugs)
Version: 0.5   Edit
Hardware: All All
: P3 enhancement
Target Milestone: 0.5   Edit
Assignee: Vladimir Piskarev CLA
QA Contact:
URL:
Whiteboard: breakingchange
Keywords: api
Depends on:
Blocks:
 
Reported: 2016-04-13 05:26 EDT by Vladimir Piskarev CLA
Modified: 2016-06-07 07:37 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Piskarev CLA 2016-04-13 05:26:59 EDT
Currently, the class ElementDelta provides methods for building a delta tree (their names start with 'hInsert'). Probably, it would be better to provide a separate Builder class for this functionality and thus separate delta accessing/building API. A further advantage is that methods of the Builder class will not need to follow a certain naming convention (like the 'hInsert' prefix).

We'll need to rename the existing ElementDeltaBuilder class to something like ElementDifferencer to set it apart from the newly introduced ElementDelta.Builder.
Comment 2 Vladimir Piskarev CLA 2016-06-07 07:37:26 EDT
A typical usage pattern for the new builder API

ElementDelta.Builder builder = new ElementDelta.Builder(new ElementDelta(root));
builder.changed(file1, F_CONTENT);
builder.added(file2);
ElementDelta delta = builder.getDelta();

For a comprehensive example of use, see the class FooDeltaProcessor in the Basic Example.

The old API methods for building a delta tree (ElementDelta#hInsertXXX) were removed.

The class ElementDeltaBuilder was renamed to ElementDifferencer and its constructors now take ElementDelta.Builder. See the class FooFile.NotifyingReconcileOperation in the Basic Example for a typical usage pattern.