Merge pull request #4457 from eugenp/BAEL-1661_v2

formatting
This commit is contained in:
Loredana Crusoveanu 2018-06-14 13:31:48 +03:00 committed by GitHub
commit 0105456ae2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 67 additions and 67 deletions

View File

@ -16,14 +16,14 @@ public class Config implements WebMvcConfigurer {
@Override @Override
public void addViewControllers(ViewControllerRegistry registry) { public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("index"); registry.addViewController("/")
.setViewName("index");
registry.setOrder(Ordered.HIGHEST_PRECEDENCE); registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
} }
@Bean @Bean
public ITemplateResolver templateResolver() { public ITemplateResolver templateResolver() {
ClassLoaderTemplateResolver resolver ClassLoaderTemplateResolver resolver = new ClassLoaderTemplateResolver();
= new ClassLoaderTemplateResolver();
resolver.setPrefix("templates/books/"); resolver.setPrefix("templates/books/");
resolver.setSuffix(".html"); resolver.setSuffix(".html");
resolver.setTemplateMode(TemplateMode.HTML); resolver.setTemplateMode(TemplateMode.HTML);

View File

@ -16,7 +16,7 @@ public class InMemoryBookService implements BookService {
@Override @Override
public List<Book> findAll() { public List<Book> findAll() {
return new ArrayList(booksDB.values()); return new ArrayList<>(booksDB.values());
} }
@Override @Override
@ -29,14 +29,14 @@ public class InMemoryBookService implements BookService {
} }
Map<Long, Book> bookMap = books.stream() Map<Long, Book> bookMap = books.stream()
.collect(Collectors.toMap( .collect(Collectors.toMap(Book::getId, Function.identity()));
Book::getId, Function.identity()));
booksDB.putAll(bookMap); booksDB.putAll(bookMap);
} }
private Long getNextId(){ private Long getNextId() {
return booksDB.keySet().stream() return booksDB.keySet()
.stream()
.mapToLong(value -> value) .mapToLong(value -> value)
.max() .max()
.orElse(0) + 1; .orElse(0) + 1;

View File

@ -5,9 +5,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
@SpringBootApplication( @SpringBootApplication(exclude = { SecurityAutoConfiguration.class, DataSourceAutoConfiguration.class })
exclude = {SecurityAutoConfiguration.class,
DataSourceAutoConfiguration.class})
public class ListBindingApplication { public class ListBindingApplication {
public static void main(String[] args) { public static void main(String[] args) {

View File

@ -41,7 +41,9 @@ public class MultipleBooksController {
@GetMapping(value = "/edit") @GetMapping(value = "/edit")
public String showEditForm(Model model) { public String showEditForm(Model model) {
List<Book> books = new ArrayList<>(); List<Book> books = new ArrayList<>();
bookService.findAll().iterator().forEachRemaining(books::add); bookService.findAll()
.iterator()
.forEachRemaining(books::add);
model.addAttribute("form", new BooksCreationDto(books)); model.addAttribute("form", new BooksCreationDto(books));