All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.digitalcollections.prosemirror.model.impl.NodeContentBlockWithAttributesImpl Maven / Gradle / Ivy

The newest version!
package de.digitalcollections.prosemirror.model.impl;

import de.digitalcollections.prosemirror.model.api.Attributes;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

public abstract class NodeContentBlockWithAttributesImpl extends NodeContentBlockImpl
    implements Attributes {

  Map attributes = null;

  @Override
  public void addAttribute(String key, Object value) {
    if (attributes == null) {
      attributes = new HashMap<>();
    }

    attributes.put(key, value);
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    if (!super.equals(o)) {
      return false;
    }
    NodeContentBlockWithAttributesImpl that = (NodeContentBlockWithAttributesImpl) o;
    return Objects.equals(attributes, that.attributes);
  }

  @Override
  public Object getAttribute(String key) {
    if (attributes == null) {
      return null;
    }

    return attributes.get(key);
  }

  @Override
  public Map getAttributes() {
    return attributes;
  }

  @Override
  public void setAttributes(Map attributes) {
    this.attributes = attributes;
  }

  @Override
  public int hashCode() {

    return Objects.hash(super.hashCode(), attributes);
  }

  @Override
  public String toString() {
    return getClass().getSimpleName() + "{" + "attributes=" + attributes + '}';
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy