R/value_type.R

# FireCloud
#
# FireCloud API 
#
# The version of the OpenAPI document: 0.1
# 
# Generated by: https://openapi-generator.tech

#' @docType class
#' @title ValueType
#'
#' @description ValueType Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field typeName  character [optional]
#'
#' @field optionalType  \link{ValueType} [optional]
#'
#' @field arrayType  \link{ValueType} [optional]
#'
#' @field mapType  \link{MapValueType} [optional]
#'
#' @field tupleTypes  list( \link{ValueType} ) [optional]
#'
#' @field objectFieldTypes  list( \link{ValueTypeObjectFieldTypes} ) [optional]
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
ValueType <- R6::R6Class(
  'ValueType',
  public = list(
    `typeName` = NULL,
    `optionalType` = NULL,
    `arrayType` = NULL,
    `mapType` = NULL,
    `tupleTypes` = NULL,
    `objectFieldTypes` = NULL,
    initialize = function(
        `typeName`=NULL, `optionalType`=NULL, `arrayType`=NULL, `mapType`=NULL, `tupleTypes`=NULL, `objectFieldTypes`=NULL, ...
    ) {
      local.optional.var <- list(...)
      if (!is.null(`typeName`)) {
        stopifnot(is.character(`typeName`), length(`typeName`) == 1)
        self$`typeName` <- `typeName`
      }
      if (!is.null(`optionalType`)) {
        stopifnot(R6::is.R6(`optionalType`))
        self$`optionalType` <- `optionalType`
      }
      if (!is.null(`arrayType`)) {
        stopifnot(R6::is.R6(`arrayType`))
        self$`arrayType` <- `arrayType`
      }
      if (!is.null(`mapType`)) {
        stopifnot(R6::is.R6(`mapType`))
        self$`mapType` <- `mapType`
      }
      if (!is.null(`tupleTypes`)) {
        stopifnot(is.vector(`tupleTypes`), length(`tupleTypes`) != 0)
        sapply(`tupleTypes`, function(x) stopifnot(R6::is.R6(x)))
        self$`tupleTypes` <- `tupleTypes`
      }
      if (!is.null(`objectFieldTypes`)) {
        stopifnot(is.vector(`objectFieldTypes`), length(`objectFieldTypes`) != 0)
        sapply(`objectFieldTypes`, function(x) stopifnot(R6::is.R6(x)))
        self$`objectFieldTypes` <- `objectFieldTypes`
      }
    },
    toJSON = function() {
      ValueTypeObject <- list()
      if (!is.null(self$`typeName`)) {
        ValueTypeObject[['typeName']] <-
          self$`typeName`
      }
      if (!is.null(self$`optionalType`)) {
        ValueTypeObject[['optionalType']] <-
          self$`optionalType`$toJSON()
      }
      if (!is.null(self$`arrayType`)) {
        ValueTypeObject[['arrayType']] <-
          self$`arrayType`$toJSON()
      }
      if (!is.null(self$`mapType`)) {
        ValueTypeObject[['mapType']] <-
          self$`mapType`$toJSON()
      }
      if (!is.null(self$`tupleTypes`)) {
        ValueTypeObject[['tupleTypes']] <-
          lapply(self$`tupleTypes`, function(x) x$toJSON())
      }
      if (!is.null(self$`objectFieldTypes`)) {
        ValueTypeObject[['objectFieldTypes']] <-
          lapply(self$`objectFieldTypes`, function(x) x$toJSON())
      }

      ValueTypeObject
    },
    fromJSON = function(ValueTypeJson) {
      ValueTypeObject <- jsonlite::fromJSON(ValueTypeJson)
      if (!is.null(ValueTypeObject$`typeName`)) {
        self$`typeName` <- ValueTypeObject$`typeName`
      }
      if (!is.null(ValueTypeObject$`optionalType`)) {
        optionalTypeObject <- ValueType$new()
        optionalTypeObject$fromJSON(jsonlite::toJSON(ValueTypeObject$optionalType, auto_unbox = TRUE, digits = NA))
        self$`optionalType` <- optionalTypeObject
      }
      if (!is.null(ValueTypeObject$`arrayType`)) {
        arrayTypeObject <- ValueType$new()
        arrayTypeObject$fromJSON(jsonlite::toJSON(ValueTypeObject$arrayType, auto_unbox = TRUE, digits = NA))
        self$`arrayType` <- arrayTypeObject
      }
      if (!is.null(ValueTypeObject$`mapType`)) {
        mapTypeObject <- MapValueType$new()
        mapTypeObject$fromJSON(jsonlite::toJSON(ValueTypeObject$mapType, auto_unbox = TRUE, digits = NA))
        self$`mapType` <- mapTypeObject
      }
      if (!is.null(ValueTypeObject$`tupleTypes`)) {
        self$`tupleTypes` <- ApiClient$new()$deserializeObj(ValueTypeObject$`tupleTypes`, "array[ValueType]", loadNamespace("openapi"))
      }
      if (!is.null(ValueTypeObject$`objectFieldTypes`)) {
        self$`objectFieldTypes` <- ApiClient$new()$deserializeObj(ValueTypeObject$`objectFieldTypes`, "array[ValueTypeObjectFieldTypes]", loadNamespace("openapi"))
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`typeName`)) {
        sprintf(
        '"typeName":
          "%s"
                ',
        self$`typeName`
        )},
        if (!is.null(self$`optionalType`)) {
        sprintf(
        '"optionalType":
        %s
        ',
        jsonlite::toJSON(self$`optionalType`$toJSON(), auto_unbox=TRUE, digits = NA)
        )},
        if (!is.null(self$`arrayType`)) {
        sprintf(
        '"arrayType":
        %s
        ',
        jsonlite::toJSON(self$`arrayType`$toJSON(), auto_unbox=TRUE, digits = NA)
        )},
        if (!is.null(self$`mapType`)) {
        sprintf(
        '"mapType":
        %s
        ',
        jsonlite::toJSON(self$`mapType`$toJSON(), auto_unbox=TRUE, digits = NA)
        )},
        if (!is.null(self$`tupleTypes`)) {
        sprintf(
        '"tupleTypes":
        [%s]
',
        paste(sapply(self$`tupleTypes`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE, digits = NA)), collapse=",")
        )},
        if (!is.null(self$`objectFieldTypes`)) {
        sprintf(
        '"objectFieldTypes":
        [%s]
',
        paste(sapply(self$`objectFieldTypes`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE, digits = NA)), collapse=",")
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(ValueTypeJson) {
      ValueTypeObject <- jsonlite::fromJSON(ValueTypeJson)
      self$`typeName` <- ValueTypeObject$`typeName`
      self$`optionalType` <- ValueType$new()$fromJSON(jsonlite::toJSON(ValueTypeObject$optionalType, auto_unbox = TRUE, digits = NA))
      self$`arrayType` <- ValueType$new()$fromJSON(jsonlite::toJSON(ValueTypeObject$arrayType, auto_unbox = TRUE, digits = NA))
      self$`mapType` <- MapValueType$new()$fromJSON(jsonlite::toJSON(ValueTypeObject$mapType, auto_unbox = TRUE, digits = NA))
      self$`tupleTypes` <- ApiClient$new()$deserializeObj(ValueTypeObject$`tupleTypes`, "array[ValueType]", loadNamespace("openapi"))
      self$`objectFieldTypes` <- ApiClient$new()$deserializeObj(ValueTypeObject$`objectFieldTypes`, "array[ValueTypeObjectFieldTypes]", loadNamespace("openapi"))
      self
    }
  )
)
vjcitn/terraClientR documentation built on Dec. 23, 2021, 4:07 p.m.