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

org.molgenis.data.Entity Maven / Gradle / Ivy

There is a newer version: 8.4.5
Show newest version
package org.molgenis.data;

import java.time.Instant;
import java.time.LocalDate;
import org.molgenis.data.meta.model.Attribute;
import org.molgenis.data.meta.model.EntityType;
import org.molgenis.util.i18n.Identifiable;

/**
 * Entity is a data record which can contain a hash of attribute values. Attribute names are unique.
 * Synonyms are ‘tuple’, ‘record’, ‘row’, ‘hashmap’. Optionally Entity can provide a unique ‘id’ for
 * updates. Optionally Entity can provide a human readable label for lookups
 */
public interface Entity extends Identifiable {
  /**
   * Returns entity meta data
   *
   * @return entity meta data, never null
   */
  EntityType getEntityType();

  /**
   * Get all attribute names
   *
   * 

TODO remove, use getEntityType to retrieve entity meta data */ Iterable getAttributeNames(); /** * Optional unique id to identify this Entity. Otherwise return null * *

// TODO getIdValue should return id of type of entity (requires generic on Entity) */ Object getIdValue(); /** * Sets the identifier value of this entity. The class type of the id is based on the id attribute * data type. * * @param id identifier value */ void setIdValue(Object id); /** Optional human readable label to recognize this Entity. Otherwise return null */ Object getLabelValue(); /** Get attribute value */ Object get(String attributeName); default Object get(Attribute attribute) { return get(attribute.getName()); } /** Retrieves the value of the designated column as String. */ String getString(String attributeName); default String getString(Attribute attribute) { return getString(attribute.getName()); } /** Retrieves the value of the designated column as Integer. */ Integer getInt(String attributeName); default Integer getInt(Attribute attribute) { return getInt(attribute.getName()); } /** Retrieves the value of the designated column as Long. */ Long getLong(String attributeName); default Long getLong(Attribute attribute) { return getLong(attribute.getName()); } /** Retrieves the value of the designated column as Boolean. */ Boolean getBoolean(String attributeName); default Boolean getBoolean(Attribute attribute) { return getBoolean(attribute.getName()); } /** Retrieves the value of the designated column as Double. */ Double getDouble(String attributeName); default Double getDouble(Attribute attribute) { return getDouble(attribute.getName()); } /** Retrieves the value of the designated column as {@link java.time.Instant}. */ Instant getInstant(String attributeName); default Instant getInstant(Attribute attribute) { return getInstant(attribute.getName()); } /** Retrieves the value of the designated column as {@link java.time.LocalDate}. */ LocalDate getLocalDate(String attributeName); default LocalDate getLocalDate(Attribute attribute) { return getLocalDate(attribute.getName()); } /** Retrieves the value of the designated column as entity */ Entity getEntity(String attributeName); default Entity getEntity(Attribute attribute) { return getEntity(attribute.getName()); } /** Retrieves the value of the designated column as entity of the give type */ E getEntity(String attributeName, Class clazz); default E getEntity(Attribute attribute, Class clazz) { return getEntity(attribute.getName(), clazz); } /** Retrieves the value of the designated column as a entity iterable */ Iterable getEntities(String attributeName); default Iterable getEntities(Attribute attribute) { return getEntities(attribute.getName()); } /** Retrieves the value of the designated column as a entity of the given type iterable */ Iterable getEntities(String attributeName, Class clazz); default Iterable getEntities(Attribute attribute, Class clazz) { return getEntities(attribute.getName(), clazz); } /** Change attribute value */ void set(String attributeName, Object value); default void set(Attribute attribute, Object value) { set(attribute.getName(), value); } /** * Copy attribute values from another entity * *

TODO remove method, move to utility class */ void set(Entity values); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy