-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
commit #824
base: master
Are you sure you want to change the base?
commit #824
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good job for first try!
contentFromFile.stream() | ||
.map(PARSER_FILE::parseLine) | ||
.forEach(transaction -> operationStrategyMap | ||
.get(Operation.checkTypeOperation(transaction.getOperation())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would create an OperationStrategy class, which will just be responsible for the logic of obtaining a handler for the desired operation.
@@ -0,0 +1,5 @@ | |||
package core.basesyntax.service; | |||
|
|||
public interface FruitService { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public interface FruitService { | |
public interface ReportService { |
import java.util.Map; | ||
|
||
public class FruitServiceImpl implements FruitService { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public class FruitServiceImpl implements FruitService { | ||
|
||
@Override | ||
public String getReport() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potentially, it's better not to use internal storage, so we're hardwired to the class and it can't be used for anything else. Processing in the same way, only take the map not from storage, but pass it as a parameter to the method, but when calling, pass it from storage.
import java.util.List; | ||
|
||
public class ReaderServiceImpl implements ReaderService { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} catch (IOException e) { | ||
throw new RuntimeException("Can't read from file " + filePath); | ||
} | ||
return content; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return content; |
import java.io.FileWriter; | ||
|
||
public class WriterServiceImpl implements WriterService { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import core.basesyntax.dto.Transaction; | ||
|
||
public class AddOperationHandler implements OperationHandler { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import core.basesyntax.dto.Transaction; | ||
|
||
public class BalanceOperationHandler implements OperationHandler { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import core.basesyntax.dto.Transaction; | ||
|
||
public class PurchaseOperationHandler implements OperationHandler { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please check the new commit |
No description provided.