Package com.dnanexus

Class DXDataObject.Builder<T extends DXDataObject.Builder<T,​U>,​U extends DXDataObject>

    • Field Detail

      • folder

        protected String folder
      • createParents

        protected Boolean createParents
      • details

        protected com.fasterxml.jackson.databind.JsonNode details
      • properties

        protected com.google.common.collect.ImmutableMap.Builder<String,​String> properties
    • Constructor Detail

      • Builder

        protected Builder()
    • Method Detail

      • getNewObjectId

        protected static String getNewObjectId​(com.fasterxml.jackson.databind.JsonNode responseJson)
        Deserializes the response to a /class-xxxx/new API call and returns the ID of the newly created object.
        Returns:
        DNAnexus object ID
      • addTags

        public T addTags​(Collection<String> tags)
        Adds the specified tags to the newly created data object.
        Parameters:
        tags - tags to add
        Returns:
        the same Builder object
      • addTypes

        public T addTypes​(Collection<String> types)
        Adds the specified types to the newly created data object.
        Parameters:
        types - types to add
        Returns:
        the same Builder object
      • build

        public abstract U build()
        Creates the new data object.
        Returns:
        a DXDataObject corresponding to the newly created object
      • checkAndFixParameters

        protected void checkAndFixParameters()
        Ensures that the project was either explicitly set or that the environment specifies a workspace.
      • getThisInstance

        protected abstract T getThisInstance()
        Returns the builder object.

        This abstract method is implemented by the Builder methods so that common methods can get an instance of the subclass for chaining purposes.

        Returns:
        the same object
      • putAllProperties

        public T putAllProperties​(Map<String,​String> properties)
        Sets the specified properties on the newly created data object.
        Parameters:
        properties - Map containing non-null keys and values which will be set as property keys and values respectively
        Returns:
        the same Builder object
      • putProperty

        public T putProperty​(String key,
                             String value)
        Sets the specified property on the newly created data object.
        Parameters:
        key - property key to set
        value - property value to set
        Returns:
        the same Builder object
      • setDetails

        public T setDetails​(Object details)
        Sets the details of the data object to be created.
        Parameters:
        details - an object whose JSON serialized form will be set as the details
        Returns:
        the same Builder object
      • setFolder

        public T setFolder​(String folder)
        Sets the folder in which the data object will be created.
        Parameters:
        folder - full path to destination folder (a String starting with "/")
        Returns:
        the same Builder object
      • setFolder

        public T setFolder​(String folder,
                           boolean createParents)
        Sets the folder in which the data object will be created, optionally specifying that the folder and its parents should be created if necessary.
        Parameters:
        folder - full path to destination folder (a String starting with "/")
        createParents - if true, the folder will be created if it doesn't exist
        Returns:
        the same Builder object
      • setName

        public T setName​(String name)
        Sets the name of the newly created data object.
        Parameters:
        name - name to set
        Returns:
        the same Builder object
      • setProject

        public T setProject​(DXContainer project)
        Sets the project or container where the new data object will be created.
        Parameters:
        project - DXProject or DXContainer
        Returns:
        the same Builder object
      • setVisibility

        public T setVisibility​(boolean visible)
        Sets the visibility of the new data object.
        Parameters:
        visible - if false, the object will be hidden
        Returns:
        the same Builder object