component/src/main/java/org/wso2/extension/siddhi/execution/extrema/MaxByMinByLengthWindowProcessor.java
@Override

    protected StateFactory<ExtensionState> init(ExpressionExecutor[] attributeExpressionExecutors,
                                                ConfigReader configReader,
                                                StreamEventClonerHolder streamEventClonerHolder,
                                                boolean outputExpectsExpiredEvents,
                                                boolean findToBeExecuted, SiddhiQueryContext siddhiQueryContext) {

        this.siddhiQueryContext = siddhiQueryContext;
        this.internalWindowChunk = new ComplexEventChunk<StreamEvent>(false);
        maxByMinByExecutor = new MaxByMinByExecutor();
        //this.events=new ArrayList<StreamEvent>();
        maxByMinByExecutor.setMinByMaxByExecutorType(minByMaxByExecutorType);

        if (this.attributeExpressionExecutors.length != 2) {
            throw new SiddhiAppValidationException(
                    "Invalid no of arguments passed to minbymaxby:" + minByMaxByExecutorType + " window, "
                            + "required 2, but found " + this.attributeExpressionExecutors.length);
        }

        Attribute.Type attributeType = this.attributeExpressionExecutors[0].getReturnType();

        if (!((attributeType == Attribute.Type.DOUBLE) || (attributeType == Attribute.Type.INT) || (attributeType
                == Attribute.Type.STRING) || (attributeType == Attribute.Type.FLOAT) || (attributeType
                == Attribute.Type.LONG))) {
            throw new SiddhiAppValidationException(
                    "Invalid parameter type found for the first argument of minbymaxby:" + minByMaxByExecutorType
                            + " window, " + "required " + Attribute.Type.INT + " or " + Attribute.Type.LONG + " or "
                            + Attribute.Type.FLOAT + " or " + Attribute.Type.DOUBLE + "or" + Attribute.Type.STRING
                            + ", but found " + attributeType.toString());
        }
        attributeType = this.attributeExpressionExecutors[1].getReturnType();
        if (!((attributeType == Attribute.Type.LONG) || (attributeType == Attribute.Type.INT))) {
            throw new SiddhiAppValidationException(
                    "Invalid parameter type found for the second argument of minbymaxby:" + minByMaxByExecutorType
                            + " window, " + "required " + Attribute.Type.INT + " or " + Attribute.Type.LONG
                            + ", but found " + attributeType.toString());
        }
        minByMaxByExecutorAttribute = this.attributeExpressionExecutors[0];
        length = (Integer) (((ConstantExpressionExecutor) this.attributeExpressionExecutors[1]).getValue());

        return () -> new ExtensionState(null);
    }
/**
     * The init method of the WindowProcessor, this method will be called before other methods
     *
     * @param attributeExpressionExecutors the executors of each function parameters
     * @param siddhiQueryContext             the context of the siddhi query
     */
The init method of the WindowProcessor, this method will be called before other methods
@param attributeExpressionExecutors the executors of each function parameters
@param siddhiQueryContext             the context of the siddhi query
The init method of the WindowProcessor this method will be called before other methods @param attributeExpressionExecutors the executors of each function parameters @param siddhiQueryContext the context of the siddhi query
@Override
    protected StateFactory<ExtensionState> init(ExpressionExecutor[] attributeExpressionExecutors,
                                                ConfigReader configReader,
                                                StreamEventClonerHolder streamEventClonerHolder,
                                                boolean outputExpectsExpiredEvents,
                                                boolean findToBeExecuted, SiddhiQueryContext siddhiQueryContext) {
        this.siddhiQueryContext = siddhiQueryContext;
        this.internalWindowChunk = new ComplexEventChunk<StreamEvent>(false);
        maxByMinByExecutor = new MaxByMinByExecutor();
        maxByMinByExecutor.setMinByMaxByExecutorType(minByMaxByExecutorType);
        if (this.attributeExpressionExecutors.length != 2) {
            throw new SiddhiAppValidationException(
                    "Invalid no of arguments passed to minbymaxby:" + minByMaxByExecutorType + " window, "
                            + "required 2, but found " + this.attributeExpressionExecutors.length);
        }
        Attribute.Type attributeType = this.attributeExpressionExecutors[0].getReturnType();
        if (!((attributeType == Attribute.Type.DOUBLE) || (attributeType == Attribute.Type.INT) || (attributeType
                == Attribute.Type.STRING) || (attributeType == Attribute.Type.FLOAT) || (attributeType
                == Attribute.Type.LONG))) {
            throw new SiddhiAppValidationException(
                    "Invalid parameter type found for the first argument of minbymaxby:" + minByMaxByExecutorType
                            + " window, " + "required " + Attribute.Type.INT + " or " + Attribute.Type.LONG + " or "
                            + Attribute.Type.FLOAT + " or " + Attribute.Type.DOUBLE + "or" + Attribute.Type.STRING
                            + ", but found " + attributeType.toString());
        }
        attributeType = this.attributeExpressionExecutors[1].getReturnType();
        if (!((attributeType == Attribute.Type.LONG) || (attributeType == Attribute.Type.INT))) {
            throw new SiddhiAppValidationException(
                    "Invalid parameter type found for the second argument of minbymaxby:" + minByMaxByExecutorType
                            + " window, " + "required " + Attribute.Type.INT + " or " + Attribute.Type.LONG
                            + ", but found " + attributeType.toString());
        }
        minByMaxByExecutorAttribute = this.attributeExpressionExecutors[0];
        length = (Integer) (((ConstantExpressionExecutor) this.attributeExpressionExecutors[1]).getValue());
        return () -> new ExtensionState(null);
    }
@ Override protected StateFactory < ExtensionState > init ( ExpressionExecutor [ ] attributeExpressionExecutors , ConfigReader configReader , StreamEventClonerHolder streamEventClonerHolder , boolean outputExpectsExpiredEvents , boolean findToBeExecuted , SiddhiQueryContext siddhiQueryContext ) { this . siddhiQueryContext = siddhiQueryContext ; this . internalWindowChunk = new ComplexEventChunk < StreamEvent > ( false ) ; maxByMinByExecutor = new MaxByMinByExecutor ( ) ; maxByMinByExecutor . setMinByMaxByExecutorType ( minByMaxByExecutorType ) ; if ( this . attributeExpressionExecutors . length != 2 ) { throw new SiddhiAppValidationException ( "Invalid no of arguments passed to minbymaxby:" + minByMaxByExecutorType + " window, " + "required 2, but found " + this . attributeExpressionExecutors . length ) ; } Attribute . Type attributeType = this . attributeExpressionExecutors [ 0 ] . getReturnType ( ) ; if ( ! ( ( attributeType == Attribute . Type . DOUBLE ) || ( attributeType == Attribute . Type . INT ) || ( attributeType == Attribute . Type . STRING ) || ( attributeType == Attribute . Type . FLOAT ) || ( attributeType == Attribute . Type . LONG ) ) ) { throw new SiddhiAppValidationException ( "Invalid parameter type found for the first argument of minbymaxby:" + minByMaxByExecutorType + " window, " + "required " + Attribute . Type . INT + " or " + Attribute . Type . LONG + " or " + Attribute . Type . FLOAT + " or " + Attribute . Type . DOUBLE + "or" + Attribute . Type . STRING + ", but found " + attributeType . toString ( ) ) ; } attributeType = this . attributeExpressionExecutors [ 1 ] . getReturnType ( ) ; if ( ! ( ( attributeType == Attribute . Type . LONG ) || ( attributeType == Attribute . Type . INT ) ) ) { throw new SiddhiAppValidationException ( "Invalid parameter type found for the second argument of minbymaxby:" + minByMaxByExecutorType + " window, " + "required " + Attribute . Type . INT + " or " + Attribute . Type . LONG + ", but found " + attributeType . toString ( ) ) ; } minByMaxByExecutorAttribute = this . attributeExpressionExecutors [ 0 ] ; length = ( Integer ) ( ( ( ConstantExpressionExecutor ) this . attributeExpressionExecutors [ 1 ] ) . getValue ( ) ) ; return ( ) -> new ExtensionState ( null ) ; }
The init method of the WindowProcessor, this method will be called before other methods
 @param attributeExpressionExecutors the executors of each function parameters
 @param siddhiQueryContext             the context of the siddhi query
The init method of the WindowProcessor this method will be called before other methods @param attributeExpressionExecutors the executors of each function parameters @param siddhiQueryContext the context of the siddhi query
//this.events=new ArrayList<StreamEvent>();