public static RMConfiguration intersect(RMAssertion rma, RMConfiguration cfg) {
if (isCompatible(rma, cfg)) {
return cfg;
}
RMConfiguration compatible = new RMConfiguration(cfg);
// if supplied, policy value overrides default inactivity timeout
Long aval = cfg.getInactivityTimeout();
Long bval = null;
if (null != rma.getInactivityTimeout()) {
bval = rma.getInactivityTimeout().getMilliseconds();
}
if (null != aval || null != bval) {
Long use;
if (bval != null) {
use = bval;
} else {
use = aval;
}
compatible.setInactivityTimeout(use);
}
// if supplied, policy value overrides base retransmission interval
aval = cfg.getBaseRetransmissionInterval();
bval = null;
if (null != rma.getBaseRetransmissionInterval()) {
bval = rma.getBaseRetransmissionInterval().getMilliseconds();
}
if (null != aval || null != bval) {
Long use;
if (bval != null) {
use = bval;
} else {
use = aval;
}
compatible.setBaseRetransmissionInterval(use);
}
// if supplied, policy value overrides acknowledgement interval
aval = cfg.getAcknowledgementInterval();
bval = null;
if (null != rma.getAcknowledgementInterval()) {
bval = rma.getAcknowledgementInterval().getMilliseconds();
}
if (null != aval || null != bval) {
Long use;
if (bval != null) {
use = bval;
} else {
use = aval;
}
compatible.setAcknowledgementInterval(use);
}
// backoff parameter
if (cfg.isExponentialBackoff() || null != rma.getExponentialBackoff()) {
compatible.setExponentialBackoff(true);
}
return compatible;
}