This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.api.reporting.services; | |
| import java.util.List; | |
| import java.util.Optional; | |
| import com.api.reporting.exceptions.ProductNotFoundException; | |
| import com.api.reporting.models.Product; | |
| import com.api.reporting.respositories.ProductRepository; | |
| import org.springframework.beans.factory.annotation.Autowired; | |
| import org.springframework.stereotype.Service; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public interface ProductService { | |
| Product getProductById(long productId); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.api.reporting.controllers; | |
| import com.api.reporting.models.Product; | |
| import com.api.reporting.services.ProductService; | |
| import org.springframework.beans.factory.annotation.Autowired; | |
| import org.springframework.http.HttpStatus; | |
| import org.springframework.http.ResponseEntity; | |
| import org.springframework.web.bind.annotation.*; | |
| import java.util.List; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.api.reporting.respositories; | |
| import com.api.reporting.models.Product; | |
| import org.springframework.beans.factory.annotation.Autowired; | |
| import org.springframework.data.mongodb.core.MongoTemplate; | |
| import org.springframework.data.mongodb.core.query.Criteria; | |
| import org.springframework.data.mongodb.core.query.Query; | |
| import java.util.List; | |
| import java.util.Optional; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import com.api.reporting.models.Product; | |
| import java.util.List; | |
| import java.util.Optional; | |
| public interface ProductRepositoryCustom { | |
| Optional<List<Product>> findByName(String name); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.api.reporting.models; | |
| import org.springframework.data.annotation.Id; | |
| import org.springframework.data.mongodb.core.mapping.Document; | |
| @Document(collection = "products") | |
| public class Product { | |
| @Id | |
| private long id; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import com.api.reporting.models.Product; | |
| import org.springframework.data.mongodb.repository.MongoRepository; | |
| public interface ProductRepository extends MongoRepository<Product, Long> { | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import com.api.reporting.models.Product; | |
| import org.springframework.data.mongodb.repository.MongoRepository; | |
| public interface ProductRepository extends MongoRepository<Product, Long>, ProductRepositoryCustom { | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Arrays; | |
| import java.util.List; | |
| import java.util.function.Consumer; | |
| public class LambdaDemo { | |
| public static void main(String[] args) { | |
| // CREATE SEPARATE CONSUMER TO MAKE STRINGS UPPERCASE | |
| List<String> names = Arrays.asList("Sam", "Bob", "Sim"); | |
| // APPLY LAMBDA |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Arrays; | |
| import java.util.List; | |
| import java.util.function.Consumer; | |
| import java.util.function.Predicate; | |
| import java.util.stream.Collectors; | |
| class Person { | |
| private String name; | |
| private int age; |