java.lang.Object
net.ssehub.easy.producer.eclipse.persistency.eclipse.NatureUtils

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

    Fields
    Modifier and Type
    Field
    Description
    private static Predicate<String>
     
  • Constructor Summary

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

    Modifier and Type
    Method
    Description
    static void
    addNature(org.eclipse.core.resources.IProject project, String nature, org.eclipse.core.runtime.IProgressMonitor monitor)
    Adds a nature to the given project.
    static void
    ensureBuilder(org.eclipse.core.resources.IProject project, String includeBuilder, String excludeBuilder, org.eclipse.core.runtime.IProgressMonitor monitor)
    Ensures a builder, while removing another one.
    static boolean
    hasNature(org.eclipse.core.resources.IProject project, 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, String nature, org.eclipse.core.runtime.IProgressMonitor monitor)
    Removes a nature from the given project.
    static void
    Allows filtering out natures.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • NatureUtils

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

    • hasNature

      public static boolean hasNature(org.eclipse.core.resources.IProject project, String... natures) throws org.eclipse.core.runtime.CoreException
      Returns whether at least one of the given natures is defined on the given project. Filtered out natures are always found.
      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
    • ensureBuilder

      public static void ensureBuilder(org.eclipse.core.resources.IProject project, String includeBuilder, String excludeBuilder, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException
      Ensures a builder, while removing another one.
      Parameters:
      project - the project to check the builders on
      includeBuilder - the builder id to include
      excludeBuilder - the builder id to exclude
      monitor - an optional progress monitor (may be null)
      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, String nature, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException
      Adds a nature to the given project. Filtered out natures are not added.
      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, String nature, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException
      Removes a nature from the given project. Filtered out natures are not removed.
      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
    • setNatureFilter

      public static void setNatureFilter(Predicate<String> filter)
      Allows filtering out natures. [testing].
      Parameters:
      filter - the nature filter