org.eclipse.modisco.infra.discovery.core

## Class AbstractDiscoverer<T>

- java.lang.Object
- - org.eclipse.modisco.infra.discovery.core.AbstractDiscoverer<T>

Type Parameters:
  `T` - the type of source of the discovery

All Implemented Interfaces:
  IDiscoverer<T>

Direct Known Subclasses:
  AbstractModelDiscoverer

    public abstract class AbstractDiscoverer<T>
    extends java.lang.Object
    implements IDiscoverer<T>

A base implementation of Discoverer, which proposes to centralize some parameters properties and behaviors :

- Control of source and parameters values at the beginning of a discovery
- Usual tests of source type
- Source refresh management

### Constructor Summary

Constructors
Constructor and Description
`AbstractDiscoverer()`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`void` `discoverElement(T source, IProgressMonitor monitor)` Generic method to launch a discovery from a source element.
`static boolean` `isAFolder(java.lang.Object source)` Utility service for usual isApplicableTo test.
`static boolean` `isAJavaProject(java.lang.Object source)` Utility service for usual isApplicableTo test.
`static boolean` `isAnIFileWithExtension(java.lang.Object source, java.lang.String fileExtension)` Utility service for usual isApplicableTo test.
`static boolean` `isAProject(java.lang.Object source)` Utility service for usual isApplicableTo test.
`void` `setRefreshSourceBeforeDiscovery(boolean value)`

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.eclipse.modisco.infra.discovery.core.IDiscoverer

`isApplicableTo`

### Constructor Detail

#### AbstractDiscoverer

    public AbstractDiscoverer()

### Method Detail

#### setRefreshSourceBeforeDiscovery

    @Parameter(name="REFRESH_SOURCE_BEFORE",
               description="Whether to refresh the source at the beginning of the discovery. Refresh behavior depends on the Discoverer implementation. The standard refresh behavior is to test if the source is an org.eclipse.core.resources.IResource and call its refreshLocal() method.")
    public void setRefreshSourceBeforeDiscovery(boolean value)

#### discoverElement

    public void discoverElement(T source,
                                IProgressMonitor monitor)
                         throws DiscoveryException

Description copied from interface: `IDiscoverer`
Generic method to launch a discovery from a source element.

Additional discovery parameters values (input or output) should be managed using fields and methods annotated with a `Parameter` annotation. See the class `AbstractDiscoverer` as an example.

Specified by:
  `discoverElement` in interface `IDiscoverer<T>`
Parameters:
  `source` - the selected object.
  `monitor` - a progress monitor used to report progress and respond to cancellation. May be a `NullProgressMonitor` if no monitor is to be used.
Throws:
  `DiscoveryException` - abnormal discovery process termination

#### isAJavaProject

    public static boolean isAJavaProject(java.lang.Object source)

Utility service for usual isApplicableTo test.

Returns:
  true if the source is an accessible instance of `IJavaProject` or `IProject` with java nature.

#### isAFolder

    public static boolean isAFolder(java.lang.Object source)

Utility service for usual isApplicableTo test.

Returns:
  true if the source is an instance of `IFolder`

#### isAProject

    public static boolean isAProject(java.lang.Object source)

Utility service for usual isApplicableTo test.

Returns:
  true if the source is an instance of `IProject`.

#### isAnIFileWithExtension

    public static boolean isAnIFileWithExtension(java.lang.Object source,
                                                 java.lang.String fileExtension)

Utility service for usual isApplicableTo test.

Parameters:
  `source` -
  `fileExtension` - the file extension to test. May be `null` to test if there is no extension. May be empty to test if a file name ends with a dot character.
Returns:
  `true` if the source is an instance of `IFile` with the given extension.