Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Asset addAttribute replaced with addAttributes

Rich Turner469fb43657b6
diff --git a/model/src/main/java/org/openremote/model/asset/Asset.java b/model/src/main/java/org/openremote/model/asset/Asset.java
index 81eeca1e5..770ab3f54 100644
--- a/model/src/main/java/org/openremote/model/asset/Asset.java
+++ b/model/src/main/java/org/openremote/model/asset/Asset.java
@@ -339,12 +339,16 @@ public class Asset implements IdentifiableEntity {
}
- public void addAttribute(AssetAttribute attribute) throws IllegalArgumentException {
- if (getAttributesStream().anyMatch(attr -> isAttributeNameEqualTo(attr, attribute.getName().orElse(null)))) {
- throw new IllegalArgumentException("Attribute by this name already exists");
- }
-
- replaceAttribute(attribute);
+ public void addAttributes(AssetAttribute... attributes) throws IllegalArgumentException {
+ Arrays.asList(attributes).forEach(
+ attribute -> {
+ if (getAttributesStream().anyMatch(attr -> isAttributeNameEqualTo(attr, attribute.getName().orElse(null)))) {
+ throw new IllegalArgumentException("Attribute by this name already exists");
+ }
+
+ replaceAttribute(attribute);
+ }
+ );
}
public void replaceAttribute(AssetAttribute attribute) throws IllegalArgumentException {