Created
January 23, 2015 16:10
-
-
Save vorburger/6abefdcbad6fe3ff9d06 to your computer and use it in GitHub Desktop.
Eclipse Optional<IJavaProject> getJavaProject(IProject project)
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
// TODO This probably already exists somewhere? | |
public Optional<IJavaProject> getJavaProject(IProject project) { | |
try { | |
if (project.hasNature(JavaCore.NATURE_ID)) { | |
IJavaProject javaProject = JavaCore.create(project); | |
return Optional.of(javaProject); | |
} else { | |
return Optional.absent(); | |
} | |
} catch (CoreException e) { | |
logger.error("CoreException from IProject.hasNature(JavaCore.NATURE_ID)" , e); | |
return Optional.absent(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment