bruh
modified: .gitignore modified: Semester 2/Assignments/labEL2_CalebFontenot/target/labEL2_CalebFontenot-1.0-SNAPSHOT.war modified: Semester 2/Assignments/labEL2_CalebFontenot/target/maven-archiver/pom.properties modified: Semester 2/Assignments/labEL2_CalebFontenot/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst modified: Semester 2/Assignments/labEL2_CalebFontenot/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file: Semester 2/Assignments/lab_EL5_CalebFontenot/Printed HTMLs/LambdaAction.html new file: Semester 2/Assignments/lab_EL5_CalebFontenot/Printed HTMLs/index.html modified: Semester 2/Assignments/lab_EL5_CalebFontenot/src/main/java/edu/slcc/asdv/beans/LambdaAction.java modified: Semester 2/Assignments/lab_EL5_CalebFontenot/src/main/webapp/index.xhtml modified: Semester 2/Assignments/lab_EL5_CalebFontenot/target/lab_EL5_CalebFontenot-1.0-SNAPSHOT/index.xhtml new file: Semester 2/ZIPs/lab_EL5_CalebFontenot.zip
This commit is contained in:
parent
ee8de8e7e5
commit
af597b18d1
3
.gitignore
vendored
3
.gitignore
vendored
@ -45,7 +45,8 @@
|
||||
/Semester 2/Assignments/SwingTest/target/
|
||||
/Semester 2/Assignments/MP2_BusinessLogic_CalebFontenot/target/
|
||||
/Semester 2/lab_EL5_CalebFontenot/target/
|
||||
|
||||
/Semester 2/labJuneau_CalebFontenot/target/
|
||||
/Semester 2/Assignments/LabJeaneauMessagesValidation_CalebFontenot/target/
|
||||
/Semester 2/LabJuneauValidateUserInput_CalebFontenot/target/
|
||||
/Semester 2/Assignments/lab_EL5_CalebFontenot/target/
|
||||
/Semester 2/Assignments/labEL2_CalebFontenot/target/
|
||||
|
Binary file not shown.
@ -1,5 +1,5 @@
|
||||
#Generated by Maven
|
||||
#Fri Sep 08 10:22:26 CDT 2023
|
||||
#Fri Sep 29 15:02:58 CDT 2023
|
||||
groupId=edu.slcc.asdv.caleb
|
||||
artifactId=labEL2_CalebFontenot
|
||||
version=1.0-SNAPSHOT
|
||||
|
@ -1,6 +1,6 @@
|
||||
edu/slcc/asdv/beans/Purchases.class
|
||||
edu/slcc/asdv/pojos/Company.class
|
||||
edu/slcc/asdv/beans/SimpleBean.class
|
||||
edu/slcc/asdv/pojos/Company.class
|
||||
edu/slcc/asdv/pojos/Name.class
|
||||
edu/slcc/asdv/bl/Utils.class
|
||||
edu/slcc/asdv/pojos/Employee.class
|
||||
|
@ -1,10 +1,10 @@
|
||||
/home/caleb/ASDV-WebDev/Semester 2/labEL2_CalebFontenot/src/main/java/edu/slcc/asdv/pojos/Name.java
|
||||
/home/caleb/ASDV-WebDev/Semester 2/labEL2_CalebFontenot/src/main/java/edu/slcc/asdv/beans/SimpleBean.java
|
||||
/home/caleb/ASDV-WebDev/Semester 2/labEL2_CalebFontenot/src/main/java/edu/slcc/asdv/beans/TestBean1.java
|
||||
/home/caleb/ASDV-WebDev/Semester 2/labEL2_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/label2_calebfontenot/JakartaRestConfiguration.java
|
||||
/home/caleb/ASDV-WebDev/Semester 2/labEL2_CalebFontenot/src/main/java/edu/slcc/asdv/pojos/Employee.java
|
||||
/home/caleb/ASDV-WebDev/Semester 2/labEL2_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/label2_calebfontenot/resources/JakartaEE10Resource.java
|
||||
/home/caleb/ASDV-WebDev/Semester 2/labEL2_CalebFontenot/src/main/java/edu/slcc/asdv/pojos/Company.java
|
||||
/home/caleb/ASDV-WebDev/Semester 2/labEL2_CalebFontenot/src/main/java/edu/slcc/asdv/bl/Utils.java
|
||||
/home/caleb/ASDV-WebDev/Semester 2/labEL2_CalebFontenot/src/main/java/edu/slcc/asdv/beans/EmployeeBean.java
|
||||
/home/caleb/ASDV-WebDev/Semester 2/labEL2_CalebFontenot/src/main/java/edu/slcc/asdv/beans/Purchases.java
|
||||
/home/caleb/ASDV-WebDev/Semester 2/Assignments/labEL2_CalebFontenot/src/main/java/edu/slcc/asdv/pojos/Employee.java
|
||||
/home/caleb/ASDV-WebDev/Semester 2/Assignments/labEL2_CalebFontenot/src/main/java/edu/slcc/asdv/bl/Utils.java
|
||||
/home/caleb/ASDV-WebDev/Semester 2/Assignments/labEL2_CalebFontenot/src/main/java/edu/slcc/asdv/pojos/Company.java
|
||||
/home/caleb/ASDV-WebDev/Semester 2/Assignments/labEL2_CalebFontenot/src/main/java/edu/slcc/asdv/beans/TestBean1.java
|
||||
/home/caleb/ASDV-WebDev/Semester 2/Assignments/labEL2_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/label2_calebfontenot/JakartaRestConfiguration.java
|
||||
/home/caleb/ASDV-WebDev/Semester 2/Assignments/labEL2_CalebFontenot/src/main/java/edu/slcc/asdv/beans/Purchases.java
|
||||
/home/caleb/ASDV-WebDev/Semester 2/Assignments/labEL2_CalebFontenot/src/main/java/edu/slcc/asdv/beans/EmployeeBean.java
|
||||
/home/caleb/ASDV-WebDev/Semester 2/Assignments/labEL2_CalebFontenot/src/main/java/edu/slcc/asdv/beans/SimpleBean.java
|
||||
/home/caleb/ASDV-WebDev/Semester 2/Assignments/labEL2_CalebFontenot/src/main/java/edu/slcc/asdv/pojos/Name.java
|
||||
/home/caleb/ASDV-WebDev/Semester 2/Assignments/labEL2_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/label2_calebfontenot/resources/JakartaEE10Resource.java
|
||||
|
@ -0,0 +1,75 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>LambdaAction.java</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<style type="text/css">
|
||||
<!--
|
||||
body {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
|
||||
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
|
||||
table {color: #888888; background-color: #313335; font-family: monospace; font-weight: bold}
|
||||
.literal {color: #cc7832}
|
||||
.ST2 {font-family: monospace; font-weight: bold; font-style: italic}
|
||||
.ST0 {color: #287bde}
|
||||
.string {color: #6a8759}
|
||||
.number {color: #6897bb}
|
||||
.ST1 {color: #ffc66d}
|
||||
.comment {color: #808080}
|
||||
.whitespace {color: #505050}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table width="100%"><tr><td align="center">/home/caleb/ASDV-WebDev/Semester 2/Assignments/lab_EL5_CalebFontenot/src/main/java/edu/slcc/asdv/beans/LambdaAction.java</td></tr></table>
|
||||
<pre>
|
||||
<span class="comment">/*</span>
|
||||
<span class="comment"> * Click </span><span class="ST0">nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt</span><span class="comment"> to change this license</span>
|
||||
<span class="comment"> * Click </span><span class="ST0">nbfs://nbhost/SystemFileSystem/Templates/JSF/JSFManagedBean.java</span><span class="comment"> to edit this template</span>
|
||||
<span class="comment"> */</span>
|
||||
<span class="literal">package</span> edu.slcc.asdv.beans;
|
||||
|
||||
<span class="literal">import</span> jakarta.el.ELContext;
|
||||
<span class="literal">import</span> jakarta.el.LambdaExpression;
|
||||
<span class="literal">import</span> jakarta.inject.Named;
|
||||
<span class="literal">import</span> jakarta.enterprise.context.RequestScoped;
|
||||
<span class="literal">import</span> jakarta.faces.context.FacesContext;
|
||||
<span class="literal">import</span> java.util.ArrayList;
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="comment">@author</span> <span class="comment">caleb</span>
|
||||
<span class="comment">*/</span>
|
||||
@Named(value = <span class="string">"</span><span class="string">lambdaAction</span><span class="string">"</span>)
|
||||
@RequestScoped
|
||||
<span class="literal">public</span> <span class="literal">class</span> LambdaAction {
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> * </span><span class="comment">Creates</span> <span class="comment">a</span> <span class="comment">new</span> <span class="comment">instance</span> <span class="comment">of</span> <span class="comment">LambdaAction</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">public</span> LambdaAction() {
|
||||
}
|
||||
|
||||
<span class="literal">public</span> Object <span class="ST1">lambda1</span>(LambdaExpression lambdaExpression) {
|
||||
<span class="comment">// Useful in case of a custom ELContext</span>
|
||||
FacesContext fc = FacesContext.<span class="ST2">getCurrentInstance</span>();
|
||||
ELContext elContext = fc.getELContext();
|
||||
<span class="literal">return</span> lambdaExpression.invoke(elContext, <span class="number">8</span>, <span class="number">3</span>);
|
||||
}
|
||||
|
||||
<span class="literal">public</span> ArrayList<String> <span class="ST1">lambda2</span>(LambdaExpression lambdaExpression) {
|
||||
ArrayList<String> returnArray = <span class="literal">new</span> ArrayList<>();
|
||||
|
||||
returnArray.add(lambdaExpression.invoke(<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>,<span class="number">4</span>).toString());
|
||||
returnArray.add(lambdaExpression.invoke(<span class="number">2</span>,<span class="number">1</span>,<span class="number">3</span>,<span class="number">4</span>).toString());
|
||||
returnArray.add(lambdaExpression.invoke(<span class="number">2</span>,<span class="number">3</span>,<span class="number">1</span>,<span class="number">4</span>).toString());
|
||||
returnArray.add(lambdaExpression.invoke(<span class="number">4</span>,<span class="number">2</span>,<span class="number">3</span>,<span class="number">1</span>).toString());
|
||||
returnArray.add(lambdaExpression.invoke(<span class="number">4</span>,<span class="number">2</span>,<span class="number">1</span>,<span class="number">1</span>).toString());
|
||||
returnArray.add(lambdaExpression.invoke(<span class="number">4</span>,<span class="number">1</span>,<span class="number">1</span>,<span class="number">2</span>).toString());
|
||||
returnArray.add(lambdaExpression.invoke(<span class="number">1</span>,<span class="number">1</span>,<span class="number">4</span>,<span class="number">2</span>).toString());
|
||||
returnArray.add(lambdaExpression.invoke(<span class="number">1</span>,<span class="number">1</span>,<span class="number">1</span>,<span class="number">1</span>).toString());
|
||||
<span class="literal">return</span> returnArray;
|
||||
}
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
@ -0,0 +1,79 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>index.xhtml</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<style type="text/css">
|
||||
<!--
|
||||
body {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
|
||||
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
|
||||
table {color: #888888; background-color: #313335; font-family: monospace; font-weight: bold}
|
||||
.highlight-caret-row {background-color: #323232}
|
||||
.expression-language {background-color: #232525}
|
||||
.ST8 {color: #cc7832; background-color: #232525}
|
||||
.ST0 {color: #628fb5}
|
||||
.ST2 {color: #287bde}
|
||||
.ST6 {color: #505050; background-color: #232525}
|
||||
.ST7 {color: #6897bb; background-color: #232525}
|
||||
.ST9 {color: #6a8759; background-color: #232525}
|
||||
.ST5 {color: #a5c261}
|
||||
.ST3 {color: #e8bf6a}
|
||||
.ST1 {color: #505050}
|
||||
.ST4 {color: #bababa}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table width="100%"><tr><td align="center">/home/caleb/ASDV-WebDev/Semester 2/Assignments/lab_EL5_CalebFontenot/src/main/webapp/index.xhtml</td></tr></table>
|
||||
<pre>
|
||||
<span class="highlight-caret-row"><?xml version='1.0' encoding='UTF-8' ?></span>
|
||||
<span class="ST0"><!DOCTYPE</span> <span class="ST0">html</span> <span class="ST0">PUBLIC</span> <span class="ST0">"-//W3C//DTD</span> <span class="ST0">XHTML</span> <span class="ST0">1.0</span> <span class="ST0">Transitional//EN"</span> <span class="ST0">"</span><span class="ST2">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</span><span class="ST0">"</span><span class="ST0">></span>
|
||||
<span class="ST3"><</span><span class="ST3">html</span> <span class="ST4">xmlns</span><span class="ST4">=</span><span class="ST5">"</span><span class="ST2">http://www.w3.org/1999/xhtml</span><span class="ST5">"</span>
|
||||
<span class="ST4">xmlns:h</span><span class="ST4">=</span><span class="ST5">"</span><span class="ST2">http://xmlns.jcp.org/jsf/html</span><span class="ST5">"</span>
|
||||
<span class="ST4">xmlns:ui</span><span class="ST4">=</span><span class="ST5">"</span><span class="ST2">http://xmlns.jcp.org/jsf/facelets</span><span class="ST5">"</span><span class="ST3">></span>
|
||||
<span class="ST3"><</span><span class="ST3">h:head</span><span class="ST3">></span>
|
||||
<span class="ST3"><</span><span class="ST3">title</span><span class="ST3">></span>Facelet Title<span class="ST3"></</span><span class="ST3">title</span><span class="ST3">></span>
|
||||
<span class="ST3"></</span><span class="ST3">h:head</span><span class="ST3">></span>
|
||||
<span class="ST3"><</span><span class="ST3">h:body</span><span class="ST3">></span>
|
||||
<span class="ST3"><</span><span class="ST3">h3</span><span class="ST3">></span>Assignment operator, concatenation operator<span class="ST3"></</span><span class="ST3">h3</span><span class="ST3">></span>
|
||||
{x = 3}: <span class="expression-language">#{</span><span class="expression-language">x</span> <span class="expression-language">=</span> <span class="ST7">3</span><span class="expression-language">}</span><span class="ST3"><</span><span class="ST3">br</span><span class="ST3">/></span>
|
||||
{y = x + 5}: <span class="expression-language">#{</span><span class="expression-language">y</span> <span class="expression-language">=</span> <span class="expression-language">x</span> <span class="expression-language">+</span> <span class="ST7">5</span><span class="expression-language">}</span><span class="ST3"><</span><span class="ST3">br</span><span class="ST3">/></span>
|
||||
{z = x + y}: <span class="expression-language">#{</span><span class="expression-language">z</span> <span class="expression-language">=</span> <span class="expression-language">x</span> <span class="expression-language">+</span> <span class="expression-language">y</span><span class="expression-language">}</span><span class="ST3"><</span><span class="ST3">br</span><span class="ST3">/></span>
|
||||
|
||||
concatenation operator += {z += x} <span class="expression-language">#{</span><span class="expression-language">z</span> <span class="expression-language">+=</span> <span class="expression-language">x</span><span class="expression-language">}</span>
|
||||
|
||||
<span class="ST3"><</span><span class="ST3">h3</span><span class="ST3">></span>; semicolon operator<span class="ST3"></</span><span class="ST3">h3</span><span class="ST3">></span>
|
||||
{x = 5; y = 3; z = x + y}: <span class="expression-language">#{</span><span class="expression-language">x</span> <span class="expression-language">=</span> <span class="ST7">5</span><span class="expression-language">;</span> <span class="expression-language">y</span> <span class="expression-language">=</span> <span class="ST7">3</span><span class="expression-language">;</span> <span class="expression-language">z</span> <span class="expression-language">=</span> <span class="expression-language">x</span> <span class="expression-language">+</span> <span class="expression-language">y</span><span class="expression-language">}</span><span class="ST3"><</span><span class="ST3">br</span><span class="ST3">/></span>
|
||||
<span class="ST3"><</span><span class="ST3">h3</span><span class="ST3">></span>lambda expressions and conditional operator<span class="ST3"></</span><span class="ST3">h3</span><span class="ST3">></span>
|
||||
{(x->x+1)(3)}: <span class="expression-language">#{</span><span class="expression-language">(</span><span class="expression-language">x</span><span class="expression-language">-></span><span class="expression-language">x</span><span class="expression-language">+</span><span class="ST7">1</span><span class="expression-language">)</span><span class="expression-language">(</span><span class="ST7">3</span><span class="expression-language">)</span><span class="expression-language">}</span><span class="ST3"><</span><span class="ST3">br</span><span class="ST3">/></span>
|
||||
Declaration and use of lambda variables: <span class="expression-language">#{</span><span class="expression-language">squareOfNumber</span> <span class="expression-language">=</span> <span class="expression-language">(</span><span class="expression-language">(</span><span class="expression-language">x</span><span class="expression-language">)</span> <span class="expression-language">-></span> <span class="expression-language">x</span><span class="expression-language">+</span><span class="expression-language">x</span><span class="expression-language">)</span><span class="expression-language">;</span> <span class="expression-language">squareOfNumber</span><span class="expression-language">(</span><span class="ST7">4</span><span class="expression-language">)</span><span class="expression-language">}</span><span class="ST3"><</span><span class="ST3">br</span><span class="ST3">/></span>
|
||||
|
||||
use of lambda variable outside the initial {}: <span class="expression-language">#{</span><span class="expression-language">squareOfNumber</span><span class="expression-language">(</span><span class="ST7">5</span><span class="expression-language">)</span><span class="expression-language">}</span><span class="ST3"><</span><span class="ST3">br</span><span class="ST3">/></span>
|
||||
|
||||
<span class="expression-language">#{</span><span class="expression-language">min</span><span class="expression-language">=</span><span class="expression-language">(</span><span class="expression-language">x</span><span class="expression-language">,</span><span class="expression-language">y</span><span class="expression-language">)</span> <span class="expression-language">-></span> <span class="expression-language">(</span><span class="expression-language">x</span> <span class="ST8">lt</span> <span class="expression-language">y</span> <span class="expression-language">?</span> <span class="expression-language">x</span> <span class="expression-language">:</span> <span class="expression-language">y</span><span class="expression-language">)</span><span class="expression-language">;</span> <span class="expression-language">min</span><span class="expression-language">(</span><span class="ST7">1</span><span class="expression-language">,</span><span class="ST7">2</span><span class="expression-language">)</span><span class="expression-language">}</span><span class="ST3"><</span><span class="ST3">br</span><span class="ST3">/></span>
|
||||
<span class="expression-language">#{</span><span class="expression-language">min</span><span class="expression-language">(</span><span class="ST7">3</span><span class="expression-language">,</span> <span class="ST7">4</span><span class="expression-language">)</span><span class="expression-language">}</span><span class="ST3"><</span><span class="ST3">br</span><span class="ST3">/></span>
|
||||
|
||||
<span class="ST3"><</span><span class="ST3">h3</span><span class="ST3">></span> call a bean method with EL as lambda expression<span class="ST3"></</span><span class="ST3">h3</span><span class="ST3">></span>
|
||||
|
||||
<span class="expression-language">#{</span><span class="expression-language">lambdaAction</span><span class="expression-language">.</span><span class="expression-language">lambda1</span><span class="expression-language">(</span><span class="expression-language">max</span> <span class="expression-language">=</span> <span class="expression-language">(</span><span class="expression-language">x</span><span class="expression-language">,</span><span class="expression-language">y</span><span class="expression-language">)</span> <span class="expression-language">-></span> <span class="expression-language">x</span> <span class="ST8">gt</span> <span class="expression-language">y</span> <span class="expression-language">?</span> <span class="expression-language">x</span> <span class="expression-language">:</span> <span class="expression-language">y</span><span class="expression-language">)</span><span class="expression-language">}</span><span class="ST3"><</span><span class="ST3">br</span><span class="ST3">/></span>
|
||||
|
||||
<span class="ST3"><</span><span class="ST3">h3</span><span class="ST3">></span> Collections as lambda expression<span class="ST3"></</span><span class="ST3">h3</span><span class="ST3">></span>
|
||||
set: <span class="expression-language">#{</span><span class="expression-language">set</span> <span class="expression-language">=</span> <span class="expression-language">{</span><span class="ST7">10</span><span class="expression-language">,</span><span class="ST7">20</span><span class="expression-language">,</span><span class="ST7">1</span><span class="expression-language">,</span><span class="ST7">44</span><span class="expression-language">}</span><span class="expression-language">}</span><span class="ST3"><</span><span class="ST3">br</span><span class="ST3">/></span>
|
||||
list: <span class="expression-language">#{</span><span class="expression-language">list</span> <span class="expression-language">=</span> <span class="expression-language">[</span><span class="ST7">100</span><span class="expression-language">,</span><span class="ST7">2</span><span class="expression-language">,</span><span class="ST7">20</span><span class="expression-language">,</span><span class="ST7">33</span><span class="expression-language">]</span><span class="expression-language">}</span><span class="ST3"><</span><span class="ST3">br</span><span class="ST3">/></span>
|
||||
map: <span class="expression-language">#{</span><span class="expression-language">map</span> <span class="expression-language">=</span> <span class="expression-language">{</span><span class="ST9">"one"</span><span class="expression-language">:</span><span class="ST7">1</span><span class="expression-language">,</span> <span class="ST9">"two"</span><span class="expression-language">:</span><span class="ST7">3</span><span class="expression-language">,</span> <span class="ST9">"four"</span><span class="expression-language">:</span><span class="ST7">4</span><span class="expression-language">}</span><span class="expression-language">}</span> <span class="ST3"><</span><span class="ST3">br</span><span class="ST3">/></span>
|
||||
sorting a list descending: <span class="expression-language">#{</span><span class="expression-language">list</span><span class="expression-language">.</span><span class="expression-language">stream</span><span class="expression-language">(</span><span class="expression-language">)</span><span class="expression-language">.</span><span class="expression-language">sorted</span><span class="expression-language">(</span><span class="expression-language">(</span><span class="expression-language">i</span><span class="expression-language">,</span><span class="expression-language">j</span><span class="expression-language">)</span><span class="expression-language">-></span><span class="expression-language">i</span><span class="expression-language">-</span><span class="expression-language">j</span><span class="expression-language">)</span><span class="expression-language">.</span><span class="expression-language">toList</span><span class="expression-language">(</span><span class="expression-language">)</span><span class="expression-language">}</span><span class="ST3"><</span><span class="ST3">br</span><span class="ST3">/></span>
|
||||
sorting a list ascending: <span class="expression-language">#{</span><span class="expression-language">list</span><span class="expression-language">.</span><span class="expression-language">stream</span><span class="expression-language">(</span><span class="expression-language">)</span><span class="expression-language">.</span><span class="expression-language">sorted</span><span class="expression-language">(</span><span class="expression-language">(</span><span class="expression-language">i</span><span class="expression-language">,</span><span class="expression-language">j</span><span class="expression-language">)</span><span class="expression-language">-></span><span class="expression-language">j</span><span class="expression-language">-</span><span class="expression-language">i</span><span class="expression-language">)</span><span class="expression-language">.</span><span class="expression-language">toList</span><span class="expression-language">(</span><span class="expression-language">)</span><span class="expression-language">}</span><span class="ST3"><</span><span class="ST3">br</span><span class="ST3">/></span>
|
||||
|
||||
<span class="ST3"><</span><span class="ST3">h3</span><span class="ST3">></span>Traversing a lambda collection<span class="ST3"></</span><span class="ST3">h3</span><span class="ST3">></span>
|
||||
<span class="ST3"><</span><span class="ST3">ui:repeat</span> <span class="ST4">value</span><span class="ST4">=</span><span class="ST5">"</span><span class="expression-language">#{</span><span class="expression-language">map</span><span class="expression-language">.</span><span class="expression-language">keySet</span><span class="expression-language">(</span><span class="expression-language">)</span><span class="expression-language">.</span><span class="expression-language">toArray</span><span class="expression-language">(</span><span class="expression-language">)</span><span class="expression-language">}</span><span class="ST5">"</span> <span class="ST4">var</span><span class="ST4">=</span><span class="ST5">"t"</span><span class="ST3">></span>
|
||||
<span class="ST3"><</span><span class="ST3">h:outputText</span> <span class="ST4">value</span><span class="ST4">=</span><span class="ST5">"key:</span><span class="expression-language">#{</span><span class="expression-language">t</span><span class="expression-language">}</span>
|
||||
<span class="ST5">value: </span><span class="expression-language">#{</span><span class="expression-language">map</span><span class="expression-language">.</span><span class="expression-language">get</span><span class="expression-language">(</span><span class="expression-language">t</span><span class="expression-language">)</span><span class="expression-language">}</span><span class="ST5">"</span><span class="ST3">/</span><span class="ST3">></span><span class="ST3"><</span><span class="ST3">br</span><span class="ST3">/></span>
|
||||
<span class="ST3"></</span><span class="ST3">ui:repeat</span><span class="ST3">></span>
|
||||
<span class="ST3"><</span><span class="ST3">h3</span><span class="ST3">></span> Min of 4<span class="ST3"></</span><span class="ST3">h3</span><span class="ST3">></span>
|
||||
<span class="expression-language">#{</span><span class="expression-language">lambdaAction</span><span class="expression-language">.</span><span class="expression-language">lambda2</span><span class="expression-language">(</span><span class="expression-language">min4</span> <span class="expression-language">=</span> <span class="expression-language">(</span><span class="expression-language">w</span><span class="expression-language">,</span> <span class="expression-language">x</span><span class="expression-language">,</span> <span class="expression-language">y</span><span class="expression-language">,</span> <span class="expression-language">z</span><span class="expression-language">)</span> <span class="expression-language">-></span> <span class="expression-language">(</span><span class="expression-language">w</span> <span class="ST8">lt</span> <span class="expression-language">x</span><span class="expression-language">)</span> <span class="expression-language">?</span> <span class="expression-language">(</span><span class="expression-language">(</span><span class="expression-language">w</span> <span class="ST8">lt</span> <span class="expression-language">y</span><span class="expression-language">)</span> <span class="expression-language">?</span> <span class="expression-language">(</span><span class="expression-language">(</span><span class="expression-language">w</span> <span class="ST8">lt</span> <span class="expression-language">z</span><span class="expression-language">)</span> <span class="expression-language">?</span> <span class="expression-language">w</span> <span class="expression-language">:</span> <span class="expression-language">z</span><span class="expression-language">)</span> <span class="expression-language">:</span> <span class="expression-language">(</span><span class="expression-language">(</span><span class="expression-language">y</span> <span class="ST8">lt</span> <span class="expression-language">z</span><span class="expression-language">)</span> <span class="expression-language">?</span> <span class="expression-language">y</span> <span class="expression-language">:</span> <span class="expression-language">z</span><span class="expression-language">)</span><span class="expression-language">)</span> <span class="expression-language">:</span> <span class="expression-language">(</span><span class="expression-language">(</span><span class="expression-language">x</span> <span class="ST8">lt</span> <span class="expression-language">y</span><span class="expression-language">)</span> <span class="expression-language">?</span> <span class="expression-language">(</span><span class="expression-language">(</span><span class="expression-language">x</span> <span class="ST8">lt</span> <span class="expression-language">z</span><span class="expression-language">)</span> <span class="expression-language">?</span> <span class="expression-language">x</span> <span class="expression-language">:</span> <span class="expression-language">z</span><span class="expression-language">)</span> <span class="expression-language">:</span> <span class="expression-language">(</span><span class="expression-language">(</span><span class="expression-language">y</span> <span class="ST8">lt</span> <span class="expression-language">z</span><span class="expression-language">)</span> <span class="expression-language">?</span> <span class="expression-language">y</span> <span class="expression-language">:</span> <span class="expression-language">z</span><span class="expression-language">)</span><span class="expression-language">)</span><span class="expression-language">)</span><span class="expression-language">}</span>;
|
||||
|
||||
<span class="ST3"></</span><span class="ST3">h:body</span><span class="ST3">></span>
|
||||
<span class="ST3"></</span><span class="ST3">html</span><span class="ST3">></span>
|
||||
|
||||
</pre></body>
|
||||
</html>
|
@ -10,6 +10,7 @@ import jakarta.el.LambdaExpression;
|
||||
import jakarta.inject.Named;
|
||||
import jakarta.enterprise.context.RequestScoped;
|
||||
import jakarta.faces.context.FacesContext;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -19,9 +20,12 @@ import jakarta.faces.context.FacesContext;
|
||||
@RequestScoped
|
||||
public class LambdaAction {
|
||||
|
||||
/** Creates a new instance of 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();
|
||||
@ -29,4 +33,17 @@ public class LambdaAction {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -41,5 +41,8 @@
|
||||
<h:outputText value="key:#{t}
|
||||
value: #{map.get(t)}"/><br/>
|
||||
</ui:repeat>
|
||||
<h3> Min of 4</h3>
|
||||
#{lambdaAction.lambda2(min4 = (w, x, y, z) -> (w lt x) ? ((w lt y) ? ((w lt z) ? w : z) : ((y lt z) ? y : z)) : ((x lt y) ? ((x lt z) ? x : z) : ((y lt z) ? y : z)))};
|
||||
|
||||
</h:body>
|
||||
</html>
|
||||
|
@ -41,5 +41,8 @@
|
||||
<h:outputText value="key:#{t}
|
||||
value: #{map.get(t)}"/><br/>
|
||||
</ui:repeat>
|
||||
<h3> Min of 4</h3>
|
||||
#{lambdaAction.lambda2(min4 = (w, x, y, z) -> (w lt x) ? ((w lt y) ? ((w lt z) ? w : z) : ((y lt z) ? y : z)) : ((x lt y) ? ((x lt z) ? x : z) : ((y lt z) ? y : z)))};
|
||||
|
||||
</h:body>
|
||||
</html>
|
||||
|
BIN
Semester 2/ZIPs/lab_EL5_CalebFontenot.zip
Normal file
BIN
Semester 2/ZIPs/lab_EL5_CalebFontenot.zip
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user