A test of the R6 generator templating

Version: 1.1.0

Generated: 2024-05-16T16:22:15.462768704

Arguments

logMessage

logMessage - a message which will be logged - (java expects a String)

Details

The feature test should allow mathjax in javadoc

$$e = mc^2$$

this is a details comment

Methods


Constructor new()

A maximum of one constructor of any signature can be used.

If different constructors are needed then they may be used but not included in the R Api (i.e. not annotated with @RMethod.)

Static factory methods can be used instead.

Usage


J = testRapi::JavaApi$get()
instance = J$FeatureTest$new(logMessage);
        

Arguments

logMessage - a message which will be logged

- (java expects a String)

Returns

the new R6 FeatureTest object

Examples


library(roxygen2)
library(devtools)
library(here)
library(tidyverse)
library(ggplot2)
library(readr)
library(dplyr)
library(tibble)
J = JavaApi$get()
minExample = J$FeatureTest$new('Hello from Java constructor!')
      


Method doHelloWorld()

A hello world function

More detailed description

Usage


J = testRapi::JavaApi$get()
instance = J$FeatureTest$new(logMessage);
instance$doHelloWorld()
        

Arguments

  • none

Returns

RCharacter: this java method returns a String

Examples


library(roxygen2)
library(devtools)
library(here)
library(tidyverse)
library(ggplot2)
library(readr)
library(dplyr)
library(tibble)
J = JavaApi$get()
minExample = J$FeatureTest$new('Hello, R World!')
minExample$doHelloWorld()
      


Method doSum()

Add some numbers (1).

The doSum function description = it adds two numerics

Usage


J = testRapi::JavaApi$get()
instance = J$FeatureTest$new(logMessage);
instance$doSum(a, b)
        

Arguments

a the A parameter, can be NA

- (java expects a RNumeric)

b the B parameter

- (java expects a RNumeric)

Returns

RNumeric: A+B of course, NAs in inputs are converted to null in Java. This catches the resulting NPE in java idiom and returns an explicit NA. This only matters if you care about the difference between NA_real_ and NaN in R.

Examples


library(roxygen2)
library(devtools)
library(here)
library(tidyverse)
library(ggplot2)
library(readr)
library(dplyr)
library(tibble)
J = JavaApi$get()
library(testthat)
minExample = J$FeatureTest$new('Hello from Java constructor!')
result = minExample$doSum(2,7.5)
testthat::expect_equal(result,9.5)
      


Method doSum2()

Adds some numbers

Do sum 2 uses native ints rather than RNumerics It should throw an error if given something that cannot be coerced to an integer. This also demonstrated the use of the `@RDefault` annotation

Usage


J = testRapi::JavaApi$get()
instance = J$FeatureTest$new(logMessage);
instance$doSum2(a, b)
        

Arguments

a the A parameter

- (java expects a int)

b the B parameter - (defaulting to `10`)

- (java expects a int)

Returns

int: A+B of course


Method getMessage()

Get the message

message desciption

Usage


J = testRapi::JavaApi$get()
instance = J$FeatureTest$new(logMessage);
instance$getMessage()
        

Arguments

  • none

Returns

RCharacter: The message (previously set by the constructor)


Method fluentSetMessage()

Set a message in a fluent way

A fluent method which updates the message in this object, returning the same object. This is differentiated from factory methods which produce a new instance of the same class by checking to see if the returned Java object is equal to the calling Java object.

Usage


J = testRapi::JavaApi$get()
instance = J$FeatureTest$new(logMessage);
instance$fluentSetMessage(message)
        

Arguments

message the message is a string - (defaulting to `\"hello\nworld\"`)

- (java expects a RCharacter)

Returns

R6 FeatureTest object: this should return exactly the same R6 object.


Method factoryMethod()

A factory or builder method which constructs an object of another class from some parameters

Usage


J = testRapi::JavaApi$get()
instance = J$FeatureTest$new(logMessage);
instance$factoryMethod(a, b)
        

Arguments

a the first parameter

- (java expects a RCharacter)

b the second parameter - (defaulting to `as.character(Sys.Date())`)

- (java expects a RCharacter)

Returns

R6 MoreFeatureTest object: A MoreFeatureTest R6 reference


Method objectAsParameter()

no title

Usage


J = testRapi::JavaApi$get()
instance = J$FeatureTest$new(logMessage);
instance$objectAsParameter(otherObj)
        

Arguments

otherObj

- (java expects a MoreFeatureTest)

Returns

String:


Method doSomethingWithDataFrame()

Consumes a data frame and logs its length

Usage


J = testRapi::JavaApi$get()
instance = J$FeatureTest$new(logMessage);
instance$doSomethingWithDataFrame(dataframe)
        

Arguments

dataframe a dataframe

- (java expects a RDataframe)

Returns

void:


Method generateDataFrame()

Creates a basic dataframe and returns it

Usage


J = testRapi::JavaApi$get()
instance = J$FeatureTest$new(logMessage);
instance$generateDataFrame()
        

Arguments

  • none

Returns

RDataframe: a daatframe


Method errorThrower()

Throws an error

Usage


J = testRapi::JavaApi$get()
instance = J$FeatureTest$new(logMessage);
instance$errorThrower()
        

Arguments

  • none

Returns

void:


Method asyncCountdown()

no title

Usage


J = testRapi::JavaApi$get()
instance = J$FeatureTest$new(logMessage);
instance$asyncCountdown()
        

Arguments

  • none

Returns

RCharacter:


Method asyncRaceCountdown()

no title

Usage


J = testRapi::JavaApi$get()
instance = J$FeatureTest$new(logMessage);
instance$asyncRaceCountdown()
        

Arguments

  • none

Returns

RCharacter:


Method blockingCountdown()

no title

Usage


J = testRapi::JavaApi$get()
instance = J$FeatureTest$new(logMessage);
instance$blockingCountdown()
        

Arguments

  • none

Returns

RCharacter:

Examples

## -----------------------------------
## Construct new instance of FeatureTest
## -----------------------------------
library(roxygen2)
library(devtools)
#> Loading required package: usethis
#> 
#> Attaching package: ‘devtools’
#> The following object is masked from ‘package:testRapi’:
#> 
#>     create
library(here)
#> here() starts at /home/vp22681/Dropbox/Git/r6-generator-docs
library(tidyverse)
#> ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
#>  dplyr     1.1.4      readr     2.1.5
#>  forcats   1.0.0      stringr   1.5.1
#>  ggplot2   3.5.1      tibble    3.2.1
#>  lubridate 1.9.3      tidyr     1.3.1
#>  purrr     1.0.2     
#> ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
#>  dplyr::filter() masks stats::filter()
#>  dplyr::lag()    masks stats::lag()
#>  Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(ggplot2)
library(readr)
library(dplyr)
library(tibble)
J = JavaApi$get()
#> Initialised testRapi
minExample = J$FeatureTest$new('Hello from Java constructor!')
#> Hello from Java constructor!

## -----------------------------------
## Method `FeatureTest$doHelloWorld()`
## -----------------------------------
library(roxygen2)
library(devtools)
library(here)
library(tidyverse)
library(ggplot2)
library(readr)
library(dplyr)
library(tibble)
J = JavaApi$get()
minExample = J$FeatureTest$new('Hello, R World!')
#> Hello, R World!
minExample$doHelloWorld()
#> [1] "Hello world from Java!"

## -----------------------------------
## Method `FeatureTest$doSum(a, b)`
## -----------------------------------
library(roxygen2)
library(devtools)
library(here)
library(tidyverse)
library(ggplot2)
library(readr)
library(dplyr)
library(tibble)
J = JavaApi$get()
library(testthat)
#> 
#> Attaching package: ‘testthat’
#> The following object is masked from ‘package:dplyr’:
#> 
#>     matches
#> The following object is masked from ‘package:purrr’:
#> 
#>     is_null
#> The following objects are masked from ‘package:readr’:
#> 
#>     edition_get, local_edition
#> The following object is masked from ‘package:tidyr’:
#> 
#>     matches
#> The following object is masked from ‘package:devtools’:
#> 
#>     test_file
minExample = J$FeatureTest$new('Hello from Java constructor!')
#> Hello from Java constructor!
result = minExample$doSum(2,7.5)
testthat::expect_equal(result,9.5)

## -----------------------------------
## Method `FeatureTest$doSum2(a, b)`
## -----------------------------------
if (FALSE) {
# appropriate parameter values must be provided
instance$doSum2(a, b)
}

## -----------------------------------
## Method `FeatureTest$getMessage()`
## -----------------------------------
if (FALSE) {
# appropriate parameter values must be provided
instance$getMessage()
}

## -----------------------------------
## Method `FeatureTest$fluentSetMessage(message)`
## -----------------------------------
if (FALSE) {
# appropriate parameter values must be provided
instance$fluentSetMessage(message)
}

## -----------------------------------
## Method `FeatureTest$factoryMethod(a, b)`
## -----------------------------------
if (FALSE) {
# appropriate parameter values must be provided
instance$factoryMethod(a, b)
}

## -----------------------------------
## Method `FeatureTest$objectAsParameter(otherObj)`
## -----------------------------------
if (FALSE) {
# appropriate parameter values must be provided
instance$objectAsParameter(otherObj)
}

## -----------------------------------
## Method `FeatureTest$doSomethingWithDataFrame(dataframe)`
## -----------------------------------
if (FALSE) {
# appropriate parameter values must be provided
instance$doSomethingWithDataFrame(dataframe)
}

## -----------------------------------
## Method `FeatureTest$generateDataFrame()`
## -----------------------------------
if (FALSE) {
# appropriate parameter values must be provided
instance$generateDataFrame()
}

## -----------------------------------
## Method `FeatureTest$errorThrower()`
## -----------------------------------
if (FALSE) {
# appropriate parameter values must be provided
instance$errorThrower()
}

## -----------------------------------
## Method `FeatureTest$asyncCountdown()`
## -----------------------------------
if (FALSE) {
# appropriate parameter values must be provided
instance$asyncCountdown()
}

## -----------------------------------
## Method `FeatureTest$asyncRaceCountdown()`
## -----------------------------------
if (FALSE) {
# appropriate parameter values must be provided
instance$asyncRaceCountdown()
}

## -----------------------------------
## Method `FeatureTest$blockingCountdown()`
## -----------------------------------
if (FALSE) {
# appropriate parameter values must be provided
instance$blockingCountdown()
}