Class NatureUtils


  • public final class NatureUtils
    extends java.lang.Object
    Some utility methods for natures.
    Author:
    Holger Eichelberger
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private NatureUtils()
      Prevents this class from being instantiated from outside.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void addNature​(org.eclipse.core.resources.IProject project, java.lang.String nature, org.eclipse.core.runtime.IProgressMonitor monitor)
      Adds a nature to the given project.
      static boolean hasNature​(org.eclipse.core.resources.IProject project, java.lang.String... natures)
      Returns whether at least one of the given natures is defined on the given project.
      static void removeNature​(org.eclipse.core.resources.IProject project, java.lang.String nature, org.eclipse.core.runtime.IProgressMonitor monitor)
      Removes a nature from the given project.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • NatureUtils

        private NatureUtils()
        Prevents this class from being instantiated from outside.
    • Method Detail

      • hasNature

        public static boolean hasNature​(org.eclipse.core.resources.IProject project,
                                        java.lang.String... natures)
                                 throws org.eclipse.core.runtime.CoreException
        Returns whether at least one of the given natures is defined on the given project.
        Parameters:
        project - the project to check the nature on
        natures - the natures to be checked
        Returns:
        true if at least one nature in natures is a nature of project, false else
        Throws:
        org.eclipse.core.runtime.CoreException - if project does not exist or is not open
      • addNature

        public static void addNature​(org.eclipse.core.resources.IProject project,
                                     java.lang.String nature,
                                     org.eclipse.core.runtime.IProgressMonitor monitor)
                              throws org.eclipse.core.runtime.CoreException
        Adds a nature to the given project.
        Parameters:
        project - the project to add the nature to
        nature - the nature to be added
        monitor - an optional progress monitor (may be null)
        Throws:
        org.eclipse.core.runtime.CoreException - if project does not exist or is not open
      • removeNature

        public static void removeNature​(org.eclipse.core.resources.IProject project,
                                        java.lang.String nature,
                                        org.eclipse.core.runtime.IProgressMonitor monitor)
                                 throws org.eclipse.core.runtime.CoreException
        Removes a nature from the given project.
        Parameters:
        project - the project to remove the nature from
        nature - the nature to be remove
        monitor - an optional progress monitor (may be null)
        Throws:
        org.eclipse.core.runtime.CoreException - if project does not exist or is not open