Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 3 additions & 25 deletions src/main/java/hello/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,14 @@
import java.util.stream.Collectors;

import hello.model.Customer;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Info: Unreferenced Quote/Value model classes left behind

With the quote fetch removed, hello.model.Quote and hello.model.Value are now completely unreferenced (grep shows no remaining usages outside those files). The PR intentionally keeps them, but they are dead code that will silently rot; consider deleting them in a follow-up so the migration doesn't leave orphaned model classes.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed they're dead code now. Leaving them out of this PR deliberately: the scope handed to me was to remove the fetch logic and its imports, and deleting the model classes is a separate (if trivial) call that also touches a sibling session's expectations of the tree. Happy to drop Quote/Value here if the owner prefers — otherwise it's a clean follow-up.

import hello.model.Quote;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
public class Application implements CommandLineRunner {
Expand All @@ -34,25 +30,6 @@ public static void main(String[] args) {
for (String beanName : beanNames) {
System.out.println(beanName);
}

RestTemplate restTemplate = new RestTemplate();
Quote quote = restTemplate.getForObject("http://gturnquist-quoters.cfapps.io/api/random", Quote.class);
log.info(quote.toString());
}


@Bean
public RestTemplate restTemplate(RestTemplateBuilder builder) {
return builder.build();
}

@Bean
public CommandLineRunner run(RestTemplate restTemplate) throws Exception {
return args -> {
Quote quote = restTemplate.getForObject(
"http://gturnquist-quoters.cfapps.io/api/random", Quote.class);
log.info(quote.toString());
};
}


Expand Down Expand Up @@ -80,8 +57,9 @@ public void run(String... args) throws Exception {

log.info("Querying for customer records where first_name = 'Josh':");
jdbcTemplate.query(
"SELECT id, first_name, last_name FROM customers WHERE first_name = ?", new Object[]{"Josh"},
(rs, rowNum) -> new Customer(rs.getLong("id"), rs.getString("first_name"), rs.getString("last_name"))
"SELECT id, first_name, last_name FROM customers WHERE first_name = ?",
(rs, rowNum) -> new Customer(rs.getLong("id"), rs.getString("first_name"), rs.getString("last_name")),
"Josh"
).forEach(customer -> log.info(customer.toString()));
Comment on lines 59 to 63

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Info: Varargs query overload resolves unambiguously with a 2-arg lambda

The switch to query(String, RowMapper, Object...) was checked against the other JdbcTemplate.query overloads that end in varargs (ResultSetExtractor, RowCallbackHandler) as well as query(String, PreparedStatementSetter, RowMapper). All of those functional interfaces take a single argument, so the two-parameter lambda (rs, rowNum) -> ... can only match RowMapper; resolution is unambiguous and the returned List<Customer> is still iterated as before.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.


}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/hello/controller/GreetingController.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package hello.controller;

import hello.model.Greeting;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

Expand All @@ -12,7 +12,7 @@ public class GreetingController {
private static final String template = "Hello, %s!";
private final AtomicLong counter = new AtomicLong();

@RequestMapping("/")
@GetMapping("/")
public Greeting greeting(@RequestParam(value="name", defaultValue="World") String name) {
return new Greeting(counter.incrementAndGet(),
String.format(template, name));
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/hello/controller/HelloController.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import hello.model.Topic;
import hello.service.TopicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;

import java.time.LocalDate;
import java.time.LocalDateTime;
Expand Down Expand Up @@ -43,7 +43,7 @@ public class HelloController {
*
* @return
*/
@RequestMapping("/datetime")
@GetMapping("/datetime")
public String index() {
TimeClient myTimeClient = new SimpleTimeClient();
LocalDateTime localDateTime = LocalDateTime.now();
Expand All @@ -63,7 +63,7 @@ public String index() {
*
* @return
*/
@RequestMapping("/topic/string/operation")
@GetMapping("/topic/string/operation")
public String showStringOperation() {

String join = topicService.returnAllTopicIDWithStringSlicing();
Expand All @@ -84,7 +84,7 @@ public String showStringOperation() {
* File Operation in Java 8
* @return
*/
@RequestMapping("/topic/file/operation")
@GetMapping("/topic/file/operation")
public String showFileOperation() {
String findAllFilesInPathAndSort = topicService.findAllFilesInPathAndSort();
String findParticularFileInPathAndSort = topicService.findParticularFileInPathAndSort();
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/hello/controller/TopicController.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class TopicController {
* Get all Topic
* @return
*/
@RequestMapping("/topic")
@GetMapping("/topic")
public List<Topic> getAllTopics() {
return topicService.getAllTopics();
}
Expand All @@ -28,7 +28,7 @@ public List<Topic> getAllTopics() {
* @param id
* @return
*/
@RequestMapping("/topic/{id}")
@GetMapping("/topic/{id}")
public Topic getTopicWithID(@PathVariable String id) {
return topicService.getTopicWithId(id);
}
Expand All @@ -37,7 +37,7 @@ public Topic getTopicWithID(@PathVariable String id) {
* Add a new topic in list
* @param topic
*/
@RequestMapping(method = RequestMethod.POST, value = "/topic")
@PostMapping("/topic")
public void addTopic(@RequestBody Topic topic) {
topicService.addTopic(topic);
}
Expand All @@ -47,7 +47,7 @@ public void addTopic(@RequestBody Topic topic) {
* @param id
* @param topic
*/
@RequestMapping(method = RequestMethod.PUT, value = "/topic/{id}")
@PutMapping("/topic/{id}")
public void updateTopic(@PathVariable String id, @RequestBody Topic topic) {
topicService.updateTopic(id, topic);
}
Expand All @@ -57,7 +57,7 @@ public void updateTopic(@PathVariable String id, @RequestBody Topic topic) {
* Delete a topic with ID
* @param id
*/
@RequestMapping(method = RequestMethod.DELETE, value = "/topic/{id}")
@DeleteMapping("/topic/{id}")
public void deleteTopic(@PathVariable String id) {
topicService.deleteTopic(id);
}
Expand All @@ -67,7 +67,7 @@ public void deleteTopic(@PathVariable String id) {
* @param minLength
* @return
*/
@RequestMapping(value = "/topic/minimum/length/{minLength}")
@GetMapping("/topic/minimum/length/{minLength}")
public List<Topic> filterMinimumLengthForId(@PathVariable Integer minLength) {
return topicService.filterMinimumLengthForId(minLength);
}
Expand All @@ -77,7 +77,7 @@ public List<Topic> filterMinimumLengthForId(@PathVariable Integer minLength) {
* Sort with Id
* @return
*/
@RequestMapping("/topic/sort")
@GetMapping("/topic/sort")
public List<Topic> sortTopicsWithID() {
return topicService.sortTopicsWithID();
}
Expand Down