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

overflowdb.Element Maven / Gradle / Ivy

There is a newer version: 1.173
Show newest version
package overflowdb;

import java.util.Map;
import java.util.Optional;
import java.util.Set;

public abstract class Element {
  public abstract String label();

  public abstract Graph graph();

  public abstract Set propertyKeys();

  public abstract Object property(String key);

  public abstract  A property(PropertyKey key);

  public  A property(String key, A defaultValue) {
    Object value = property(key);
    return value != null ? (A) value : defaultValue;
  }

  public  A property(PropertyKey key, A defaultValue) {
    Object value = property(key);
    return value != null ? (A) value : defaultValue;
  }

  /** override this in specific element class, to define a default value */
  public Object propertyDefaultValue(String propertyKey) {
    return null;
  }

  public abstract  Optional propertyOption(PropertyKey key);

  public abstract Optional propertyOption(String key);

  /** Map with all properties, including the default property values which haven't been explicitly set */
  public abstract Map propertiesMap();


  @Deprecated public final void setProperty(String key, Object value) {setPropertyImpl(key, value);};
  protected abstract void setPropertyImpl(String key, Object value);
  final void setPropertyInternal(String key, Object value) {setPropertyImpl(key, value);}

  @Deprecated public final  void setProperty(PropertyKey key, A value){setPropertyImpl(key, value);}
  protected abstract  void setPropertyImpl(PropertyKey key, A value);
  final  void setPropertyInternal(PropertyKey key, A value){setPropertyImpl(key, value);}


  @Deprecated public final void setProperty(Property property){setPropertyImpl(property);}
  protected abstract void setPropertyImpl(Property property);
  final void setPropertyInternal(Property property){setPropertyImpl(property);}


  @Deprecated final public void removeProperty(String key){removePropertyImpl(key);}
  protected abstract void removePropertyImpl(String key);
  final void removePropertyInternal(String key){removePropertyImpl(key);}


  @Deprecated public final void remove(){removeImpl();};
  protected abstract void removeImpl();
  final void removeInternal(){removeImpl();};

}