* @param attrName
* Name of the attribute.
*
- * @return Attribute value type information {@AttributeValue.TypeInfo
- * }.
+ * @return Attribute value type information {@AttributeValue.TypeInfo}.
*/
public AttributeValue.TypeInfo getAttributeType(String attrName) {
if (mValues.containsKey(attrName))
return mValues.size();
}
+ /**
+ * API to update the attribute values from given
+ * {@link SimulatorResourceModel}.
+ */
+ public void update(SimulatorResourceModel resourceModel) {
+ if (null == resourceModel || 0 == resourceModel.size())
+ return;
+
+ for (Map.Entry<String, SimulatorResourceAttribute> entry : resourceModel
+ .getAttributes().entrySet()) {
+ SimulatorResourceAttribute newAttribute = entry.getValue();
+ SimulatorResourceAttribute attribute = getAttribute(entry.getKey());
+ if (null != newAttribute && null != attribute) {
+ if (null != attribute.property()) {
+ AttributeValueValidation validation = new AttributeValueValidation(
+ attribute.property());
+ if (!validation.validate(newAttribute.value())) {
+ mValues.put(entry.getKey(), newAttribute.value());
+ }
+ } else {
+ mValues.put(entry.getKey(), newAttribute.value());
+ }
+ }
+ }
+ }
+
// Methods used in native code
private SimulatorResourceModel(Map<String, AttributeValue> values,
Map<String, AttributeProperty> properties) {