Interface ResourceFactory
- All Known Implementing Classes:
CoreResourceFactory, EclipseResourceFactory, JavaResourceFactory, MvnRepoResourceFactory
public interface ResourceFactory
Defines both an interface for factories that create
Resources and
factory methods for invoking an appropriate factory.-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Resource>
Tcreate(ResourceType<T> type, Object... args) Short forcreate(type, null, args).static <T extends Resource>
Tcreate(ResourceType<T> type, Project project, Object... args) Returns a new resource with the given type, passing the given arguments to the constructor of the resource.newResource(ResourceType<T> type, Project project, Object... args) Returns a new resource of the given type if the factory instance can create it.
-
Method Details
-
create
Returns a new resource with the given type, passing the given arguments to the constructor of the resource. The implementation usesServiceLoaderto find aResourceFactorythat creates the resource, i.e. that does not returnOptional.empty()when<T>newResource(org.jdrupes.builder.api.ResourceType<T>,org.jdrupes.builder.api.Project,java.lang.Object...)is called.- Type Parameters:
T- the generic resource type- Parameters:
type- the resource typeproject- the projectargs- the additional arguments- Returns:
- the resource
-
create
Short forcreate(type, null, args).- Type Parameters:
T- the generic resource type- Parameters:
type- the resource typeargs- the additional arguments- Returns:
- the resource
-
newResource
Returns a new resource of the given type if the factory instance can create it.- Type Parameters:
T- the generic resource type- Parameters:
type- the resource typeproject- the projectargs- the additional arguments- Returns:
- the result.
Optional.empty()if the resource cannot be created by the factory instance.
-