addAttribute static method
Add attribute
Implementation
static bool addAttribute(
final HashSet<CoapLinkAttribute> attributes,
final CoapLinkAttribute attrToAdd,
) {
final parameter = LinkFormatParameter.fromShort(attrToAdd.name);
if (parameter == null) {
// Attribute is unknown
return false;
}
if (parameter.isSingle &&
attributes
.map((final attribute) => attribute.name)
.contains(attrToAdd.name)) {
return false;
}
// Special rules
if (parameter.parameterType == LinkFormatParameterType.uint &&
attrToAdd.valueAsInt! < 0) {
return false;
}
attributes.add(attrToAdd);
return true;
}