Skip to content

Commit

Permalink
Code cleanup (iluwatar#1461)
Browse files Browse the repository at this point in the history
* Code cleanup

* Fix flux tests

* Fix checkstyle errors

* Fix compile error
  • Loading branch information
iluwatar authored Jul 30, 2020
1 parent 5381387 commit 417f21e
Show file tree
Hide file tree
Showing 243 changed files with 1,154 additions and 1,162 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private class DocumentImplementation extends AbstractDocument {
}
}

private DocumentImplementation document = new DocumentImplementation(new HashMap<>());
private final DocumentImplementation document = new DocumentImplementation(new HashMap<>());

@Test
public void shouldPutAndGetValue() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
*/
public class AbstractFactoryTest {

private App app = new App();
private final App app = new App();
private KingdomFactory elfFactory;
private KingdomFactory orcFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
*/
public class ConfigureForDosVisitorTest {

private TestLogger logger = TestLoggerFactory.getTestLogger(ConfigureForDosVisitor.class);
private final TestLogger logger = TestLoggerFactory.getTestLogger(ConfigureForDosVisitor.class);

@Test
public void testVisitForZoom() {
Expand Down
4 changes: 2 additions & 2 deletions adapter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ And captain expects an implementation of `RowingBoat` interface to be able to mo
```java
public class Captain {

private RowingBoat rowingBoat;
private final RowingBoat rowingBoat;
// default constructor and setter for rowingBoat
public Captain(RowingBoat rowingBoat) {
this.rowingBoat = rowingBoat;
Expand All @@ -75,7 +75,7 @@ public class FishingBoatAdapter implements RowingBoat {

private static final Logger LOGGER = LoggerFactory.getLogger(FishingBoatAdapter.class);

private FishingBoat boat;
private final FishingBoat boat;

public FishingBoatAdapter() {
boat = new FishingBoat();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*/
public class FishingBoatAdapter implements RowingBoat {

private FishingBoat boat;
private final FishingBoat boat;

public FishingBoatAdapter() {
boat = new FishingBoat();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void testSuccessfulCall() {
}

private static class StaticRandomProvider implements RandomProvider {
private double value;
private final double value;

StaticRandomProvider(double value) {
this.value = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private static class CompletableResult<T> implements AsyncResult<T> {
void setValue(T value) {
this.value = value;
this.state = COMPLETED;
this.callback.ifPresent(ac -> ac.onComplete(value, Optional.<Exception>empty()));
this.callback.ifPresent(ac -> ac.onComplete(value, Optional.empty()));
synchronized (lock) {
lock.notifyAll();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*/
public class Client {

private BusinessDelegate businessDelegate;
private final BusinessDelegate businessDelegate;

public Client(BusinessDelegate businessDelegate) {
this.businessDelegate = businessDelegate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@
*/
public enum ServiceType {

EJB, JMS;
EJB, JMS
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
*/
public class VirtualMachine {

private Stack<Integer> stack = new Stack<>();
private final Stack<Integer> stack = new Stack<>();

private Wizard[] wizards = new Wizard[2];
private final Wizard[] wizards = new Wizard[2];

/**
* Constructor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void testGetHealth() {
bytecode[2] = LITERAL.getIntValue();
bytecode[3] = 50; // health amount
bytecode[4] = SET_HEALTH.getIntValue();
bytecode[5] = LITERAL.getIntValue();;
bytecode[5] = LITERAL.getIntValue();
bytecode[6] = wizardNumber;
bytecode[7] = GET_HEALTH.getIntValue();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
public enum CachingPolicy {
THROUGH("through"), AROUND("around"), BEHIND("behind"), ASIDE("aside");

private String policy;
private final String policy;

CachingPolicy(String policy) {
this.policy = policy;
Expand Down
2 changes: 1 addition & 1 deletion chain/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Then the request handler hierarchy
```java
public abstract class RequestHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(RequestHandler.class);
private RequestHandler next;
private final RequestHandler next;

public RequestHandler(RequestHandler next) {
this.next = next;
Expand Down
2 changes: 1 addition & 1 deletion chain/src/main/java/com/iluwatar/chain/RequestHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public abstract class RequestHandler {

private static final Logger LOGGER = LoggerFactory.getLogger(RequestHandler.class);

private RequestHandler next;
private final RequestHandler next;

public RequestHandler(RequestHandler next) {
this.next = next;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,7 @@ public boolean equals(Object obj) {
} else if (!model.equals(other.model)) {
return false;
}
if (year != other.year) {
return false;
}
return true;
return year == other.year;
}

public String getMake() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* A Person class that has the list of cars that the person owns and use.
*/
public class Person {
private List<Car> cars;
private final List<Car> cars;

/**
* Constructor to create an instance of person.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
public class AppTest {
private static final Logger LOGGER = LoggerFactory.getLogger(AppTest.class);

private List<Car> cars = CarFactory.createCars();
private final List<Car> cars = CarFactory.createCars();

@Test
public void testGetModelsAfter2000UsingFor() {
Expand Down
4 changes: 2 additions & 2 deletions command/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public class Wizard {

private static final Logger LOGGER = LoggerFactory.getLogger(Wizard.class);

private Deque<Command> undoStack = new LinkedList<>();
private Deque<Command> redoStack = new LinkedList<>();
private final Deque<Command> undoStack = new LinkedList<>();
private final Deque<Command> redoStack = new LinkedList<>();

public Wizard() {}

Expand Down
86 changes: 43 additions & 43 deletions command/src/main/java/com/iluwatar/command/Size.java
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
/*
* The MIT License
* Copyright © 2014-2019 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

package com.iluwatar.command;

/**
* Enumeration for target size.
*/
public enum Size {

SMALL("small"), NORMAL("normal");

private String title;

Size(String title) {
this.title = title;
}

@Override
public String toString() {
return title;
}
}
/*
* The MIT License
* Copyright © 2014-2019 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

package com.iluwatar.command;

/**
* Enumeration for target size.
*/
public enum Size {

SMALL("small"), NORMAL("normal");

private final String title;

Size(String title) {
this.title = title;
}

@Override
public String toString() {
return title;
}
}
86 changes: 43 additions & 43 deletions command/src/main/java/com/iluwatar/command/Visibility.java
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
/*
* The MIT License
* Copyright © 2014-2019 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

package com.iluwatar.command;

/**
* Enumeration for target visibility.
*/
public enum Visibility {

VISIBLE("visible"), INVISIBLE("invisible");

private String title;

Visibility(String title) {
this.title = title;
}

@Override
public String toString() {
return title;
}
}
/*
* The MIT License
* Copyright © 2014-2019 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

package com.iluwatar.command;

/**
* Enumeration for target visibility.
*/
public enum Visibility {

VISIBLE("visible"), INVISIBLE("invisible");

private final String title;

Visibility(String title) {
this.title = title;
}

@Override
public String toString() {
return title;
}
}
4 changes: 2 additions & 2 deletions command/src/main/java/com/iluwatar/command/Wizard.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public class Wizard {

private static final Logger LOGGER = LoggerFactory.getLogger(Wizard.class);

private Deque<Command> undoStack = new LinkedList<>();
private Deque<Command> redoStack = new LinkedList<>();
private final Deque<Command> undoStack = new LinkedList<>();
private final Deque<Command> redoStack = new LinkedList<>();

public Wizard() {
// comment to ignore sonar issue: LEVEL critical
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*/

public class EmployeeDatabase extends Database<Order> {
private Hashtable<String, Order> data;
private final Hashtable<String, Order> data;

public EmployeeDatabase() {
this.data = new Hashtable<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*/

public class MessagingDatabase extends Database<MessageRequest> {
private Hashtable<String, MessageRequest> data;
private final Hashtable<String, MessageRequest> data;

public MessagingDatabase() {
this.data = new Hashtable<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

public class PaymentDatabase extends Database<PaymentRequest> {

private Hashtable<String, PaymentRequest> data;
private final Hashtable<String, PaymentRequest> data;

public PaymentDatabase() {
this.data = new Hashtable<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

public class QueueDatabase extends Database<QueueTask> {

private Queue<QueueTask> data;
private final Queue<QueueTask> data;
public List<Exception> exceptionsList;

public QueueDatabase(Exception... exc) {
Expand Down
Loading

0 comments on commit 417f21e

Please sign in to comment.