Class ReadableResource.Builder<T extends ReadableResource.Builder<T>>

java.lang.Object
com.janeirodigital.sai.core.resources.ReadableResource.Builder<T>
Type Parameters:
T - Parameterized type of an inheriting builder
Direct Known Subclasses:
CRUDResource.Builder, ImmutableResource.Builder, ReadableAccessGrant.Builder, ReadableAgentRegistration.Builder, ReadableDataGrant.Builder, ReadableSocialAgentProfile.Builder
Enclosing class:
ReadableResource

public abstract static class ReadableResource.Builder<T extends ReadableResource.Builder<T>> extends Object
Generic builder which is extended by readable resource builders, as well as builders for the other base resource types CRUDResource and ImmutableResource, respectively.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected com.janeirodigital.sai.httputils.ContentType
     
    protected org.apache.jena.rdf.model.Model
     
    protected boolean
     
    protected String
     
    protected org.apache.jena.rdf.model.Resource
     
    protected final SaiSession
     
    protected boolean
     
    protected final URI
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Builder(URI uri, SaiSession saiSession)
    Base builder for all resource types.
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract T
    Necessary to so that we don't get an unchecked cast warning when casting the return value of setters in this and any inheriting builders.
    setContentType(com.janeirodigital.sai.httputils.ContentType contentType)
    Set the content-type for the resource (as opposed to the default set by the builder constructor).
    setDataset(okhttp3.Response response)
    Extracts a Jena Model from an HTTP response and calls setDataset(Model) after extraction
    setDataset(org.apache.jena.rdf.model.Model dataset)
    Jena Model that is used to initialize attributes of inheriting builders rather than set them manually.
    setJsonLdContext(String jsonLdContext)
    Set the JSON-LD context to use for the resource (as opposed to the default context by the builder constructor).
    Set the resource type as unprotected.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • uri

      protected final URI uri
    • saiSession

      protected final SaiSession saiSession
    • unprotected

      protected boolean unprotected
    • contentType

      protected com.janeirodigital.sai.httputils.ContentType contentType
    • dataset

      protected org.apache.jena.rdf.model.Model dataset
    • resource

      protected org.apache.jena.rdf.model.Resource resource
    • jsonLdContext

      protected String jsonLdContext
    • exists

      protected boolean exists
  • Constructor Details

    • Builder

      protected Builder(URI uri, SaiSession saiSession)
      Base builder for all resource types. Use setters for all further configuration
      Parameters:
      uri - URI of the resource to build
      saiSession - SaiSession to use
  • Method Details

    • getThis

      public abstract T getThis()
      Necessary to so that we don't get an unchecked cast warning when casting the return value of setters in this and any inheriting builders.
      Returns:
      T generic - on implementations this is the resource type that is being built
    • setUnprotected

      public T setUnprotected()
      Set the resource type as unprotected. Keeps any credentials from being sent along as part of any requests issued for this resource
      Returns:
      ReadableResource.Builder
    • setContentType

      public T setContentType(com.janeirodigital.sai.httputils.ContentType contentType)
      Set the content-type for the resource (as opposed to the default set by the builder constructor).
      Parameters:
      contentType - ContentType to set
      Returns:
      ReadableResource.Builder
    • setDataset

      public T setDataset(org.apache.jena.rdf.model.Model dataset) throws SaiException
      Jena Model that is used to initialize attributes of inheriting builders rather than set them manually. Used in all read scenarios when populating the Builder from the contents of a remote resource.
      Parameters:
      dataset - Jena model to populate the Builder attributes with
      Returns:
      ReadableResource.Builder
      Throws:
      SaiException
    • setDataset

      public T setDataset(okhttp3.Response response) throws SaiException
      Extracts a Jena Model from an HTTP response and calls setDataset(Model) after extraction
      Parameters:
      response - OkHttp Response to extract from
      Returns:
      ReadableResource.Builder
      Throws:
      SaiException
    • setJsonLdContext

      public T setJsonLdContext(String jsonLdContext)
      Set the JSON-LD context to use for the resource (as opposed to the default context by the builder constructor). Note that this setting won't matter unless the ContentType of the resource is LD_JSON.
      Parameters:
      jsonLdContext - JSON-LD context to set
      Returns:
      ReadableResource.Builder