# WARNING - Generated by {fusen} from dev/flat_kwb_simulate_inflow.Rmd: do not edit by hand # nolint: line_length_linter.

#' Restore Object Attributes
#' 
#' Restore given attributes that are not object attributes any more
#' 
#' This function does the same thing as kwb.utils::catIf(),
#' but it is bundled with *ambre* to avoid a hard dependency on the 
#' unmaintained package.
#' 
#' @param x object
#' @param attribs former attributes of x (as retrieved by attributes(x)) to be
#'   restored
#' @references
#'   Sonnenberg H (2024). kwb.utils: General Utility Functions Developed at KWB. R package version 0.15.0
#'   URL: \url{https://github.com/kwb-r/kwb.utils}
#'   (MIT Licence)
#' @noRd
#' 
#' @examples
#' # Example usage of hsRestoreAttributes
#' x <- 1:5
#' attr(x, "my_attr") <- "test attribute"
#' attr(x, "another_attr") <- 123
#'
#' # Remove an attribute
#' attr(x, "my_attr") <- NULL
#'
#' # Restore the original attributes
#' original_attrs <- list(my_attr = "test attribute", another_attr = 123)
#' x_restored <- hsRestoreAttributes(x, original_attrs)
#'
#' # Print results
#' print("Original object with attributes:")
#' print(attributes(x))
#'
#' print("Restored object with attributes:")
#' print(attributes(x_restored))
hsRestoreAttributes <- function(x, attribs)
{
  for (attrib in setdiff(names(attribs), names(attributes(x)))) {
    
    attr(x, attrib) <- attribs[[attrib]]
  }
  
  x
}
