R/validation_message.R

# mzTab-M reference implementation and validation API.
#
# This is the mzTab-M reference implementation and validation API service.
#
# The version of the OpenAPI document: 2.0.0
# Contact: nils.hoffmann@cebitec.uni-bielefeld.de
# Generated by: https://openapi-generator.tech

#' @docType class
#' @title ValidationMessage
#' @description ValidationMessage Class
#' @format An \code{R6Class} generator object
#' @field code  character 
#'
#' @field category  character 
#'
#' @field message_type  character [optional]
#'
#' @field message  character 
#'
#' @field line_number  integer [optional]
#'
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
ValidationMessage <- R6::R6Class(
  'ValidationMessage',
  public = list(
    `code` = NULL,
    `category` = NULL,
    `message_type` = NULL,
    `message` = NULL,
    `line_number` = NULL,
    #' @description Create a new ValidationMessage object.
    #' @param code The message code.
    #' @param category The message category.
    #' @param message The message content.
    #' @param message_type The message type.
    #' @param line_number The line number in the mzTab-M file to which this message refers to.
    #' @param ... local optional variable arguments
    initialize = function(`code`, `category`, `message`, `message_type`='info', `line_number`=NULL, ...){
      local.optional.var <- list(...)
      if (!missing(`code`)) {
        stopifnot(is.character(`code`), length(`code`) == 1)
        self$`code` <- `code`
      }
      if (!missing(`category`)) {
        stopifnot(is.character(`category`), length(`category`) == 1)
        self$`category` <- `category`
      }
      if (!missing(`message`)) {
        stopifnot(is.character(`message`), length(`message`) == 1)
        self$`message` <- `message`
      }
      if (!is.null(`message_type`)) {
        stopifnot(is.character(`message_type`), length(`message_type`) == 1)
        self$`message_type` <- `message_type`
      }
      if (!is.null(`line_number`)) {
        stopifnot(is.numeric(`line_number`), length(`line_number`) == 1)
        self$`line_number` <- `line_number`
      }
    },
    #' @description Serialize to list object suitable for jsonlite
    toJSON = function() {
      ValidationMessageObject <- list()
      if (!is.null(self$`code`)) {
        ValidationMessageObject[['code']] <-
          rmzTabM::safe_unbox(self$`code`)
      }
      if (!is.null(self$`category`)) {
        ValidationMessageObject[['category']] <-
          rmzTabM::safe_unbox(self$`category`)
      }
      if (!is.null(self$`message_type`)) {
        ValidationMessageObject[['message_type']] <-
          rmzTabM::safe_unbox(self$`message_type`)
      }
      if (!is.null(self$`message`)) {
        ValidationMessageObject[['message']] <-
          rmzTabM::safe_unbox(self$`message`)
      }
      if (!is.null(self$`line_number`)) {
        ValidationMessageObject[['line_number']] <-
          rmzTabM::safe_unbox(self$`line_number`)
      }

      ValidationMessageObject
    },
    #' @description Deserialize from jsonlite list object
    #' @param ValidationMessageJson list object.    
    fromJSON = function(ValidationMessageJson) {
      ValidationMessageObject <- jsonlite::fromJSON(ValidationMessageJson)
      if (!is.null(ValidationMessageObject$`code`)) {
        self$`code` <- ValidationMessageObject$`code`
      }
      if (!is.null(ValidationMessageObject$`category`)) {
        self$`category` <- ValidationMessageObject$`category`
      }
      if (!is.null(ValidationMessageObject$`message_type`)) {
        self$`message_type` <- ValidationMessageObject$`message_type`
      }
      if (!is.null(ValidationMessageObject$`message`)) {
        self$`message` <- ValidationMessageObject$`message`
      }
      if (!is.null(ValidationMessageObject$`line_number`)) {
        self$`line_number` <- ValidationMessageObject$`line_number`
      }
    },
    #' @description Serialize to JSON string.    
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`code`)) {
        sprintf(
        '"code":
          "%s"
                ',
        rmzTabM::safe_unbox(self$`code`)
        )},
        if (!is.null(self$`category`)) {
        sprintf(
        '"category":
          "%s"
                ',
        rmzTabM::safe_unbox(self$`category`)
        )},
        if (!is.null(self$`message_type`)) {
        sprintf(
        '"message_type":
          "%s"
                ',
        rmzTabM::safe_unbox(self$`message_type`)
        )},
        if (!is.null(self$`message`)) {
        sprintf(
        '"message":
          "%s"
                ',
        rmzTabM::safe_unbox(self$`message`)
        )},
        if (!is.null(self$`line_number`)) {
        sprintf(
        '"line_number":
          %d
                ',
        rmzTabM::safe_unbox(self$`line_number`)
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    #' @description Deserialize from JSON string
    #' @param ValidationMessageJson JSON string    
    fromJSONString = function(ValidationMessageJson) {
      ValidationMessageObject <- jsonlite::fromJSON(ValidationMessageJson)
      self$`code` <- ValidationMessageObject$`code`
      self$`category` <- ValidationMessageObject$`category`
      self$`message_type` <- ValidationMessageObject$`message_type`
      self$`message` <- ValidationMessageObject$`message`
      self$`line_number` <- ValidationMessageObject$`line_number`
      self
    }
  )
)
lifs-tools/rmzTab-m documentation built on Jan. 26, 2023, 4:45 p.m.