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

com.fluxtion.ext.streaming.api.WrapperBase Maven / Gradle / Ivy

There is a newer version: 2.10.50
Show newest version
/*
 * Copyright (c) 2020, V12 Technology Ltd.
 * All rights reserved.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the Server Side Public License, version 1,
 * as published by MongoDB, Inc.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * Server Side Public License for more details.
 *
 * You should have received a copy of the Server Side Public License
 * along with this program.  If not, see 
 * .
 */
package com.fluxtion.ext.streaming.api;

import com.fluxtion.api.partition.LambdaReflection;
import com.fluxtion.ext.streaming.api.stream.StreamOperator;

/**
 * TODO refactor to combine Wrapper
 * @author Greg Higgins [email protected]
 * @param  The wrapped type
 * @param  The type of the subclass that extends WrapperBase
 */
public interface WrapperBase> {

    /**
     * The wrapped node
     *
     *
     * @return the wrapped node
     */
    //TODO refactor to wrapped
    T event();

    /**
     * The type of the wrapped node
     *
     * @return wrapped node class
     */
    //TODO refactor to wrappedClass
    Class eventClass();

    /**
     *
     * @param 
     * @param prefix String prefix for the log message
     * @param supplier
     * @return The current node
     */
    default  R log(String prefix, LambdaReflection.SerializableFunction... supplier) {
        if(!prefix.contains("{}")){
            prefix += " {}";
        }
       StreamOperator.service().log(self(), prefix, supplier);
        return self();
    }
    
    default  R log(){
        return log("");
    }

    default R self() {
        return (R) this;
    }

    default R id(String id) {
         return (R)StreamOperator.service().nodeId(this, id);
    }

}