how about "toBuilder()"?

--Yakov

2015-12-11 13:02 GMT+03:00 Alexey Goncharuk <alexey.goncha...@gmail.com>:

> Igniters,
>
> I was creating an example showing how to use BinaryObjects and
> EntryProcessor for the case when server nodes do not have cache classes
> definitions and realized that there is no straightforward way to get an
> instance of BinaryObjectBuilder inside of an EntryProcessor.
>
> Currently the only way to do this is to inject an instance of Ignite to the
> instance of EntryProcessor and get a reference to IgniteBinary from it,
> which looks a bit too verbose to me:
>
> class MyEntryProcessor {
>     @IgniteInstanceResource
>     private Ignite ignite;
>
>     BinaryObject invoke(...) {
>         BinaryObjectBulder bld = ignite.binary().builder(entry.getValue());
>
>         entry.setValue(bld.setField("a", 2).build());
>     }
> }
>
> I think we can add something like a "BinaryBuilder buildCopy();" method to
> the BinaryObject interface which will create a new binary builder
> initialized with the current binary object. Now the above EntryProcessor
> will look as follows:
>
> class MyEntryProcessor {
>     BinaryObject invoke(...) {
>         entry.setValue(entry.getValue().buildCopy().setField("a",
> 2).build());
>     }
> }
>
> Thoughts?
>

Reply via email to