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

com.metaring.framework.auth.VerifyEnableFunctionality Maven / Gradle / Ivy

package com.metaring.framework.auth;

import java.util.concurrent.CompletableFuture;
import com.metaring.framework.functionality.AbstractFunctionality;
import com.metaring.framework.functionality.GeneratedFunctionality;
import com.metaring.framework.functionality.FunctionalityInfo;
import com.metaring.framework.auth.PreliminaryEnableData;

abstract class VerifyEnableFunctionality extends AbstractFunctionality implements GeneratedFunctionality {

    static final FunctionalityInfo INFO = FunctionalityInfo.create("com.metaring.framework.auth.verifyEnable", true, true, false, "com.metaring.framework.auth.PreliminaryEnableData", "java.lang.Boolean");

    static final VerifyEnableFunctionality INSTANCE = new VerifyEnableFunctionalityImpl();

    protected VerifyEnableFunctionality() {
        super(INFO, Boolean.class);
    }

    @Override
    protected final CompletableFuture beforePreConditionCheck(Object input) throws Exception {
        CompletableFuture response = beforePreConditionCheck(input == null ? null : (PreliminaryEnableData) input);
        return response == null ? end : response;
    }

    protected CompletableFuture beforePreConditionCheck(PreliminaryEnableData input) throws Exception {
        return end;
    }

    @Override
    protected final CompletableFuture preConditionCheck(Object input) throws Exception {
        CompletableFuture response = preConditionCheck(input == null ? null : (PreliminaryEnableData) input);
        return response == null ? end : response;
    }

    protected abstract CompletableFuture preConditionCheck(PreliminaryEnableData input) throws Exception;

    @Override
    protected final CompletableFuture afterPreConditionCheck(Object input) throws Exception {
        CompletableFuture response = afterPreConditionCheck(input == null ? null : (PreliminaryEnableData) input);
        return response == null ? end : response;
    }

    protected CompletableFuture afterPreConditionCheck(PreliminaryEnableData input) throws Exception {
        return end;
    }

    @Override
    protected final CompletableFuture beforeCall(Object input) throws Exception {
        CompletableFuture response = beforeCall(input == null ? null : (PreliminaryEnableData) input);
        return response == null ? end : response;
    }

    protected CompletableFuture beforeCall(PreliminaryEnableData input) throws Exception {
        return end;
    }

    @Override
    protected final CompletableFuture call(Object input) throws Exception {
        CompletableFuture call = call((PreliminaryEnableData) input);
        if(call == null) {
            return end(null);
        }
        final CompletableFuture response = new CompletableFuture<>();
        call.whenCompleteAsync((result, error) -> {
            if(error != null) {
                response.completeExceptionally(error);
                return;
            }
            response.complete(result);
        }, EXECUTOR);
        return response;
    }

    protected abstract CompletableFuture call(PreliminaryEnableData input) throws Exception;

    @Override
    protected final CompletableFuture afterCall(Object input, Object output) throws Exception {
        CompletableFuture response = afterCall(input == null ? null : (PreliminaryEnableData) input, output == null ? null : (Boolean) output);
        return response == null ? end : response;
    }

    protected CompletableFuture afterCall(PreliminaryEnableData input, Boolean output) throws Exception {
        return end;
    }

    @Override
    protected final CompletableFuture beforePostConditionCheck(Object input, Object output) throws Exception {
        CompletableFuture response = beforePostConditionCheck(input == null ? null : (PreliminaryEnableData) input, output == null ? null : (Boolean) output);
        return response == null ? end : response;
    }

    protected CompletableFuture beforePostConditionCheck(PreliminaryEnableData input, Boolean output) throws Exception {
        return end;
    }

    @Override
    protected final CompletableFuture postConditionCheck(Object input, Object output) throws Exception {
        CompletableFuture response = postConditionCheck(input == null ? null : (PreliminaryEnableData) input, output == null ? null : (Boolean) output);
        return response == null ? end : response;
    }

    protected abstract CompletableFuture postConditionCheck(PreliminaryEnableData input, Boolean output) throws Exception;

    @Override
    protected final CompletableFuture afterPostConditionCheck(Object input, Object output) throws Exception {
        CompletableFuture response = afterPostConditionCheck(input == null ? null : (PreliminaryEnableData) input, output == null ? null : (Boolean) output);
        return response == null ? end : response;
    }

    protected CompletableFuture afterPostConditionCheck(PreliminaryEnableData input, Boolean output) throws Exception {
        return end;
    }

    @Override
    protected final Object getInputFromJsonWork(String inputJson) {
        return PreliminaryEnableData.fromJson(inputJson);
    }
}