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

org.khasanof.executors.invoker.InvokerResultService Maven / Gradle / Ivy

There is a newer version: 1.2.2
Show newest version
package org.khasanof.executors.invoker;

import org.khasanof.enums.InvokerType;
import org.khasanof.model.InvokerMethod;
import org.khasanof.model.InvokerObject;
import org.khasanof.model.InvokerResult;
import org.khasanof.utils.MethodUtils;
import org.springframework.stereotype.Component;

import java.lang.reflect.Method;
import java.util.AbstractMap;
import java.util.Map;

/**
 * @author Nurislom
 * @see org.khasanof.executors.invoker
 * @since 8/20/2023 3:49 PM
 */
@Component
public class InvokerResultService {

    public Map.Entry getResultEntry(InvokerResult result) {
        if (result.getType().equals(InvokerType.CLASS)) {
            InvokerObject invokerObject = (InvokerObject) result;
            return new AbstractMap.SimpleEntry<>(MethodUtils.getClassMethodByName(invokerObject.getReference(),
                    invokerObject.getExecutionMethodName()), invokerObject.getReference());
        } else {
            InvokerMethod invokerMethod = (InvokerMethod) result;
            return new AbstractMap.SimpleEntry<>(invokerMethod.getMethod(), invokerMethod.getReference());
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy