Annotation processor that generates a kotlin wrapper class for a java file, enabling named parameters for kotlin callers.

Related tags

Demo kwrapper
Overview

Problem:

class SomeJavaClass {

    void someReallyBigSignature(
        boolean someBool, String someString, boolean anotherArg, List<String> yetAnother, 
        int yetAnotherArg
    )
}
class SomeKotlinClass {
    fun doStuff() {
        SomeJavaClass().someReallyBigSignature(
            // --> NO NAMED PARAMS! 
        )
    }
}

Dream:

class SomeKotlinClass {
    fun doStuff() {
        SomeJavaClass().KWrapper.someReallyBigSignature(
            someBool = true,
            someString = "pizza", 
            anotherArg = true,
            yetAnother = listOf("pizza"),
            yetAnotherArg = 42
        )
    }
}

Experiment so far generates from this java file (annotated with @KWrapper)...

testFoo) { return "top funky"; } } ">
@KWrapper
public class TestJavaClass {

    void someMethod(String argOne, String argTwo, Boolean mySweetBool) {
        System.out.println(argOne + argTwo);
    }

    List<String> realKewlMethod(double doubleTrouble, String nameOfPet, List<String> cigarTypes) {
        return Arrays.asList("pizza", "pasta");
    }

    String genericsAreCoolToo(List<String> testFoo) {
        return "top funky";
    }

}

...the following kotlin output:

@JvmInline
public value class TestJavaClassKWrapper(
    private val wrappee: TestJavaClass
) {
    public fun someMethod(
        argOne: String,
        argTwo: String,
        mySweetBool: Boolean
    ): Unit = wrappee.someMethod(argOne, argTwo, mySweetBool)

    public fun realKewlMethod(
        doubleTrouble: Double,
        nameOfPet: String,
        cigarTypes: List<String>
    ): List<String> = wrappee.realKewlMethod(doubleTrouble, nameOfPet, cigarTypes)

    public fun genericsAreCoolToo(testFoo: List<String>): String = wrappee.genericsAreCoolToo(testFoo)
}

public val TestJavaClass.KWrapper: TestJavaClassKWrapper
    get() = TestJavaClassKWrapper(this)

Which can now be used as:

fun main() {
    TestJavaClassKWrapper.KWrapper.realKewlMethod(
        testFoo = listOf("oh yeah!")
    )
}
You might also like...
Demo Android application using Gradle. Project is written entirely in Kotlin with MVVM architecture
Demo Android application using Gradle. Project is written entirely in Kotlin with MVVM architecture

Demo Android application using Gradle. Project is written entirely in Kotlin with MVVM architecture, Dagger / Hilt Dependency Injection, Room Database and Retrofit API Calls

A Kotlin compiler plugin that allows Java callers to pass in null for default parameters

kotlin-null-defaults (Compiler plugin) (Gradle Plugin) ( Currently pending approval) A Kotlin compiler plugin that allows Java callers to pass in null

Annotation Processing Library. Generates proxy class on top of interface/abstract class, that allows to intercept calls. Also known as a design pattern: proxy, delegate, interceptor.
Annotation Processing Library. Generates proxy class on top of interface/abstract class, that allows to intercept calls. Also known as a design pattern: proxy, delegate, interceptor.

1. AutoProxy Annotation Processing Library. Generates proxy class on top of interface/abstract class, that allows to intercept calls. Also known as a

Android Annotation Processor library to generate adapter class easily from your model with a lot of customization
Android Annotation Processor library to generate adapter class easily from your model with a lot of customization

Android Annotation Processing Library to generate your adapters only with Annotations on your model, support working with Kapt and KSP Processors

Android Studio plugin which automatically generates drawable selectors from appropriately named resources.
Android Studio plugin which automatically generates drawable selectors from appropriately named resources.

SelectorChapek for Android This Android Studio plugin automatically generates drawable selectors from appropriately named Android resources. How to in

Automatically generates UI demos which allow users to call any function with any parameters
Automatically generates UI demos which allow users to call any function with any parameters

Automatically generates UI demos which allow users to call any function (including composable ones) with any parameters. Useful for building demo screens in playground apps of various design systems.

Annotation Processor for generating Parcelable code
Annotation Processor for generating Parcelable code

ParcelablePlease An AnnotationProcessor for generating Android Parcelable boilerplate code. See this blog entry for comparison with other parcel libra

This library provides advance views for lists and stacks. Some of the views are build on top of RecyclerView and others are written in their own. Annotations are compiled by annotation processor to generate bind classes. DOCS -->
This library provides advance views for lists and stacks. Some of the views are build on top of RecyclerView and others are written in their own. Annotations are compiled by annotation processor to generate bind classes. DOCS --

PlaceHolderView An advance view for lists and stacks Some Implementations Documentation You can find the PlaceHolderView documentation here which has

🔦 Showkase is an annotation-processor based Android library that helps you organize, discover, search and visualize Jetpack Compose UI elements
🔦 Showkase is an annotation-processor based Android library that helps you organize, discover, search and visualize Jetpack Compose UI elements

Showkase is an annotation-processor based Android library that helps you organize, discover, search and visualize Jetpack Compose UI elements. With minimal configuration it generates a UI browser that helps you easily find your components, colors & typography. It also renders your components in common situations like dark mode, right-to-left layouts, and scaled fonts which help in finding issues early.

KSP annotation processor for Toothpick

toothpick-ksp KSP annotation processor for Toothpick. All credits go to olivierperez/ksp for the initial work on a KSP processor. Bear in mind this is

Annotation processor that provides better navigation on android multi-modules projects 🛳.
Annotation processor that provides better navigation on android multi-modules projects 🛳.

FlowNav FlowNav is a mobile library for Android that helps and provider a better way to make multi-modules navigation. The main purpose of this librar

An annotation processor library that automatically creates Hilt's `@Binds` functions and modules.
An annotation processor library that automatically creates Hilt's `@Binds` functions and modules.

HiltBinder An annotation processor library that automatically creates Hilt's @Binds functions and modules. If you think this library is useful, please

KSP-based library that generates lists from your annotation usages

ListGen, Generate Lists From Functions That Have @Listed Annotations! Welcome to ListGen! ListGen is a KSP-based library that can generate lists (and

Block unknown callers with this call screening service.
Block unknown callers with this call screening service.

Silence Block unknown callers with this call screening service. By default numbers not in your contact list are blocked. Optionally allow: Numbers you

Stetho is a debug bridge for Android applications, enabling the powerful Chrome Developer Tools and much more.

Stetho Stetho is a sophisticated debug bridge for Android applications. When enabled, developers have access to the Chrome Developer Tools feature nat

A Jetpack Compose modifier enabling reordering in a LazyList.
A Jetpack Compose modifier enabling reordering in a LazyList.

Compose LazyList reorder A Jetpack Compose modifier enabling reordering in a LazyList. Download repositories { maven { setUrl("https://jitpack.io"

The SSI Kit is a technology stack for enabling Self-Sovereign Identity (SSI) in any application.

Walt.ID SSI Kit The Walt.ID SSI Kit is a holistic SSI solution, with primarily focus on the European EBSI/ESSIF ecosystem. The core services are in th

Wynncraft API Wrapper - Simple wrapper to get Wynncraft Stats of a player or a guild and more in Java

WynncraftAPIWrapper Simple wrapper to get Wynncraft Stats of a player or a guild

Kotlin extension function provides a facility to "add" methods to class without inheriting a class or using any type of design pattern

What is Kotlin Extension Function ? Kotlin extension function provides a facility to "add" methods to class without inheriting a class or using any ty

Owner
Josh Skeen
Android @ Square
Josh Skeen
A sample Grocery Store app built using the Room, MVVM, Live Data, Rx Java, Dependency Injection (Kotlin Injection) and support Dark Mode

Apps Intro A sample Grocery Store app built using the Room, MVVM, Live Data, Rx Java, Dependency Injection (Kotlin Injection) and support Dark Mode In

Irsyad Abdillah 25 Dec 9, 2022
Quality-Tools-for-Android 7.5 0.0 L5 Java This is an Android sample app + tests that will be used to work on various project to increase the quality of the Android platform.

Quality Tools for Android This is an Android sample app + tests that will be used to work on various project to increase the quality of the Android pl

Stéphane Nicolas 1.3k Dec 27, 2022
PlayPauseDrawable 1.9 0.0 L5 Java This is a sample Play & Pause Drawable with morphing animation for Android

#PlayPauseDrawable #Deprecated please go to https://github.com/tarek360/Material-Animation-Samples This is a sample Play & Pause Drawable with morphin

Ahmed Tarek 48 May 26, 2022
📚 Sample Android Components Architecture on a modular word focused on the scalability, testability and maintainability written in Kotlin, following best practices using Jetpack.

Android Components Architecture in a Modular Word Android Components Architecture in a Modular Word is a sample project that presents modern, 2020 app

Madalin Valceleanu 2.3k Dec 30, 2022
learn MVVM & Android Jetpack in Kotlin

MVVM & Android Jetpack MVVM in Android Kotlin Android Jetpack in Kotlin List of tutorials DataBinding : Step 1 mvvm DataBinding : Step 2 mvvm Lifecycl

Alireza 5 Feb 25, 2022
Android sample app following best practices: Kotlin, Compose, Coroutines and Flow, Hilt, JetPack Navigation, ViewModel, MVVM and MVI, Retrofit, Coil

Foodies - Modern Android Architecture Foodies is a sample project that presents a modern 2021 approach to Android app development. The project tries t

null 362 Jan 2, 2023
simple android grocery app using kotlin and android studio

Project Idea The idea of this project is to make a grocery android app that users can use to order the groceries they want. It doesn't contain any bac

null 0 Nov 29, 2021
Kotlin Tutorials for new learners.

Kotlin Programming Tutorial for Beginners Learn Kotlin Programming, its basics and Fundamentals from scratch. Topics to be covered Overview Course int

Baxtiyor Elboyev 8 Apr 21, 2022
Viacheslav Veselov 0 Jul 8, 2022
Created Classic TicTacToe using JavaFX & Kotlin

Tic Tac Toe Created Classic TicTacToe using JavaFX & Kotlin. Hope you all enjoy

Sharan Thakur 0 Dec 31, 2021