Corrected Indentation using formatter. (#1541)

This commit is contained in:
Devendra Tiwari 2017-03-30 23:51:17 +05:30 committed by Grzegorz Piwowarek
parent e28dfe6a4a
commit ce589cc7b5
14 changed files with 119 additions and 145 deletions

View File

@ -10,7 +10,6 @@ public class AtomicLongMapTutorials {
atomicLongMap = AtomicLongMap.create(); atomicLongMap = AtomicLongMap.create();
} }
public void addKeys() { public void addKeys() {
atomicLongMap.addAndGet("apple", 250); atomicLongMap.addAndGet("apple", 250);
atomicLongMap.addAndGet("bat", 350); atomicLongMap.addAndGet("bat", 350);

View File

@ -11,9 +11,7 @@ public class ComparatorsExamples {
public static void main(String[] args) { public static void main(String[] args) {
List<Integer> integers = Arrays.asList(1, 2, 3, 4, 4, 6, 7, 8, 9, 10); List<Integer> integers = Arrays.asList(1, 2, 3, 4, 4, 6, 7, 8, 9, 10);
//This will return true
boolean isInAscendingOrder = Comparators.isInOrder(integers, new AscedingOrderComparator()); boolean isInAscendingOrder = Comparators.isInOrder(integers, new AscedingOrderComparator());
System.out.println(isInAscendingOrder); System.out.println(isInAscendingOrder);
} }

View File

@ -3,16 +3,12 @@ package com.baeldung.guava.tutorial;
import com.google.common.collect.Interner; import com.google.common.collect.Interner;
import com.google.common.collect.Interners; import com.google.common.collect.Interners;
import static com.google.common.collect.Interners.newBuilder;
public class InternerBuilderExample { public class InternerBuilderExample {
public static void main(String[] args) { public static void main(String[] args) {
Interner<Integer> interners = Interners.<Integer> newBuilder() Interner<Integer> interners = Interners.<Integer> newBuilder()
.concurrencyLevel(2) .concurrencyLevel(2)
.strong() .strong().<Integer> build();
.<Integer>build();
} }

View File

@ -4,7 +4,6 @@ import com.google.common.util.concurrent.Monitor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.function.BooleanSupplier;
public class MonitorExample { public class MonitorExample {
private List<String> students = new ArrayList<String>(); private List<String> students = new ArrayList<String>();
@ -12,7 +11,6 @@ public class MonitorExample {
private Monitor monitor = new Monitor(); private Monitor monitor = new Monitor();
public void addToCourse(String item) throws InterruptedException { public void addToCourse(String item) throws InterruptedException {
Monitor.Guard studentsBelowCapacity = monitor.newGuard(this::isStudentsCapacityUptoLimit); Monitor.Guard studentsBelowCapacity = monitor.newGuard(this::isStudentsCapacityUptoLimit);
monitor.enterWhen(studentsBelowCapacity); monitor.enterWhen(studentsBelowCapacity);

View File

@ -10,7 +10,8 @@ public class MoreCollectorsExample {
public static void main(String[] args) { public static void main(String[] args) {
List<Integer> numbers = Arrays.asList(1); List<Integer> numbers = Arrays.asList(1);
Optional<Integer> number = numbers.stream() Optional<Integer> number = numbers
.stream()
.map(e -> e * 2) .map(e -> e * 2)
.collect(MoreCollectors.toOptional()); .collect(MoreCollectors.toOptional());
} }

View File

@ -34,9 +34,6 @@ public class StreamsUtility {
//This will return 10 //This will return 10
Optional<Integer> lastItem = Streams.findLast(integers.stream()); Optional<Integer> lastItem = Streams.findLast(integers.stream());
Streams.zip( Streams.zip(Stream.of("candy", "chocolate", "bar"), Stream.of("$1", "$2", "$3"), (arg1, arg2) -> arg1 + ":" + arg2);
Stream.of("candy", "chocolate", "bar"),
Stream.of("$1", "$2","$3"),
(arg1, arg2) -> arg1 + ":" + arg2);
} }
} }

View File

@ -1,5 +1,4 @@
import com.google.common.util.concurrent.AtomicLongMap; import com.google.common.util.concurrent.AtomicLongMap;
import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
@ -18,16 +17,12 @@ public class AtomicLongMapTests {
courses.put(GUAVA_COURSE_KEY, 78); courses.put(GUAVA_COURSE_KEY, 78);
} }
@Test @Test
public void accumulateAndGet_withLongBinaryOperator_thenSuccessful() { public void accumulateAndGet_withLongBinaryOperator_thenSuccessful() {
long noOfStudents = 56; long noOfStudents = 56;
long oldValue = courses.get(SPRING_COURSE_KEY); long oldValue = courses.get(SPRING_COURSE_KEY);
long totalNotesRequired = courses.accumulateAndGet( long totalNotesRequired = courses.accumulateAndGet("Guava", noOfStudents, (x, y) -> (x * y));
"Guava",
noOfStudents,
(x,y) -> (x * y));
assertEquals(totalNotesRequired, oldValue * noOfStudents); assertEquals(totalNotesRequired, oldValue * noOfStudents);
} }
@ -37,10 +32,7 @@ public void accumulateAndGet_withLongBinaryOperator_thenSuccessful(){
long noOfStudents = 56; long noOfStudents = 56;
long beforeUpdate = courses.get(SPRING_COURSE_KEY); long beforeUpdate = courses.get(SPRING_COURSE_KEY);
long onUpdate = courses.accumulateAndGet("Guava", long onUpdate = courses.accumulateAndGet("Guava", noOfStudents, (x, y) -> (x * y));
noOfStudents,
(x,y) -> (x * y)
);
long afterUpdate = courses.get(SPRING_COURSE_KEY); long afterUpdate = courses.get(SPRING_COURSE_KEY);
@ -52,9 +44,7 @@ public void accumulateAndGet_withLongBinaryOperator_thenSuccessful(){
public void updateAndGet_withLongUnaryOperator_thenSuccessful() { public void updateAndGet_withLongUnaryOperator_thenSuccessful() {
long beforeUpdate = courses.get(SPRING_COURSE_KEY); long beforeUpdate = courses.get(SPRING_COURSE_KEY);
long onUpdate = courses.updateAndGet( long onUpdate = courses.updateAndGet("Guava", (x) -> (x / 2));
"Guava",
(x) -> (x/2));
long afterUpdate = courses.get(SPRING_COURSE_KEY); long afterUpdate = courses.get(SPRING_COURSE_KEY);

View File

@ -2,7 +2,9 @@ import com.google.common.collect.Comparators;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import java.util.*; import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.function.Function; import java.util.function.Function;
import java.util.function.ToDoubleFunction; import java.util.function.ToDoubleFunction;
import java.util.function.ToIntFunction; import java.util.function.ToIntFunction;
@ -30,7 +32,6 @@ public class ComparatorsUnitTests {
Assert.assertFalse(isInAscendingOrder); Assert.assertFalse(isInAscendingOrder);
} }
private class AscendingOrderComparator<I extends Number> implements Comparator<Integer> { private class AscendingOrderComparator<I extends Number> implements Comparator<Integer> {
@Override @Override

View File

@ -18,7 +18,6 @@ public class GauavaStreamsTests {
numbers = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20); numbers = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20);
} }
@Test @Test
public void createStreamsWithCollection() { public void createStreamsWithCollection() {
//Deprecated API to create stream from collection //Deprecated API to create stream from collection
@ -87,8 +86,12 @@ public class GauavaStreamsTests {
@Test @Test
public void concatStreamsOfSameType() { public void concatStreamsOfSameType() {
Stream oddNumbers = Arrays.asList(1,3,5,7,9,11,13,15,17,19).stream(); Stream oddNumbers = Arrays
Stream evenNumbers = Arrays.asList(2,4,6,8,10,12,14,16,18,20).stream(); .asList(1, 3, 5, 7, 9, 11, 13, 15, 17, 19)
.stream();
Stream evenNumbers = Arrays
.asList(2, 4, 6, 8, 10, 12, 14, 16, 18, 20)
.stream();
Stream combinedStreams = Streams.concat(oddNumbers, evenNumbers); Stream combinedStreams = Streams.concat(oddNumbers, evenNumbers);
@ -118,7 +121,6 @@ public class GauavaStreamsTests {
StreamUtility.assertStreamEquals(combinedStreams, IntStream.concat(firstTwenty, nextTwenty)); StreamUtility.assertStreamEquals(combinedStreams, IntStream.concat(firstTwenty, nextTwenty));
} }
@Test @Test
public void findLastOfStream() { public void findLastOfStream() {
Optional<Integer> lastElement = Streams.findLast(numbers.stream()); Optional<Integer> lastElement = Streams.findLast(numbers.stream());
@ -134,7 +136,9 @@ public class GauavaStreamsTests {
Stream<String> mappedStream = Streams.mapWithIndex(stringSream, (str, index) -> str + ":" + index); Stream<String> mappedStream = Streams.mapWithIndex(stringSream, (str, index) -> str + ":" + index);
//Assert.assertNotNull(mappedStream); //Assert.assertNotNull(mappedStream);
Assert.assertEquals(mappedStream.findFirst().get(), "a:0"); Assert.assertEquals(mappedStream
.findFirst()
.get(), "a:0");
} }
@ -145,11 +149,10 @@ public class GauavaStreamsTests {
Stream<String> mappedStream = Streams.zip(stringSream, intStream, (str, index) -> str + ":" + index); Stream<String> mappedStream = Streams.zip(stringSream, intStream, (str, index) -> str + ":" + index);
//Assert.assertNotNull(mappedStream); //Assert.assertNotNull(mappedStream);
Assert.assertEquals(mappedStream.findFirst().get(), "a:1"); Assert.assertEquals(mappedStream
.findFirst()
.get(), "a:1");
} }
} }

View File

@ -10,8 +10,7 @@ public class InternBuilderUnitTests {
Interner<Integer> interners = Interners.<Integer> newBuilder() Interner<Integer> interners = Interners.<Integer> newBuilder()
.concurrencyLevel(2) .concurrencyLevel(2)
.strong() .strong().<Integer> build();
.<Integer>build();
Assert.assertNotNull(interners); Assert.assertNotNull(interners);
} }

View File

@ -2,14 +2,6 @@ import com.google.common.util.concurrent.Monitor;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import static com.google.common.util.concurrent.Uninterruptibles.joinUninterruptibly;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
public class MonitorUnitTests { public class MonitorUnitTests {
@Test @Test

View File

@ -13,24 +13,24 @@ public class MoreCollectorsUnitTests {
List<Integer> numbers = Arrays.asList(1); List<Integer> numbers = Arrays.asList(1);
Optional<Integer> number = numbers.stream() Optional<Integer> number = numbers
.stream()
.map(e -> e * 2) .map(e -> e * 2)
.collect(MoreCollectors.toOptional()); .collect(MoreCollectors.toOptional());
Assert.assertEquals(number.get(), new Integer(2)); Assert.assertEquals(number.get(), new Integer(2));
} }
@Test @Test
public void onlyElementTest() { public void onlyElementTest() {
List<Integer> numbers = Arrays.asList(1); List<Integer> numbers = Arrays.asList(1);
Integer number = numbers.stream() Integer number = numbers
.stream()
.map(e -> e * 2) .map(e -> e * 2)
.collect(MoreCollectors.onlyElement()); .collect(MoreCollectors.onlyElement());
Assert.assertEquals(number, new Integer(2)); Assert.assertEquals(number, new Integer(2));
} }
} }