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

org.jackstaff.grpc.Original Maven / Gradle / Ivy

Go to download

Jackstaff Grpc Core: A java RPC framework , gRPC based and compatible with gRPC

There is a newer version: 2.0.13
Show newest version
package org.jackstaff.grpc;

import java.util.Optional;
import java.util.function.Consumer;

/**
 * @author [email protected]
 */
@FunctionalInterface
public interface Original {

    T getOrigin();

    static  T from(Object source, Class clazz) {
        return Optional.ofNullable(source instanceof Original ? ((Original) source).getOrigin() : source).
                filter(clazz::isInstance).map(clazz::cast).orElse(null);
    }

    static  void accept(Object source, Class clazz, Consumer consumer) {
        Optional.ofNullable(from(source, clazz)).ifPresent(consumer);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy