- /** @return Service - the Service object read from the DataBroker or null if none was found */
- public static Service read(DataBroker dataBroker,String serviceKey, LogicalDatastoreType logicalDatastoreType) throws Exception {
- InstanceIdentifier serviceInstanceIdentifier = InstanceIdentifier.<Services>builder(Services.class)
- .child(Service.class, new ServiceKey(serviceKey)).build();
- ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction();
- Optional<Service> data = (Optional<Service>) readTx.read(logicalDatastoreType, serviceInstanceIdentifier).get();
- if(!data.isPresent()){
+ public static <P> P build(Builder<P> b) {
+ return b == null? null :b.build();
+ }
+
+ public static <P,B extends Builder<P>> P build(Function<P,B> builderConstructor,P sourceDataObject){
+ if(sourceDataObject == null){