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 Details

    • create

      static <T extends Resource> T create(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. The implementation uses ServiceLoader to find a ResourceFactory that creates the resource, i.e. that does not return Optional.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 type
      project - the project
      args - the additional arguments
      Returns:
      the resource
    • create

      static <T extends Resource> T create(ResourceType<T> type, Object... args)
      Short for create(type, null, args).
      Type Parameters:
      T - the generic resource type
      Parameters:
      type - the resource type
      args - the additional arguments
      Returns:
      the resource
    • newResource

      <T extends Resource> Optional<T> newResource(ResourceType<T> type, Project project, Object... args)
      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 type
      project - the project
      args - the additional arguments
      Returns:
      the result. Optional.empty() if the resource cannot be created by the factory instance.