use of com.developmentontheedge.beans.AbstractDynamicPropertySet in project be5 by DevelopmentOnTheEdge.
the class BeConnectionProfile method getProperties.
public DynamicPropertySet getProperties() {
return new AbstractDynamicPropertySet() {
private static final long serialVersionUID = 1L;
@Override
public int size() {
return properties.size();
}
@Override
public boolean replaceWith(String name, DynamicProperty prop) {
if (!properties.containsKey(name))
return false;
properties.put(name, (String) prop.getValue());
return true;
}
@Override
public void renameProperty(String from, String to) {
String value = properties.get(from);
properties.remove(from);
properties.put(to, value);
}
@Override
public Object remove(String name) {
return properties.remove(name);
}
@Override
public Iterator<DynamicProperty> propertyIterator() {
return StreamEx.ofKeys(properties).map(this::findProperty).iterator();
}
@Override
public Iterator<String> nameIterator() {
return properties.keySet().iterator();
}
@Override
public boolean moveTo(String name, int index) {
throw new UnsupportedOperationException();
}
@Override
public boolean contains(DynamicProperty property) {
return properties.containsKey(property.getName());
}
@Override
public Map<String, Object> asMap() {
return new LinkedHashMap<>(properties);
}
@Override
public boolean addBefore(String propName, DynamicProperty property) {
throw new UnsupportedOperationException();
}
@Override
public boolean addAfter(String propName, DynamicProperty property) {
throw new UnsupportedOperationException();
}
@Override
public void add(DynamicProperty property) {
properties.put(property.getName(), (String) property.getValue());
}
@Override
protected DynamicProperty findProperty(String name) {
String value = properties.get(name);
return value == null ? null : new DynamicProperty(name, String.class, value);
}
};
}
Aggregations