R/OntologyReference.r

# OpenSilex API
#
# No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
#
# OpenAPI spec version: 1.0.0-rc+2
# 
# Generated by: https://github.com/swagger-api/swagger-codegen.git


#' OntologyReference Class
#'
#' @field documentationLinks 
#' @field ontologyDbId 
#' @field ontologyName 
#' @field version 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
OntologyReference <- R6::R6Class(
  'OntologyReference',
  public = list(
    `documentationLinks` = NULL,
    `ontologyDbId` = NULL,
    `ontologyName` = NULL,
    `version` = NULL,
    initialize = function(`documentationLinks`, `ontologyDbId`, `ontologyName`, `version`){
      if (!missing(`documentationLinks`)) {
        stopifnot(is.list(`documentationLinks`), length(`documentationLinks`) != 0)
        lapply(`documentationLinks`, function(x) stopifnot(R6::is.R6(x)))
        self$`documentationLinks` <- `documentationLinks`
      }
      if (!missing(`ontologyDbId`)) {
        stopifnot(is.character(`ontologyDbId`), length(`ontologyDbId`) == 1)
        self$`ontologyDbId` <- `ontologyDbId`
      }
      if (!missing(`ontologyName`)) {
        stopifnot(is.character(`ontologyName`), length(`ontologyName`) == 1)
        self$`ontologyName` <- `ontologyName`
      }
      if (!missing(`version`)) {
        stopifnot(is.character(`version`), length(`version`) == 1)
        self$`version` <- `version`
      }
    },
    toJSON = function() {
      OntologyReferenceObject <- list()
      if (!is.null(self$`documentationLinks`)) {
        OntologyReferenceObject[['documentationLinks']] <- lapply(self$`documentationLinks`, function(x) x$toJSON())
      }
      if (!is.null(self$`ontologyDbId`)) {
        OntologyReferenceObject[['ontologyDbId']] <- self$`ontologyDbId`
      }
      if (!is.null(self$`ontologyName`)) {
        OntologyReferenceObject[['ontologyName']] <- self$`ontologyName`
      }
      if (!is.null(self$`version`)) {
        OntologyReferenceObject[['version']] <- self$`version`
      }

      OntologyReferenceObject
    },
    fromJSON = function(OntologyReferenceJson) {
      OntologyReferenceObject <- jsonlite::fromJSON(OntologyReferenceJson)
      if (!is.null(OntologyReferenceObject$`documentationLinks`)) {
        self$`documentationLinks` <- lapply(OntologyReferenceObject$`documentationLinks`, function(x) {
          documentationLinksObject <- DocumentationLink$new()
          documentationLinksObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE, null = "null"))
          documentationLinksObject
        })
      }
      if (!is.null(OntologyReferenceObject$`ontologyDbId`)) {
        self$`ontologyDbId` <- OntologyReferenceObject$`ontologyDbId`
      }
      if (!is.null(OntologyReferenceObject$`ontologyName`)) {
        self$`ontologyName` <- OntologyReferenceObject$`ontologyName`
      }
      if (!is.null(OntologyReferenceObject$`version`)) {
        self$`version` <- OntologyReferenceObject$`version`
      }
    },
    fromJSONObject = function(OntologyReferenceObject) {
      if (!is.null(OntologyReferenceObject$`documentationLinks`)) {
        self$`documentationLinks` <- lapply(OntologyReferenceObject$`documentationLinks`, function(x) {
          documentationLinksObject <- DocumentationLink$new()
          documentationLinksObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE, null = "null"))
          documentationLinksObject
        })
      }
      if (!is.null(OntologyReferenceObject$`ontologyDbId`)) {
        self$`ontologyDbId` <- OntologyReferenceObject$`ontologyDbId`
      }
      if (!is.null(OntologyReferenceObject$`ontologyName`)) {
        self$`ontologyName` <- OntologyReferenceObject$`ontologyName`
      }
      if (!is.null(OntologyReferenceObject$`version`)) {
        self$`version` <- OntologyReferenceObject$`version`
      }
    },
    toJSONString = function() {
      documentationLinksList = paste(lapply(self$`documentationLinks`, function(x) x$toJSONString()),collapse = ",")
       sprintf(
        '{
           "documentationLinks": [%s],
           "ontologyDbId": %s,
           "ontologyName": %s,
           "version": %s
        }',
        documentationLinksList,
        ifelse(is.null(self$`ontologyDbId`), "null",jsonlite::toJSON(self$`ontologyDbId`,auto_unbox=TRUE, null = "null")),
        ifelse(is.null(self$`ontologyName`), "null",jsonlite::toJSON(self$`ontologyName`,auto_unbox=TRUE, null = "null")),
        ifelse(is.null(self$`version`), "null",jsonlite::toJSON(self$`version`,auto_unbox=TRUE, null = "null"))
      )
    },
    fromJSONString = function(OntologyReferenceJson) {
      OntologyReferenceObject <- jsonlite::fromJSON(OntologyReferenceJson)
      self$`documentationLinks` <- lapply(OntologyReferenceObject$`documentationLinks`, function(x) DocumentationLink$new()$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE)))
      self$`ontologyDbId` <- OntologyReferenceObject$`ontologyDbId`
      self$`ontologyName` <- OntologyReferenceObject$`ontologyName`
      self$`version` <- OntologyReferenceObject$`version`
    }
  )
)
OpenSILEX/opensilexClientToolsR documentation built on Jan. 28, 2022, 5:03 a.m.