@Override public Object setAttribute(String property, Object value) { // Update the existing attribute if one already exists for (CollectionAttributeDTO attribute : attributes) { if (attribute.getKey().equals(property)) { Object previousValue = attribute.getValueOrContents(); attribute.setValueOrContents(value); return previousValue; } } // We didn't match an existing attribute, create a new one attributes.add(new CollectionAttributeDTO(property, value)); return null; }
@SuppressWarnings("unchecked") @Override public <V> V getAttribute(String property) { for (CollectionAttributeDTO attribute : attributes) { if (!attribute.getKey().equals(property)) { continue; } return (V)attribute.getValueOrContents(); } return null; }
public Map<String, Object> getParameters(ServiceCollector collector) { if (Boolean.TRUE.equals(attributesNeedUnmarshaling)) { final Map<String, String> parms = new HashMap<>(); attributes.stream().forEach(a -> parms.put(a.getKey(), a.getValue())); return collector.unmarshalParameters(parms); } else { final Map<String, Object> parms = new HashMap<>(); attributes.stream().forEach(a -> parms.put(a.getKey(), a.getValueOrContents())); return parms; } }
public void addAttribute(String key, Object value) { attributes.add(new CollectionAttributeDTO(key, value)); }
@Override public Set<String> getAttributeNames() { return attributes.stream() .map(a -> a.getKey()) .collect(Collectors.toSet()); }
public Map<String, Object> getParameters(ServiceCollector collector) { if (Boolean.TRUE.equals(attributesNeedUnmarshaling)) { final Map<String, String> parms = new HashMap<>(); attributes.stream().forEach(a -> parms.put(a.getKey(), a.getValue())); return collector.unmarshalParameters(parms); } else { final Map<String, Object> parms = new HashMap<>(); attributes.stream().forEach(a -> parms.put(a.getKey(), a.getValueOrContents())); return parms; } }
public void addAttribute(String key, Object value) { attributes.add(new CollectionAttributeDTO(key, value)); }