Class Document

java.lang.Object
se.conciliate.extensions.documents.Document

public final class Document extends Object
A document with meta-data from a source. This class is immutable.
  • Method Details

    • createUnsaved

      public static Document createUnsaved(DocumentSource source, Collection<MetaData> data)
      Creates a document instance representing a document that has not yet been persisted to its source and thus does not have a valid id yet.
      Parameters:
      source - The source that owns the document and knows how to persist it.
      data - A collection of meta data to populate this document with. The data must have the same source as the source parameter.
      Returns:
      a document representing a non-persisted document that does not have an id.
    • createExisting

      public static Document createExisting(DocumentSource source, String id, Collection<MetaData> data)
      Creates a document instance representing an existing document that is persisted in its source and thus has an id.
      Parameters:
      source - The source that owns the document, the source where the document is persisted.
      id - The document's id.
      data - A collection of meta data for the document.
      Returns:
      A document representing a persisted document that does have an id.
    • getSource

      public DocumentSource getSource()
      Returns this document's source, the owner of the document.
      Returns:
      the owning source of this document.
    • getID

      public Optional<String> getID()
      Returns:
      A unique (for the source) ID for the document.
    • getGlobalID

      public Document.DocumentID getGlobalID()
      Returns a globally unique ID for the document.
      Returns:
      a globally unique ID for the document.
    • getTitle

      public String getTitle()
      Returns the title of this document.
      Returns:
      the title of this document.
    • getIcon

      public URL getIcon()
      Returns the icon of this document. If the icon is not 24x24 pixels, it may be scaled.
      Returns:
      the icon of this document.
    • getMetaData

      public Optional<MetaData> getMetaData(String typeId)
      Parameters:
      typeId - The meta-data type.
      Returns:
      Optional meta-data of a given type set on this document.
    • getMetaData

      public Optional<MetaData> getMetaData(MetaDataType type)
      Parameters:
      type - The meta-data type.
      Returns:
      Optional meta-data of a given type set on this document.
    • getMetaData

      Parameters:
      type - The meta-data type.
      Returns:
      Optional meta-data of a given type set on this document.
    • getMetaData

      Parameters:
      type - The meta-data type.
      Returns:
      Optional meta-data of a given type set on this document.
    • getMetaData

      Parameters:
      type - The meta-data type.
      Returns:
      Optional meta-data of a given type set on this document.
    • getMetaData

      Parameters:
      type - The meta-data type.
      Returns:
      Optional meta-data of a given type set on this document.
    • getMetaData

      Parameters:
      type - The meta-data type.
      Returns:
      Optional meta-data of a given type set on this document.
    • getMetaData

      Parameters:
      type - The meta-data type.
      Returns:
      Optional meta-data of a given type set on this document.
    • getMetaData

      Parameters:
      type - The meta-data type.
      Returns:
      Optional meta-data of a given type set on this document.
    • getMetaData

      Parameters:
      type - The meta-data type.
      Returns:
      Optional meta-data of a given type set on this document.
    • getMetaData

      Parameters:
      type - The meta-data type.
      Returns:
      Optional meta-data of a given type set on this document.
    • getMetaData

      public Optional<MetaData<?>> getMetaData(MetaDataType.ColumnType columnType)
      Parameters:
      columnType - The pre-defined column type
      Returns:
      Optional meta data of a given column type
    • getIcon

      Parameters:
      columnType - The pre-defined column type
      Returns:
      Optional meta data of a given column type
    • setMetaData

      public Document setMetaData(Collection<MetaData> data)
      Parameters:
      data - The data to set.
      Returns:
      A new document with the new meta-data set.
      Throws:
      IllegalArgumentException - If any meta-data has a non-editable type.
    • setMetaData

      public Document setMetaData(MetaData data)
      Parameters:
      data - The data to set.
      Returns:
      A new document with the new meta-data set.
      Throws:
      IllegalArgumentException - If the meta-data has a non-editable type.
    • equals

      public boolean equals(Object o)
      Checks this document's equality relation to some other object. Will return false for any object that is not a Document. Documents are considered equal if they have the same id and source, even if they do not share the same set of meta data.
      New Documents are never equal to any other document (since they don't have an id).
      Overrides:
      equals in class Object
      Parameters:
      o - The object to compare for equality.
      Returns:
      True if o is a Document and has the same id and source as this document, false otherwise. False is also returned if either this or o is a new document (created with a call to createUnsaved).
    • hashCode

      public int hashCode()
      Returns the hash for this document. The hash will be the same for any documents that are equal. For non equal documents, the hash will be the same if the documents have the same source and are new documents created with a call to createUnsaved.
      Overrides:
      hashCode in class Object
      Returns:
      A hash for the document.
    • toString

      public String toString()
      Returns a debug string representing this document. The string will be "SourceID DocumentTitle.
      Overrides:
      toString in class Object
      Returns:
      a debug string representing this document.