Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
Java8Pocs
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Harshitha Sai Muppala
Java8Pocs
Commits
29fa3dfc
Commit
29fa3dfc
authored
Jun 26, 2023
by
Harshitha Sai Muppala
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added the logs
parent
e9dfb3c3
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
49 additions
and
16 deletions
+49
-16
Java-functional-Interface.iml
Java-functional-Interface.iml
+1
-0
FunctionalInterfaceExample.class
...ctional-Interface/Lambda/FunctionalInterfaceExample.class
+0
-0
Person.class
out/production/Java-functional-Interface/Lambda/Person.class
+0
-0
PredicateExample.class
...n/Java-functional-Interface/Lambda/PredicateExample.class
+0
-0
SumOfTwoIntegers.class
...n/Java-functional-Interface/Lambda/SumOfTwoIntegers.class
+0
-0
SupplierExample.class
...on/Java-functional-Interface/Lambda/SupplierExample.class
+0
-0
FunctionalInterfaceExample.java
src/Lambda/FunctionalInterfaceExample.java
+9
-1
FunctionalTest.java
src/Lambda/FunctionalTest.java
+6
-1
PredicateExample.java
src/Lambda/PredicateExample.java
+8
-3
PredicateExample1.java
src/Lambda/PredicateExample1.java
+6
-1
PredicateStringComparing.java
src/Lambda/PredicateStringComparing.java
+7
-2
SumOfTwoIntegers.java
src/Lambda/SumOfTwoIntegers.java
+1
-1
SupplierExample.java
src/Lambda/SupplierExample.java
+11
-7
No files found.
Java-functional-Interface.iml
View file @
29fa3dfc
...
@@ -7,5 +7,6 @@
...
@@ -7,5 +7,6 @@
</content>
</content>
<orderEntry
type=
"inheritedJdk"
/>
<orderEntry
type=
"inheritedJdk"
/>
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
<orderEntry
type=
"library"
name=
"slf4j-api-2.0.7"
level=
"project"
/>
</component>
</component>
</module>
</module>
\ No newline at end of file
out/production/Java-functional-Interface/Lambda/FunctionalInterfaceExample.class
View file @
29fa3dfc
No preview for this file type
out/production/Java-functional-Interface/Lambda/Person.class
View file @
29fa3dfc
No preview for this file type
out/production/Java-functional-Interface/Lambda/PredicateExample.class
View file @
29fa3dfc
No preview for this file type
out/production/Java-functional-Interface/Lambda/SumOfTwoIntegers.class
View file @
29fa3dfc
No preview for this file type
out/production/Java-functional-Interface/Lambda/SupplierExample.class
View file @
29fa3dfc
No preview for this file type
src/Lambda/FunctionalInterfaceExample.java
View file @
29fa3dfc
package
Lambda
;
package
Lambda
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
public
class
FunctionalInterfaceExample
{
public
class
FunctionalInterfaceExample
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
FunctionalInterfaceExample
.
class
);
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
List
<
Person
>
people
=
new
ArrayList
<>();
List
<
Person
>
people
=
new
ArrayList
<>();
people
.
add
(
new
Person
(
"harshitha"
,
1
));
people
.
add
(
new
Person
(
"harshitha"
,
1
));
...
@@ -15,7 +23,7 @@ public class FunctionalInterfaceExample {
...
@@ -15,7 +23,7 @@ public class FunctionalInterfaceExample {
return
person1
.
getAge
()
-
person2
.
getAge
();
return
person1
.
getAge
()
-
person2
.
getAge
();
});
});
for
(
Person
person:
people
){
for
(
Person
person:
people
){
System
.
out
.
println
(
person
.
getName
()+
" "
+
person
.
getAge
());
logger
.
info
(
person
.
getName
()+
" "
+
person
.
getAge
());
}
}
}
}
...
...
src/Lambda/FunctionalTest.java
View file @
29fa3dfc
package
Lambda
;
package
Lambda
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
public
interface
FunctionalTest
{
public
interface
FunctionalTest
{
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
FunctionalInterfaceExample
.
class
);
void
abstractTest
(
int
x
);
void
abstractTest
(
int
x
);
default
void
Message
(){
default
void
Message
(){
System
.
out
.
println
(
"hello"
);
logger
.
info
(
"hello"
);
}
}
}
}
...
...
src/Lambda/PredicateExample.java
View file @
29fa3dfc
package
Lambda
;
package
Lambda
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
public
class
PredicateExample
{
public
class
PredicateExample
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
FunctionalInterfaceExample
.
class
);
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
Display
i
=
()
->
System
.
out
.
println
(
"This is predicate example"
);
Display
i
=
()
->
System
.
out
.
println
(
"This is predicate example"
);
i
.
hello
();
i
.
hello
();
SumOfTwoIntegers
s
=
(
a
,
b
)
->
(
a
+
b
);
SumOfTwoIntegers
s
=
(
a
,
b
)
->
String
.
valueOf
((
a
+
b
)
);
System
.
out
.
println
(
s
.
sum
(
5
,
6
));
logger
.
info
(
s
.
sum
(
5
,
6
));
System
.
out
.
println
(
s
.
sum
(
7
,
7
));
logger
.
info
(
s
.
sum
(
7
,
7
));
}
}
}
}
src/Lambda/PredicateExample1.java
View file @
29fa3dfc
package
Lambda
;
package
Lambda
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.*
;
import
java.util.*
;
...
@@ -8,6 +11,8 @@ import java.util.function.Predicate;
...
@@ -8,6 +11,8 @@ import java.util.function.Predicate;
public
class
PredicateExample1
{
public
class
PredicateExample1
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
FunctionalInterfaceExample
.
class
);
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
List
<
User
>
users
=
new
ArrayList
<
User
>();
List
<
User
>
users
=
new
ArrayList
<
User
>();
users
.
add
(
new
User
(
"dev"
,
"Harshitha"
));
users
.
add
(
new
User
(
"dev"
,
"Harshitha"
));
...
@@ -15,7 +20,7 @@ public class PredicateExample1 {
...
@@ -15,7 +20,7 @@ public class PredicateExample1 {
users
.
add
(
new
User
(
"QA"
,
"Anusha"
));
users
.
add
(
new
User
(
"QA"
,
"Anusha"
));
List
devs
=
process
(
users
,(
User
u
)->
u
.
getRole
().
equals
(
"dev"
));
List
devs
=
process
(
users
,(
User
u
)->
u
.
getRole
().
equals
(
"dev"
));
System
.
out
.
println
(
devs
);
logger
.
info
(
devs
.
toString
()
);
}
}
...
...
src/Lambda/PredicateStringComparing.java
View file @
29fa3dfc
package
Lambda
;
package
Lambda
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.util.function.Predicate
;
import
java.util.function.Predicate
;
public
class
PredicateStringComparing
{
public
class
PredicateStringComparing
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
FunctionalInterfaceExample
.
class
);
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
String
s1
=
"hello"
;
String
s1
=
"hello"
;
String
s2
=
"hello"
;
String
s2
=
"hello"
;
Predicate
<
String
>
p
=
s
->
s
.
equals
(
s2
);
Predicate
<
String
>
p
=
s
->
s
.
equals
(
s2
);
if
(
p
.
test
(
s1
)){
if
(
p
.
test
(
s1
)){
System
.
out
.
println
(
"equal"
);
logger
.
info
(
"equal"
);
}
}
else
{
else
{
System
.
out
.
println
(
"not equal"
);
logger
.
info
(
"not equal"
);
}
}
}
}
...
...
src/Lambda/SumOfTwoIntegers.java
View file @
29fa3dfc
...
@@ -3,5 +3,5 @@ package Lambda;
...
@@ -3,5 +3,5 @@ package Lambda;
public
interface
SumOfTwoIntegers
public
interface
SumOfTwoIntegers
{
{
public
abstract
int
sum
(
int
a
,
int
b
);
public
abstract
String
sum
(
int
a
,
int
b
);
}
}
src/Lambda/SupplierExample.java
View file @
29fa3dfc
package
Lambda
;
package
Lambda
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.util.function.Consumer
;
import
java.util.function.Consumer
;
import
java.util.function.Supplier
;
import
java.util.function.Supplier
;
public
class
SupplierExample
{
public
class
SupplierExample
{
public
static
void
main
(
String
[]
args
)
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
FunctionalInterfaceExample
.
class
);
public
static
void
main
(
String
[]
args
)
{
//example of supplier
//example of supplier
Supplier
<
String
>
supplier
=
()
->
{
Supplier
<
String
>
supplier
=
()
->
{
System
.
out
.
println
(
"inside the supplier"
);
logger
.
info
(
"inside the supplier"
);
return
"hello"
;
return
"hello"
;
};
};
String
string
=
supplier
.
get
();
String
string
=
supplier
.
get
();
System
.
out
.
println
(
string
);
logger
.
info
(
string
);
//example of consumer
//example of consumer
Consumer
<
String
>
consumer
=
(
String
s
)
->
{
Consumer
<
String
>
consumer
=
(
String
s
)
->
{
System
.
out
.
println
(
"Inside the consumer"
);
logger
.
info
(
"Inside the consumer"
);
System
.
out
.
println
(
s
);
logger
.
info
(
s
);
};
};
consumer
.
accept
(
"hello"
);
consumer
.
accept
(
"hello"
);
Supplier
<
String
>
supplier1
=
()
->
{
Supplier
<
String
>
supplier1
=
()
->
{
System
.
out
.
println
(
"Supplier"
);
logger
.
info
(
"Supplier"
);
return
"hello"
;
return
"hello"
;
};
};
String
s
=
supplier1
.
get
();
String
s
=
supplier1
.
get
();
System
.
out
.
println
(
s
);
logger
.
info
(
s
);
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment