brooklyn.entity.rebind.dto.BasicPolicyMemento Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of brooklyn-core Show documentation
Show all versions of brooklyn-core Show documentation
Entity implementation classes, events, and other core elements
package brooklyn.entity.rebind.dto;
import java.io.Serializable;
import java.util.Map;
import brooklyn.mementos.PolicyMemento;
import com.google.common.collect.Maps;
/**
* The persisted state of a location.
*
* @author aled
*/
public class BasicPolicyMemento extends AbstractMemento implements PolicyMemento, Serializable {
private static final long serialVersionUID = -4025337943126838761L;
public static Builder builder() {
return new Builder();
}
public static class Builder extends AbstractMemento.Builder {
protected Map flags = Maps.newLinkedHashMap();
public Builder from(PolicyMemento other) {
super.from(other);
flags.putAll(other.getFlags());
return this;
}
public Builder flags(Map vals) {
flags.putAll(vals); return this;
}
public PolicyMemento build() {
return new BasicPolicyMemento(this);
}
}
private Map flags;
private Map fields;
// Trusts the builder to not mess around with mutability after calling build()
protected BasicPolicyMemento(Builder builder) {
flags = toPersistedMap(builder.flags);
}
protected void setCustomFields(Map fields) {
this.fields = toPersistedMap(fields);
}
public Map getCustomFields() {
return fromPersistedMap(fields);
}
@Override
public Map getFlags() {
return fromPersistedMap(flags);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy