All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.javonet.utils.HandlerUtils Maven / Gradle / Ivy

Go to download

Javonet allows you to reference and use modules or packages written in (Java/Kotlin/Groovy/Clojure, C#/VB.NET, Ruby, Perl, Python, JavaScript/TypeScript) like they were created in your technology. It works on Linux/Windows and MacOS for applications created in JVM, CLR/Netcore, Perl, Python, Ruby, NodeJS, C++ or GoLang and gives you unparalleled freedom and flexibility with native performance in building your mixed-technologies products. Let it be accessing best AI or cryptography libraries, devices SDKs, legacy client modules, internal custom packages or anything from public repositories available on NPM, Nuget, PyPI, Maven/Gradle, RubyGems or GitHub. Get free from programming languages barriers today! For more information check out our guides at https://www.javonet.com/guides/v2/

There is a newer version: 2.4.5
Show newest version
package com.javonet.utils;

import org.jetbrains.annotations.NotNull;

import java.util.Arrays;

public class HandlerUtils {

    //This method is uboxing to primitive types
    @NotNull
    public static Class[] getArgumentTypes(Object[] arguments) {
        Object[] argumentTypesObject = Arrays.stream(arguments).map(Object::getClass).toArray();
        Class[] argumentTypes = new Class[argumentTypesObject.length];
        for (int i = 0; i < argumentTypesObject.length; i++) {
            Class classType = (Class) argumentTypesObject[i];
            switch (classType.getName()) {
                case "java.lang.Integer":
                    argumentTypes[i] = int.class;
                    break;
                case "java.lang.Double":
                    argumentTypes[i] = double.class;
                    break;
                case "java.lang.Float":
                    argumentTypes[i] = float.class;
                    break;
                case "java.lang.Short":
                    argumentTypes[i] = short.class;
                    break;
                case "java.lang.Long":
                    argumentTypes[i] = long.class;
                    break;
                case "java.lang.Boolean":
                    argumentTypes[i] = boolean.class;
                    break;
                case "java.lang.Byte":
                    argumentTypes[i] = byte.class;
                    break;
                case "java.lang.Character":
                    argumentTypes[i] = char.class;
                    break;
                default:
                    argumentTypes[i] = classType;
                    break;
            }
        }
        return argumentTypes;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy