Skip to content
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

dependecy-injection-injector-hw #715

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ihorvasylenko23
Copy link

No description provided.

Copy link
Contributor

@nacenik nacenik left a comment

Choose a reason for hiding this comment

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

Good solution, let's improve it)

Comment on lines 60 to 64
Map<Class<?>, Class<?>> interfaceImplementations = Map.of(
ProductParser.class, ProductParserImpl.class,
FileReaderService.class, FileReaderServiceImpl.class,
ProductService.class, ProductServiceImpl.class
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Make this map a class-level field and initialize it once

Comment on lines 68 to 71
if (interfaceClazz.isInterface()) {
return interfaceImplementations.get(interfaceClazz);
}
return interfaceClazz;
Copy link
Contributor

Choose a reason for hiding this comment

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

you can improve your solution using ternary

Comment on lines 39 to 42
if (clazzImplementationInstance == null) {
clazzImplementationInstance = createNewInstance(clazz);
}
return clazzImplementationInstance;
Copy link
Contributor

Choose a reason for hiding this comment

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

you can improve your solution using ternary

src/main/java/mate.academy/lib/Injector.java Show resolved Hide resolved
Copy link
Contributor

@nacenik nacenik left a comment

Choose a reason for hiding this comment

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

LGTM! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants