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

SDK-311: Using Java 8 Optional Class #227

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

wikumChamith
Copy link
Contributor

@dkayiwa
Copy link
Member

dkayiwa commented Jun 27, 2023

@wikumChamith wikumChamith changed the title Sdk 311: Using Java 8 Optional Class SDK-311: Using Java 8 Optional Class Jun 28, 2023
@wikumChamith
Copy link
Contributor Author

What do you think about these changes in relation to these two articles?

http://dolszewski.com/java/java-8-optional-use-cases/

https://blogs.oracle.com/javamagazine/post/12-recipes-for-using-the-optional-class-as-its-meant-to-be-used

@dkayiwa I made some changes to the code.

@dkayiwa
Copy link
Member

dkayiwa commented Jun 29, 2023

Are all these changes supposed to be in this pull request?

@wikumChamith
Copy link
Contributor Author

Ohh, I think it is a problem with rebasing. I'll recheck

@wikumChamith wikumChamith force-pushed the SDK-311 branch 2 times, most recently from cee0f22 to b6f254b Compare June 29, 2023 14:30
@wikumChamith
Copy link
Contributor Author

@dkayiwa please review these new changes.

@dkayiwa
Copy link
Member

dkayiwa commented Jun 30, 2023

please review these new changes.

Feel free to continue with other pull requests as you wait for this to be reviewed. 😊

return mergeArtifactLists(childArtifacts, parentArtifacts);
}

public String getPlatformVersion(DistroHelper distroHelper, File directory) throws MojoExecutionException{
Artifact artifact = getDistroArtifact();
if (artifact != null) {
DistroProperties distroProperties = distroHelper.downloadDistroProperties(directory, artifact);
Copy link
Member

Choose a reason for hiding this comment

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

How is this change related to the Java 8 Optional class?

@@ -524,13 +495,7 @@ public void runSystemNpmCommandWithArgs(List<String> arguments) throws MojoExecu
}

private String getNpmSystemExecutable() {
String npm;
if (SystemUtils.IS_OS_WINDOWS) {
Copy link
Member

Choose a reason for hiding this comment

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

Is this also related to the Optional class?

}

public PackageJson getPackageJson(String jsonFilename) throws MojoExecutionException {
Reader reader = null;
File json;
if (mavenProject == null) {
json = new File(jsonFilename);
Copy link
Member

Choose a reason for hiding this comment

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

Is this also related to the Optional class?

@dkayiwa
Copy link
Member

dkayiwa commented Jul 10, 2023

@wikumChamith are all the changes in this pull request related to the Optional class?

@wikumChamith
Copy link
Contributor Author

@dkayiwa I made the changes mentioned above according to the 12th recipe of this article you shared.

https://blogs.oracle.com/javamagazine/post/12-recipes-for-using-the-optional-class-as-its-meant-to-be-used

@dkayiwa
Copy link
Member

dkayiwa commented Jul 11, 2023

Did you see my other comments in this pull request?

@wikumChamith
Copy link
Contributor Author

Did you see my other comments in this pull request?

Yes. I used the ternary operator because it is better than using if-else or optional ifPresent-get. It is also recommended here: https://blogs.oracle.com/javamagazine/post/12-recipes-for-using-the-optional-class-as-its-meant-to-be-used

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