/home/caleb/ASDV-WebDev/Semester 2/Assignments/lab_EL5_CalebFontenot/src/main/java/edu/slcc/asdv/beans/LambdaAction.java
/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/JSF/JSFManagedBean.java to edit this template
 */
package edu.slcc.asdv.beans;

import jakarta.el.ELContext;
import jakarta.el.LambdaExpression;
import jakarta.inject.Named;
import jakarta.enterprise.context.RequestScoped;
import jakarta.faces.context.FacesContext;
import java.util.ArrayList;

/**
 *
 * @author caleb
 */
@Named(value = "lambdaAction")
@RequestScoped
public class LambdaAction {

    /**
     * Creates a new instance of LambdaAction
     */
    public LambdaAction() {
    }

    public Object lambda1(LambdaExpression lambdaExpression) {
        // Useful in case of a custom ELContext
        FacesContext fc = FacesContext.getCurrentInstance();
        ELContext elContext = fc.getELContext();
        return lambdaExpression.invoke(elContext, 8, 3);
    }

    public ArrayList<String> lambda2(LambdaExpression lambdaExpression) {
        ArrayList<String> returnArray = new ArrayList<>();

        returnArray.add(lambdaExpression.invoke(1,2,3,4).toString());
        returnArray.add(lambdaExpression.invoke(2,1,3,4).toString());
        returnArray.add(lambdaExpression.invoke(2,3,1,4).toString());
        returnArray.add(lambdaExpression.invoke(4,2,3,1).toString());
        returnArray.add(lambdaExpression.invoke(4,2,1,1).toString());
        returnArray.add(lambdaExpression.invoke(4,1,1,2).toString());
        returnArray.add(lambdaExpression.invoke(1,1,4,2).toString());
        returnArray.add(lambdaExpression.invoke(1,1,1,1).toString());
        return returnArray;
    }
}