Last active
October 25, 2020 20:07
-
-
Save lofidewanto/3ddd7ddf67fd7091a443d884719941e3 to your computer and use it in GitHub Desktop.
IndexedDB with Java Patterns - Using Dagger2 - Consumer
This file contains 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.github.lofi.client; | |
import java.util.logging.Logger; | |
import javax.inject.Inject; | |
import javax.inject.Singleton; | |
@Singleton | |
public class ProductService { | |
private static Logger logger = Logger.getLogger(ProductService.class.getName()); | |
private ProductIdbRepository productRepository; | |
private ProductRandomCreator productRandomCreator; | |
@Inject | |
public ProductService(ProductIdbRepository productRepository, ProductRandomCreator productRandomCreator) { | |
this.productRepository = productRepository; | |
this.productRandomCreator = productRandomCreator; | |
} | |
public Product createProduct() { | |
String key = productRandomCreator.getRandomId(); | |
String type = productRandomCreator.geRandomType(); | |
Integer price = productRandomCreator.getRandomPrice(); | |
Product product = new Product.Builder(key, "Lofi " + key).setType(type).setAmount(10).setPrice(price).build(); | |
logger.info(product.toString()); | |
productRepository.persist(product); | |
return product; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment