Giter Site home page Giter Site logo

static-methods-agg's Introduction

Static Methods Aggregator

Based on the historical Java Hamcrest Generator, re-packaged their legacy code here to help aggregate a list of classes' public static methods in a single Sugar class.

Example usage (find the releases in this repo, which includes the static-methods-agg.jar file):

# arguments:
#   1. the folder in which it will look recursively for java classes
#   2. the fully qualified name of the generated sugar class
#   3. the root folder of the java project in which the
#      generated sugar class will be generated
java -jar static-methods-agg.jar ~/myproject/src/test/java/org/example/mypackage org.example.GeneratedSugarClass ~/myproject/src/test/java

Example

Imagine having a list of Java classes like this

 org.example
 └── mypackage
     ├── Clazz1.java
     ├── Clazz2.java
     ├── Clazz3.java
     └── ...

In each of them, they are statically exposed methods and we don't wish you import them all.

This is where the sugar class comes in play. The generated class would then look like the following:

// Generated source.
package org.example;

public class GeneratedSugarClass {

    public static org.example.FullyQualifiedReturnedObject method1(/* list of args with fully qualified types */) {
        return org.example.mypackage.Clazz1.method1(/* delegate the arguments */);
    }

    public static org.example.FullyQualifiedReturnedObject method2(/* list of args with fully qualified types */) {
        return org.example.mypackage.Clazz1.method2(/* delegate the arguments */);
    }

    public static org.example.FullyQualifiedReturnedObject method3(/* list of args with fully qualified types */) {
        return org.example.mypackage.Clazz1.method3(/* delegate the arguments */);
    }

    public static org.example.OtherFullyQualifiedReturnedObject method1(/* list of args with fully qualified types */) {
        return org.example.mypackage.Clazz2.method1(/* delegate the arguments */);
    }

    // ...
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.