Skip to content

Commit eb4c10c

Browse files
author
Saurabh Oza
committed
Formatting the files
1 parent c558288 commit eb4c10c

File tree

7 files changed

+37
-43
lines changed

7 files changed

+37
-43
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bin

src/com/onlyfullstack/bean/GraphicsCard.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ public class GraphicsCard {
55
private String size;
66
private GraphicsMemory graphicsMemory;
77

8-
public GraphicsCard(String size) {
8+
9+
public GraphicsCard(String size, GraphicsMemory graphicsMemory) {
10+
super();
911
this.size = size;
12+
this.graphicsMemory = graphicsMemory;
1013
}
1114

1215
public GraphicsMemory getGraphicsMemory() {

src/com/onlyfullstack/optional/OptionalFeature.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ public static void main(String[] args) {
2222
}
2323

2424
private static void getGraphicsCardSize(SmartPhone smartPhone) {
25-
List a = new ArrayList<>();
26-
a.stream();
2725
String size = smartPhone.getGraphicsCard()
2826
.map(GraphicsCard::getGraphicsMemory) // map returns the Optional of type passed as a parameter (here its string)
2927
.map(GraphicsMemory::getDedicatedMemory)
@@ -43,7 +41,8 @@ private static void ofVsOfNullable() {
4341

4442
private static SmartPhone createSmartPhoneWithGraphicsCard() {
4543
SmartPhone smartPhone = new SmartPhone();
46-
Optional<GraphicsCard> card = Optional.ofNullable(new GraphicsCard("4 gb"));
44+
GraphicsMemory memory = new GraphicsMemory("4 GB", "");
45+
Optional<GraphicsCard> card = Optional.ofNullable(new GraphicsCard("4 gb", memory));
4746
smartPhone.setGraphicsCard(card);
4847
return smartPhone;
4948
}

src/com/onlyfullstack/stream/AdvanceCollectors.java

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,64 +14,58 @@ public class AdvanceCollectors {
1414
public static void main(String[] args) {
1515

1616
List<Student> students = JavaInputFixture.createList();
17-
//joiningCollector(students);
18-
//summaryStatisticsCollector(students);
19-
//partitioningByCollector(students);
20-
//groupingByCollector(students);
17+
joiningCollector(students);
18+
summaryStatisticsCollector(students);
19+
partitioningByCollector(students);
20+
groupingByCollector(students);
2121
mappingByCollector(students);
2222
}
2323

2424
private static void joiningCollector(List<Student> students) {
2525
System.out.println("######## Executing joiningCollector() : ######## ");
26-
String allStudents = students.stream()
27-
.map(Student::getName)
28-
.collect(Collectors.joining(" | "));
29-
System.out.println("Collectors.joining() : "+allStudents);
26+
String allStudents = students.stream().map(Student::getName).collect(Collectors.joining(" | "));
27+
System.out.println("Collectors.joining() : " + allStudents);
3028
System.out.println("######## Ending the execution of joiningCollector() ######## ");
31-
29+
3230
}
33-
31+
3432
private static void summaryStatisticsCollector(List<Student> students) {
3533
System.out.println("######## Executing summaryStatisticsCollector() : ######## ");
36-
DoubleSummaryStatistics statistics = students.stream()
37-
.mapToDouble(Student::getAge)
38-
.summaryStatistics();
39-
40-
System.out.println("summaryStatistics() : "+statistics);
41-
System.out.println("Total Count : "+statistics.getCount());
34+
DoubleSummaryStatistics statistics = students.stream().mapToDouble(Student::getAge).summaryStatistics();
35+
36+
System.out.println("summaryStatistics() : " + statistics);
37+
System.out.println("Total Count : " + statistics.getCount());
4238
System.out.println("Total Sum : " + statistics.getSum());
4339
System.out.println("Minimum Age : " + statistics.getMin());
4440
System.out.println("Maximum Age : " + statistics.getMax());
4541
System.out.println("Average Age : " + statistics.getAverage());
4642
System.out.println("######## Ending the execution of summaryStatisticsCollector() ######## ");
4743
}
48-
44+
4945
private static void partitioningByCollector(List<Student> students) {
5046
System.out.println("######## Executing partitioningByCollector() : ######## ");
51-
Map<Boolean,List<Student>> partition = students.stream()
47+
Map<Boolean, List<Student>> partition = students.stream()
5248
.collect(Collectors.partitioningBy(stud -> stud.getCity().equals("Pune")));
53-
54-
System.out.println("Students living in Pune : "+partition.get(true));
55-
System.out.println("Students not living in Pune : "+partition.get(false));
49+
50+
System.out.println("Students living in Pune : " + partition.get(true));
51+
System.out.println("Students not living in Pune : " + partition.get(false));
5652
System.out.println("######## Ending the execution of partitioningByCollector() ######## ");
5753
}
58-
54+
5955
private static void groupingByCollector(List<Student> students) {
6056
System.out.println("######## Executing groupingByCollector() : ######## ");
61-
Map<String,List<Student>> groupBy = students.stream()
62-
.collect(Collectors.groupingBy(Student::getCity));
63-
64-
System.out.println("groupingByCollector : "+groupBy);
57+
Map<String, List<Student>> groupBy = students.stream().collect(Collectors.groupingBy(Student::getCity));
58+
59+
System.out.println("groupingByCollector : " + groupBy);
6560
System.out.println("######## Ending the execution of groupingByCollector() ######## ");
6661
}
6762

6863
private static void mappingByCollector(List<Student> students) {
6964
System.out.println("######## Executing mappingByCollector() : ######## ");
70-
Map<String,Set<String>> mappingBy = students.stream()
71-
.collect(Collectors.groupingBy(Student::getCity,
72-
Collectors.mapping(Student::getName, Collectors.toSet())));
73-
74-
System.out.println("mappingByCollector : "+mappingBy);
65+
Map<String, Set<String>> mappingBy = students.stream().collect(
66+
Collectors.groupingBy(Student::getCity, Collectors.mapping(Student::getName, Collectors.toSet())));
67+
68+
System.out.println("mappingByCollector : " + mappingBy);
7569
System.out.println("######## Ending the execution of mappingByCollector() ######## ");
7670
}
7771
}

src/com/onlyfullstack/stream/IntermediateVsTerminal.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@ public static void main(String[] args) throws InterruptedException {
1616

1717
private static void lazyIntermediateOperations(List<Student> students) throws InterruptedException {
1818
System.out.println("######## Executing lazyIntermediateOperations() : ######## ");
19-
Stream<String> studentStream = students.stream()
20-
.map(student -> {
21-
System.out.printf("In Map : %s\n", student.getName());
22-
return student.getName().toUpperCase();
23-
});
24-
19+
Stream<String> studentStream = students.stream().map(student -> {
20+
System.out.printf("In Map : %s\n", student.getName());
21+
return student.getName().toUpperCase();
22+
});
23+
2524
System.out.println("After map statement");
2625
Thread.sleep(5000);
2726
System.out.println("Thread is in Running state now");

src/com/onlyfullstack/stream/ShortCircuit.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.onlyfullstack.stream;
22

33
import java.util.Arrays;
4-
import java.util.stream.Stream;
54

65
public class ShortCircuit {
76

src/com/onlyfullstack/stream/Stream.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.onlyfullstack.stream;
22

3-
import java.util.ArrayList;
43
import java.util.Arrays;
54
import java.util.List;
65
import java.util.Set;

0 commit comments

Comments
 (0)