The reason is because Java does not recognize the default parameter values of Kotlin functions and so they must be specified even if they are empty. To fix this we should use @JvmOverloads on all element constructor functions.
All constructor functions in this file should look something like this:
/** Creates a [BoolElement] that represents an Ion `bool`. */
@JvmOverloads
fun ionBool(
b: Boolean,
annotations: List<String>? = emptyList(),
metas: MetaContainer? = emptyMetaColntainer()
): BoolElement = BoolElementImpl(b, annotations, metas)
Usage from Java should be:
// no metas, no annotations
IntElement elem = Ion.ionInt(42);
// just annotations
IntElement elem = Ion.ionInt(42, Collections.singletonList("meaning_of_life"));
// just metas
Map<String, Object> metas = ...
IntElement elem = Ion.ionInt(42, metas);
Instantiating a single scalar element in Java looks like this, which is way too syntactically heavy:
The reason is because Java does not recognize the default parameter values of Kotlin functions and so they must be specified even if they are empty. To fix this we should use
@JvmOverloads
on all element constructor functions.All constructor functions in this file should look something like this:
Usage from Java should be:
Which is an significant improvement.