use of org.eclipse.leshan.core.request.BindingMode in project leshan by eclipse.
the class RegistrationUpdate method update.
/**
* Returns an updated version of the registration.
*
* @param registration the registration to update
* @return the updated registration
*/
public Registration update(Registration registration) {
Identity identity = this.identity != null ? this.identity : registration.getIdentity();
Link[] linkObject = this.objectLinks != null ? this.objectLinks : registration.getObjectLinks();
long lifeTimeInSec = this.lifeTimeInSec != null ? this.lifeTimeInSec : registration.getLifeTimeInSec();
BindingMode bindingMode = this.bindingMode != null ? this.bindingMode : registration.getBindingMode();
String smsNumber = this.smsNumber != null ? this.smsNumber : registration.getSmsNumber();
Map<String, String> additionalAttributes = this.additionalAttributes.isEmpty() ? registration.getAdditionalRegistrationAttributes() : updateAdditionalAttributes(registration.getAdditionalRegistrationAttributes());
// this needs to be done in any case, even if no properties have changed, in order
// to extend the client registration time-to-live period ...
Date lastUpdate = new Date();
Registration.Builder builder = new Registration.Builder(registration.getId(), registration.getEndpoint(), identity, registration.getRegistrationEndpointAddress());
builder.lwM2mVersion(registration.getLwM2mVersion()).lifeTimeInSec(lifeTimeInSec).smsNumber(smsNumber).bindingMode(bindingMode).objectLinks(linkObject).registrationDate(registration.getRegistrationDate()).lastUpdate(lastUpdate).additionalRegistrationAttributes(additionalAttributes);
return builder.build();
}
Aggregations