R/v1_categorical_field_detail.R

# HCA Matrix Service
#
# Human Cell Atlas Matrix Service API
#
# The version of the OpenAPI document: 1.0.0
# 
# Generated by: https://openapi-generator.tech

#' @docType class
#' @title V1CategoricalFieldDetail
#' @description V1CategoricalFieldDetail Class
#' @format An \code{R6Class} generator object
#' @field field_name   character  
#'
#' @field field_description   character  
#'
#' @field field_type   character  
#'
#' @field cell_counts    named list(integer)   
#'
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
V1CategoricalFieldDetail <- R6::R6Class(
  'V1CategoricalFieldDetail',
  public = list(
    `field_name` = NULL,
    `field_description` = NULL,
    `field_type` = NULL,
    `cell_counts` = NULL,
    initialize = function(`field_name`, `field_description`, `field_type`, `cell_counts`, ...){
      local.optional.var <- list(...)
      if (!missing(`field_name`)) {
        stopifnot(is.character(`field_name`), length(`field_name`) == 1)
        self$`field_name` <- `field_name`
      }
      if (!missing(`field_description`)) {
        stopifnot(is.character(`field_description`), length(`field_description`) == 1)
        self$`field_description` <- `field_description`
      }
      if (!missing(`field_type`)) {
        stopifnot(is.character(`field_type`), length(`field_type`) == 1)
        self$`field_type` <- `field_type`
      }
      if (!missing(`cell_counts`)) {
        stopifnot(is.vector(`cell_counts`), length(`cell_counts`) != 0)
        sapply(`cell_counts`, function(x) stopifnot(is.character(x)))
        self$`cell_counts` <- `cell_counts`
      }
    },
    toJSON = function() {
      V1CategoricalFieldDetailObject <- list()
      if (!is.null(self$`field_name`)) {
        V1CategoricalFieldDetailObject[['field_name']] <-
          self$`field_name`
      }
      if (!is.null(self$`field_description`)) {
        V1CategoricalFieldDetailObject[['field_description']] <-
          self$`field_description`
      }
      if (!is.null(self$`field_type`)) {
        V1CategoricalFieldDetailObject[['field_type']] <-
          self$`field_type`
      }
      if (!is.null(self$`cell_counts`)) {
        V1CategoricalFieldDetailObject[['cell_counts']] <-
          self$`cell_counts`
      }

      V1CategoricalFieldDetailObject
    },
    fromJSON = function(V1CategoricalFieldDetailJson) {
      V1CategoricalFieldDetailObject <- jsonlite::fromJSON(V1CategoricalFieldDetailJson)
      if (!is.null(V1CategoricalFieldDetailObject$`field_name`)) {
        self$`field_name` <- V1CategoricalFieldDetailObject$`field_name`
      }
      if (!is.null(V1CategoricalFieldDetailObject$`field_description`)) {
        self$`field_description` <- V1CategoricalFieldDetailObject$`field_description`
      }
      if (!is.null(V1CategoricalFieldDetailObject$`field_type`)) {
        self$`field_type` <- V1CategoricalFieldDetailObject$`field_type`
      }
      if (!is.null(V1CategoricalFieldDetailObject$`cell_counts`)) {
        self$`cell_counts` <- ApiClient$new()$deserializeObj(V1CategoricalFieldDetailObject$`cell_counts`, "map(integer)", "package:hcamatrixapi")
      }
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`field_name`)) {
        sprintf(
        '"field_name":
          "%s"
                ',
        self$`field_name`
        )},
        if (!is.null(self$`field_description`)) {
        sprintf(
        '"field_description":
          "%s"
                ',
        self$`field_description`
        )},
        if (!is.null(self$`field_type`)) {
        sprintf(
        '"field_type":
          "%s"
                ',
        self$`field_type`
        )},
        if (!is.null(self$`cell_counts`)) {
        sprintf(
        '"cell_counts":
          "%s"
        ',
        jsonlite::toJSON(lapply(self$`cell_counts`, function(x){ x }), auto_unbox = TRUE, digits=NA)
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(V1CategoricalFieldDetailJson) {
      V1CategoricalFieldDetailObject <- jsonlite::fromJSON(V1CategoricalFieldDetailJson)
      self$`field_name` <- V1CategoricalFieldDetailObject$`field_name`
      self$`field_description` <- V1CategoricalFieldDetailObject$`field_description`
      self$`field_type` <- V1CategoricalFieldDetailObject$`field_type`
      self$`cell_counts` <- ApiClient$new()$deserializeObj(V1CategoricalFieldDetailObject$`cell_counts`, "map(integer)","package:hcamatrixapi")
      self
    }
  )
)
Bioconductor/hcamatrixapi documentation built on Nov. 6, 2019, 12:10 a.m.