public void setValue(Attribute attribute, Object value) { checkWritable(); if (value != null && !(value instanceof Collection<?>)) { value = Collections.singleton(value); } setValues(attribute, (Collection<?>) value); }
public <T> void addValue(Attribute attribute, T value) { checkWritable(); String attributeKey = attribute.getKey(); String stringValue = toStringValue(attribute, value); if (stringValue == null) { return; } addValue(attributeKey, stringValue); }
public <T> void addValue(Attribute attribute, T value) { checkWritable(); String attributeKey = attribute.getKey(); String stringValue = ((AttributeImpl) attribute).toStringValue(value); if (stringValue == null) { return; } List<String> l = data.get(attributeKey); if (l == null) { l = new ArrayList<String>(); data.put(attributeKey, l); } l.add(stringValue); }
public <T> void setValues(Attribute attribute, Collection<T> values) { checkWritable(); String attributeKey = attribute.getKey(); if (values == null || values.isEmpty()) { data.remove(attributeKey); name = null; return; } ArrayList<String> newValues = new ArrayList<String>(); for (Object value : values) { String stringValue = ((AttributeImpl) attribute).toStringValue(value); if (stringValue != null) { newValues.add(stringValue); } } data.put(attributeKey, newValues); // isNameUpToDate = false; name = null; }