Package com.dnanexus
Class DXDataObject.Builder<T extends DXDataObject.Builder<T,U>,U extends DXDataObject>
- java.lang.Object
-
- com.dnanexus.DXDataObject.Builder<T,U>
-
- Type Parameters:
T- the builder type subclassU- class of data object to be created
- Direct Known Subclasses:
DXApplet.Builder,DXFile.Builder,DXRecord.Builder,DXWorkflow.Builder
- Enclosing class:
- DXDataObject
protected abstract static class DXDataObject.Builder<T extends DXDataObject.Builder<T,U>,U extends DXDataObject> extends Object
Abstract builder class for creating a new data object of classU.
-
-
Field Summary
Fields Modifier and Type Field Description protected BooleancreateParentsprotected com.fasterxml.jackson.databind.JsonNodedetailsprotected DXEnvironmentenvprotected Stringfolderprotected Booleanhiddenprotected Stringnameprotected DXContainerprojectprotected com.google.common.collect.ImmutableMap.Builder<String,String>propertiesprotected List<String>tagsprotected List<String>types
-
Constructor Summary
Constructors Modifier Constructor Description protectedBuilder()protectedBuilder(DXEnvironment env)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description TaddTags(Collection<String> tags)Adds the specified tags to the newly created data object.TaddTypes(Collection<String> types)Adds the specified types to the newly created data object.abstract Ubuild()Creates the new data object.protected voidcheckAndFixParameters()Ensures that the project was either explicitly set or that the environment specifies a workspace.protected static StringgetNewObjectId(com.fasterxml.jackson.databind.JsonNode responseJson)Deserializes the response to a/class-xxxx/newAPI call and returns the ID of the newly created object.protected abstract TgetThisInstance()Returns the builder object.TputAllProperties(Map<String,String> properties)Sets the specified properties on the newly created data object.TputProperty(String key, String value)Sets the specified property on the newly created data object.TsetDetails(Object details)Sets the details of the data object to be created.TsetFolder(String folder)Sets the folder in which the data object will be created.TsetFolder(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.TsetName(String name)Sets the name of the newly created data object.TsetProject(DXContainer project)Sets the project or container where the new data object will be created.TsetVisibility(boolean visible)Sets the visibility of the new data object.
-
-
-
Field Detail
-
project
protected DXContainer project
-
name
protected String name
-
folder
protected String folder
-
createParents
protected Boolean createParents
-
details
protected com.fasterxml.jackson.databind.JsonNode details
-
hidden
protected Boolean hidden
-
env
protected final DXEnvironment env
-
-
Constructor Detail
-
Builder
protected Builder()
-
Builder
protected Builder(DXEnvironment env)
-
-
Method Detail
-
getNewObjectId
protected static String getNewObjectId(com.fasterxml.jackson.databind.JsonNode responseJson)
Deserializes the response to a/class-xxxx/newAPI 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
Builderobject
-
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
Builderobject
-
build
public abstract U build()
Creates the new data object.- Returns:
- a
DXDataObjectcorresponding 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
Builderobject
-
putProperty
public T putProperty(String key, String value)
Sets the specified property on the newly created data object.- Parameters:
key- property key to setvalue- property value to set- Returns:
- the same
Builderobject
-
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
Builderobject
-
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
Builderobject
-
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
Builderobject
-
setName
public T setName(String name)
Sets the name of the newly created data object.- Parameters:
name- name to set- Returns:
- the same
Builderobject
-
setProject
public T setProject(DXContainer project)
Sets the project or container where the new data object will be created.- Parameters:
project-DXProjectorDXContainer- Returns:
- the same
Builderobject
-
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
Builderobject
-
-