Format source code for documentation reference purposes.

This commit is contained in:
John Blum
2019-04-30 23:04:44 -07:00
parent 48ad20244e
commit 934f03ebce
2 changed files with 11 additions and 5 deletions

View File

@@ -26,8 +26,8 @@ import example.app.temp.model.TemperatureReading;
// tag::class[]
public interface TemperatureReadingRepository extends CrudRepository<TemperatureReading, Long> {
List<TemperatureReading> findByTimestampGreaterThanAndTimestampLessThan(Long timestampLowerBound,
Long timestampUpperBound);
List<TemperatureReading> findByTimestampGreaterThanAndTimestampLessThan(
Long timestampLowerBound, Long timestampUpperBound);
@Query("SELECT count(*) FROM /TemperatureReadings WHERE temperature >= 212")
Integer countBoilingTemperatureReadings();

View File

@@ -31,8 +31,10 @@ import example.app.temp.repo.TemperatureReadingRepository;
@SuppressWarnings("unused")
public class TemperatureSensor {
private final PrimitiveIterator.OfInt temperatureStream = new Random(System.currentTimeMillis())
.ints(-100, 400).iterator();
private final PrimitiveIterator.OfInt temperatureStream =
new Random(System.currentTimeMillis())
.ints(-100, 400)
.iterator();
private final TemperatureReadingRepository repository;
@@ -45,7 +47,11 @@ public class TemperatureSensor {
@Scheduled(fixedRateString = "${example.app.temp.sensor.reading.schedule.rate:1000}")
public void readTemperature() {
this.repository.save(log(TemperatureReading.newTemperatureReading(temperatureStream.nextInt())));
TemperatureReading temperatureReading =
TemperatureReading.newTemperatureReading(temperatureStream.nextInt());
this.repository.save(log(temperatureReading));
}
private TemperatureReading log(TemperatureReading temperatureReading) {