# 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 Uri
#' @description Uri Class
#' @format An \code{R6Class} generator object
#' @field id integer [optional]
#'
#' @field value character [optional]
#'
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
Uri <- R6::R6Class(
'Uri',
public = list(
`id` = NULL,
`value` = NULL,
#' @description Create a URI
#' @param id URI id.
#' @param value The URI.
#' @param ... local optional variable arguments
#'
initialize = function(`id`=NULL, `value`=NULL, ...){
local.optional.var <- list(...)
if (!is.null(`id`)) {
stopifnot(is.numeric(`id`), length(`id`) == 1)
self$`id` <- `id`
}
if (!is.null(`value`)) {
stopifnot(is.character(`value`), length(`value`) == 1)
self$`value` <- `value`
}
},
#' @description Serialize to list object suitable for jsonlite
toJSON = function() {
UriObject <- list()
if (!is.null(self$`id`)) {
UriObject[['id']] <-
rmzTabM::safe_unbox(self$`id`)
}
if (!is.null(self$`value`)) {
UriObject[['value']] <-
rmzTabM::safe_unbox(self$`value`)
}
UriObject
},
#' @description Deserialize from jsonlite list object
#' @param UriJson list object.
fromJSON = function(UriJson) {
UriObject <- jsonlite::fromJSON(UriJson)
if (!is.null(UriObject$`id`)) {
self$`id` <- UriObject$`id`
}
if (!is.null(UriObject$`value`)) {
self$`value` <- UriObject$`value`
}
},
#' @description Serialize to JSON string.
toJSONString = function() {
jsoncontent <- c(
if (!is.null(self$`id`)) {
sprintf(
'"id":
%d
',
rmzTabM::safe_unbox(self$`id`)
)},
if (!is.null(self$`value`)) {
sprintf(
'"value":
"%s"
',
rmzTabM::safe_unbox(self$`value`)
)}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
paste('{', jsoncontent, '}', sep = "")
},
#' @description Deserialize from JSON string
#' @param UriJson JSON string
fromJSONString = function(UriJson) {
UriObject <- jsonlite::fromJSON(UriJson)
self$`id` <- UriObject$`id`
self$`value` <- UriObject$`value`
self
},
#' @description Serialize to data frame
#' @param type The prefix of the URI
toDataFrame = function(type="uri") {
idPrefix <- paste0(type, "[", self$`id`, "]")
elements <- data.frame(PREFIX=character(), KEY=character(), VALUE=character())
if (!is.null(self$`value`)) {
elements <-
rbind(elements,
list(
PREFIX = "MTD",
KEY = idPrefix,
VALUE = self$`value`
),
stringsAsFactors = FALSE)
}
},
#' @description Deserialize from assay data frame
#' @param UriDataFrame Uri data frame
fromDataFrame = function(UriDataFrame) {
stopifnot(nrow(UriDataFrame)==1)
if (rlang::has_name(UriDataFrame, "id")) {
self$`id` <- as.numeric(UriDataFrame$`id`)
}
if (rlang::has_name(UriDataFrame, "value")) {
self$`value` <- UriDataFrame$`value`
}
self
}
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.