Object oldValue = base.getValue(attr);
if (oldValue == null ? value == null : oldValue.equals(value)) return;
Integer newMax = null;
if (attr == StdAttr.WIDTH) {
BitWidth oldWidth = base.getValue(StdAttr.WIDTH);
BitWidth newWidth = (BitWidth) value;
int oldW = oldWidth.getWidth();
int newW = newWidth.getWidth();
Integer oldValObj = base.getValue(Counter.ATTR_MAX);
int oldVal = oldValObj.intValue();
base.setValue(StdAttr.WIDTH, newWidth);
if (newW > oldW) {
newMax = Integer.valueOf(newWidth.getMask());
} else {
int v = oldVal & newWidth.getMask();
if (v != oldVal) {
Integer newValObj = Integer.valueOf(v);
base.setValue(Counter.ATTR_MAX, newValObj);
fireAttributeValueChanged(Counter.ATTR_MAX, newValObj);
}
}
fireAttributeValueChanged(StdAttr.WIDTH, newWidth);
} else if (attr == Counter.ATTR_MAX) {
int oldVal = ((Integer) value).intValue();
BitWidth width = base.getValue(StdAttr.WIDTH);
int newVal = oldVal & width.getMask();
if (newVal != oldVal) {
@SuppressWarnings("unchecked")
V val = (V) Integer.valueOf(newVal);
value = val;
}