com.javonet.core.handler.AbstractHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javonet-java-sdk Show documentation
Show all versions of javonet-java-sdk Show documentation
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/
package com.javonet.core.handler;
import com.javonet.utils.Command;
import com.javonet.utils.CommandType;
import java.util.Map;
public abstract class AbstractHandler {
private final static Map HANDLER_MAP = new Handler().HANDLERS;
abstract Object process(Command command) throws Exception;
public Object handleCommand(Command command) throws Exception {
if (CommandType.GENERATE_LIB == command.getCommandType()) {
return this.process(command);
} else {
this.iterate(command);
return this.process(command);
}
}
void iterate(Command command) throws Exception {
for (int i = 0; i < command.getPayload().length; i++) {
if (command.getPayload()[i].getClass() == Command.class) {
Command innerCommand = (Command) command.getPayload()[i];
command.getPayload()[i] = HANDLER_MAP.get(innerCommand.getCommandType()).handleCommand(innerCommand);
}
}
}
}