Make fields private where possible
This commit is contained in:
@@ -28,13 +28,13 @@ public class HotelSummary implements Serializable {
|
||||
private static final MathContext MATH_CONTEXT = new MathContext(2,
|
||||
RoundingMode.HALF_UP);
|
||||
|
||||
private City city;
|
||||
private final City city;
|
||||
|
||||
private String name;
|
||||
private final String name;
|
||||
|
||||
private Double averageRating;
|
||||
private final Double averageRating;
|
||||
|
||||
private Integer averageRatingRounded;
|
||||
private final Integer averageRatingRounded;
|
||||
|
||||
public HotelSummary(City city, String name, Double averageRating) {
|
||||
this.city = city;
|
||||
|
||||
@@ -22,9 +22,9 @@ public class RatingCount implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Rating rating;
|
||||
private final Rating rating;
|
||||
|
||||
private long count;
|
||||
private final long count;
|
||||
|
||||
public RatingCount(Rating rating, long count) {
|
||||
this.rating = rating;
|
||||
|
||||
@@ -82,7 +82,7 @@ class HotelServiceImpl implements HotelService {
|
||||
|
||||
private static class ReviewsSummaryImpl implements ReviewsSummary {
|
||||
|
||||
private Map<Rating, Long> ratingCount;
|
||||
private final Map<Rating, Long> ratingCount;
|
||||
|
||||
public ReviewsSummaryImpl(List<RatingCount> ratingCounts) {
|
||||
this.ratingCount = new HashMap<Rating, Long>();
|
||||
|
||||
@@ -26,7 +26,7 @@ import java.util.concurrent.atomic.AtomicLong;
|
||||
public class InMemoryMessageRespository implements MessageRepository {
|
||||
|
||||
private static AtomicLong counter = new AtomicLong();
|
||||
private ConcurrentMap<Long, Message> messages = new ConcurrentHashMap<Long, Message>();
|
||||
private final ConcurrentMap<Long, Message> messages = new ConcurrentHashMap<Long, Message>();
|
||||
|
||||
@Override
|
||||
public Iterable<Message> findAll() {
|
||||
|
||||
@@ -34,7 +34,7 @@ import sample.ui.MessageRepository;
|
||||
@Controller
|
||||
@RequestMapping("/")
|
||||
public class MessageController {
|
||||
private MessageRepository messageRepository;
|
||||
private final MessageRepository messageRepository;
|
||||
|
||||
@Autowired
|
||||
public MessageController(MessageRepository messageRepository) {
|
||||
|
||||
@@ -31,7 +31,7 @@ public class SimpleClientWebSocketHandler extends TextWebSocketHandler {
|
||||
|
||||
private final GreetingService greetingService;
|
||||
|
||||
private CountDownLatch latch;
|
||||
private final CountDownLatch latch;
|
||||
|
||||
@Autowired
|
||||
public SimpleClientWebSocketHandler(GreetingService greetingService,
|
||||
|
||||
@@ -83,7 +83,7 @@ public class SampleWebSocketsApplicationTests {
|
||||
@Configuration
|
||||
static class ClientConfiguration implements CommandLineRunner {
|
||||
|
||||
private CountDownLatch latch = new CountDownLatch(1);
|
||||
private final CountDownLatch latch = new CountDownLatch(1);
|
||||
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user