R/filter.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 Filter
#'
#' @description Filter Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field type  \link{FilterType} 
#'
#' @field data  \link{FilterData} [optional]
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
Filter <- R6::R6Class(
  'Filter',
  public = list(
    `type` = NULL,
    `data` = NULL,
    initialize = function(
        `type`, `data`=NULL, ...
    ) {
      local.optional.var <- list(...)
      if (!missing(`type`)) {
        stopifnot(R6::is.R6(`type`))
        self$`type` <- `type`
      }
      if (!is.null(`data`)) {
        stopifnot(R6::is.R6(`data`))
        self$`data` <- `data`
      }
    },
    toJSON = function() {
      FilterObject <- list()
      if (!is.null(self$`type`)) {
        FilterObject[['type']] <-
          self$`type`$toJSON()
      }
      if (!is.null(self$`data`)) {
        FilterObject[['data']] <-
          self$`data`$toJSON()
      }

      FilterObject
    },
    fromJSON = function(FilterJson) {
      FilterObject <- jsonlite::fromJSON(FilterJson)
      if (!is.null(FilterObject$`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 <- FilterType$new()
        #typeObject$fromJSON(jsonlite::toJSON(FilterObject$type, auto_unbox = TRUE, digits = NA))
        typeObject <- FilterType$new(FilterObject$type)
        self$`type` <- typeObject
      }
      if (!is.null(FilterObject$`data`)) {
        dataObject <- FilterData$new()
        dataObject$fromJSON(jsonlite::toJSON(FilterObject$data, auto_unbox = TRUE, digits = NA))
        self$`data` <- dataObject
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`type`)) {
        sprintf(
        '"type":
        %s
        ',
        jsonlite::toJSON(self$`type`$toJSON(), auto_unbox=TRUE, digits = NA)
        )},
        if (!is.null(self$`data`)) {
        sprintf(
        '"data":
        %s
        ',
        jsonlite::toJSON(self$`data`$toJSON(), auto_unbox=TRUE, digits = NA)
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(FilterJson) {
      FilterObject <- jsonlite::fromJSON(FilterJson)
      self$`type` <- FilterType$new()$fromJSON(jsonlite::toJSON(FilterObject$type, auto_unbox = TRUE, digits = NA))
      self$`data` <- FilterData$new()$fromJSON(jsonlite::toJSON(FilterObject$data, auto_unbox = TRUE, digits = NA))
      self
    }
  )
)
eddelbuettel/tldbclr documentation built on Sept. 25, 2022, 12:46 p.m.