Skip to content

Commit

Permalink
Solved checkstyle violations
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcelCoding committed Mar 31, 2021
1 parent 38847c0 commit d9879d3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
import reactor.core.publisher.Mono;

@Slf4j
public class Utils {
public final class Utils {

private Utils() {
throw new UnsupportedOperationException();
}

public static <T> Mono<T> handleError(final ClientResponse response, final Class<T> clazz) {
if (response.statusCode().equals(HttpStatus.OK)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.marcelcoding.luna.dwd.controller;

import com.github.marcelcoding.luna.dwd.dto.CurrentWeatherResponse;
import com.github.marcelcoding.luna.dwd.dto.SourcesResponse;
import com.github.marcelcoding.luna.dwd.dto.Source;
import com.github.marcelcoding.luna.dwd.dto.WeatherResponse;
import com.github.marcelcoding.luna.dwd.service.BrightSkyService;
import java.time.OffsetDateTime;
Expand All @@ -10,6 +10,7 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

@RestController
Expand Down Expand Up @@ -39,7 +40,7 @@ public Mono<CurrentWeatherResponse> currentWeather(
}

@GetMapping("stations")
public Mono<SourcesResponse> stations(
public Flux<Source> stations(
@RequestParam("lat") final float lat,
@RequestParam("lon") final float lon,
@RequestParam("radius") final int radius
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public Mono<CurrentWeatherResponse> weather(final float lat, final float lon) {
* @param radius is meters ({@code m})
* @return a {@link Flux} with all matching {@link Source}s
*/
public Mono<SourcesResponse> sources(final float lat, final float lon, final int radius) {
public Flux<Source> sources(final float lat, final float lon, final int radius) {
final QueryStringEncoder queryEncoder = new QueryStringEncoder("/sources");
queryEncoder.addParam("lat", String.valueOf(lat));
queryEncoder.addParam("lon", String.valueOf(lon));
Expand All @@ -85,7 +85,7 @@ public Mono<SourcesResponse> sources(final float lat, final float lon, final int

return this.client.get()
.uri(queryEncoder.toString())
.exchangeToMono(response -> Utils.handleError(response, SourcesResponse.class));
// .flatMapIterable(SourcesResponse::getSources);
.exchangeToMono(response -> Utils.handleError(response, SourcesResponse.class))
.flatMapIterable(SourcesResponse::getSources);
}
}

0 comments on commit d9879d3

Please sign in to comment.