R/dimension.R

# TileDB Storage Platform API
#
# TileDB Storage Platform REST API
#
# The version of the OpenAPI document: 2.2.19
# 
# Generated by: https://openapi-generator.tech

#' @docType class
#' @title Dimension
#'
#' @description Dimension Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field name  character [optional]
#'
#' @field type  \link{Datatype} 
#'
#' @field domain  \link{DomainArray} 
#'
#' @field nullTileExtent  character 
#'
#' @field tileExtent  \link{DimensionTileExtent} [optional]
#'
#' @field filterPipeline  \link{FilterPipeline} [optional]
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
Dimension <- R6::R6Class(
  'Dimension',
  public = list(
    `name` = NULL,
    `type` = NULL,
    `domain` = NULL,
    `nullTileExtent` = NULL,
    `tileExtent` = NULL,
    `filterPipeline` = NULL,
    initialize = function(
        `type`, `domain`, `nullTileExtent`, `name`=NULL, `tileExtent`=NULL, `filterPipeline`=NULL, ...
    ) {
      local.optional.var <- list(...)
      if (!missing(`type`)) {
        stopifnot(R6::is.R6(`type`))
        self$`type` <- `type`
      }
      if (!missing(`domain`)) {
        stopifnot(R6::is.R6(`domain`))
        self$`domain` <- `domain`
      }
      if (!missing(`nullTileExtent`)) {
        self$`nullTileExtent` <- `nullTileExtent`
      }
      if (!is.null(`name`)) {
        stopifnot(is.character(`name`), length(`name`) == 1)
        self$`name` <- `name`
      }
      if (!is.null(`tileExtent`)) {
        stopifnot(R6::is.R6(`tileExtent`))
        self$`tileExtent` <- `tileExtent`
      }
      if (!is.null(`filterPipeline`)) {
        stopifnot(R6::is.R6(`filterPipeline`))
        self$`filterPipeline` <- `filterPipeline`
      }
    },
    toJSON = function() {
      DimensionObject <- list()
      if (!is.null(self$`name`)) {
        DimensionObject[['name']] <-
          self$`name`
      }
      if (!is.null(self$`type`)) {
        DimensionObject[['type']] <-
          self$`type`$toJSON()
      }
      if (!is.null(self$`domain`)) {
        DimensionObject[['domain']] <-
          self$`domain`$toJSON()
      }
      if (!is.null(self$`nullTileExtent`)) {
        DimensionObject[['nullTileExtent']] <-
          self$`nullTileExtent`
      }
      if (!is.null(self$`tileExtent`)) {
        DimensionObject[['tileExtent']] <-
          self$`tileExtent`$toJSON()
      }
      if (!is.null(self$`filterPipeline`)) {
        DimensionObject[['filterPipeline']] <-
          self$`filterPipeline`$toJSON()
      }

      DimensionObject
    },
    fromJSON = function(DimensionJson) {
      DimensionObject <- jsonlite::fromJSON(DimensionJson)
      if (!is.null(DimensionObject$`name`)) {
        self$`name` <- DimensionObject$`name`
      }
      if (!is.null(DimensionObject$`type`)) {
        # MANUAL EDIT AFTER OPENAPI AUTOGEN
        # For enums, OpenAPI autogen (1) generates a constructor which requires being called
        # with one arguent; (2) generates callsites (such as here) that calls that constructor
        # with zero arguments.
        #
        #typeObject <- Datatype$new()
        #typeObject$fromJSON(jsonlite::toJSON(DimensionObject$type, auto_unbox = TRUE, digits = NA))
        typeObject <- Datatype$new(DimensionObject$type)
        self$`type` <- typeObject
      }
      if (!is.null(DimensionObject$`domain`)) {
        domainObject <- DomainArray$new()
        domainObject$fromJSON(jsonlite::toJSON(DimensionObject$domain, auto_unbox = TRUE, digits = NA))
        self$`domain` <- domainObject
      }
      if (!is.null(DimensionObject$`nullTileExtent`)) {
        self$`nullTileExtent` <- DimensionObject$`nullTileExtent`
      }
      if (!is.null(DimensionObject$`tileExtent`)) {
        tileExtentObject <- DimensionTileExtent$new()
        tileExtentObject$fromJSON(jsonlite::toJSON(DimensionObject$tileExtent, auto_unbox = TRUE, digits = NA))
        self$`tileExtent` <- tileExtentObject
      }
      if (!is.null(DimensionObject$`filterPipeline`)) {
        filterPipelineObject <- FilterPipeline$new()
        filterPipelineObject$fromJSON(jsonlite::toJSON(DimensionObject$filterPipeline, auto_unbox = TRUE, digits = NA))
        self$`filterPipeline` <- filterPipelineObject
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`name`)) {
        sprintf(
        '"name":
          "%s"
                ',
        self$`name`
        )},
        if (!is.null(self$`type`)) {
        sprintf(
        '"type":
        %s
        ',
        jsonlite::toJSON(self$`type`$toJSON(), auto_unbox=TRUE, digits = NA)
        )},
        if (!is.null(self$`domain`)) {
        sprintf(
        '"domain":
        %s
        ',
        jsonlite::toJSON(self$`domain`$toJSON(), auto_unbox=TRUE, digits = NA)
        )},
        if (!is.null(self$`nullTileExtent`)) {
        sprintf(
        '"nullTileExtent":
          "%s"
                ',
        self$`nullTileExtent`
        )},
        if (!is.null(self$`tileExtent`)) {
        sprintf(
        '"tileExtent":
        %s
        ',
        jsonlite::toJSON(self$`tileExtent`$toJSON(), auto_unbox=TRUE, digits = NA)
        )},
        if (!is.null(self$`filterPipeline`)) {
        sprintf(
        '"filterPipeline":
        %s
        ',
        jsonlite::toJSON(self$`filterPipeline`$toJSON(), auto_unbox=TRUE, digits = NA)
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(DimensionJson) {
      DimensionObject <- jsonlite::fromJSON(DimensionJson)
      self$`name` <- DimensionObject$`name`
      self$`type` <- Datatype$new()$fromJSON(jsonlite::toJSON(DimensionObject$type, auto_unbox = TRUE, digits = NA))
      self$`domain` <- DomainArray$new()$fromJSON(jsonlite::toJSON(DimensionObject$domain, auto_unbox = TRUE, digits = NA))
      self$`nullTileExtent` <- DimensionObject$`nullTileExtent`
      self$`tileExtent` <- DimensionTileExtent$new()$fromJSON(jsonlite::toJSON(DimensionObject$tileExtent, auto_unbox = TRUE, digits = NA))
      self$`filterPipeline` <- FilterPipeline$new()$fromJSON(jsonlite::toJSON(DimensionObject$filterPipeline, auto_unbox = TRUE, digits = NA))
      self
    }
  )
)
TileDB-Inc/TileDB-Cloud-R documentation built on July 18, 2024, 3:33 p.m.