rename of() -> combine()

Signed-off-by: Ludovic Orban <lorban@bitronix.be>
This commit is contained in:
Ludovic Orban 2022-08-03 13:06:32 +02:00
parent f2a20436d4
commit cb348c8d15
12 changed files with 18 additions and 20 deletions

View File

@ -779,7 +779,7 @@ public class HTTPServerDocs
ResourceHandler handler = new ResourceHandler(); ResourceHandler handler = new ResourceHandler();
// For multiple directories, use ResourceCollection. // For multiple directories, use ResourceCollection.
Resource resource = Resource.of( Resource resource = Resource.combine(
ResourceFactory.of(handler).newResource("/path/to/static/resources/"), ResourceFactory.of(handler).newResource("/path/to/static/resources/"),
ResourceFactory.of(handler).newResource("/another/path/to/static/resources/") ResourceFactory.of(handler).newResource("/another/path/to/static/resources/")
); );

View File

@ -136,7 +136,7 @@ public class ResourceCacheTest
.map(ResourceFactory.root()::newResource) .map(ResourceFactory.root()::newResource)
.toList(); .toList();
ResourceCollection rc = Resource.of(resourceList); ResourceCollection rc = Resource.combine(resourceList);
List<Resource> r = rc.getResources(); List<Resource> r = rc.getResources();
MimeTypes mime = new MimeTypes(); MimeTypes mime = new MimeTypes();
@ -168,7 +168,7 @@ public class ResourceCacheTest
.map(ResourceFactory.root()::newResource) .map(ResourceFactory.root()::newResource)
.toList(); .toList();
ResourceCollection rc = Resource.of(resourceList); ResourceCollection rc = Resource.combine(resourceList);
List<Resource> r = rc.getResources(); List<Resource> r = rc.getResources();
MimeTypes mime = new MimeTypes(); MimeTypes mime = new MimeTypes();

View File

@ -100,11 +100,10 @@ public abstract class Resource
* @return A Resource of multiple resources. * @return A Resource of multiple resources.
* @see ResourceCollection * @see ResourceCollection
*/ */
public static ResourceCollection of(List<Resource> resources) public static ResourceCollection combine(Collection<Resource> resources)
{ {
if (resources == null || resources.isEmpty()) if (resources == null || resources.isEmpty())
throw new IllegalArgumentException("No resources"); throw new IllegalArgumentException("No resources");
return new ResourceCollection(resources); return new ResourceCollection(resources);
} }
@ -114,11 +113,10 @@ public abstract class Resource
* @return A Resource of multiple resources. * @return A Resource of multiple resources.
* @see ResourceCollection * @see ResourceCollection
*/ */
public static ResourceCollection of(Resource... resources) public static ResourceCollection combine(Resource... resources)
{ {
if (resources == null || resources.length == 0) if (resources == null || resources.length == 0)
throw new IllegalArgumentException("No resources"); throw new IllegalArgumentException("No resources");
return new ResourceCollection(List.of(resources)); return new ResourceCollection(List.of(resources));
} }

View File

@ -70,7 +70,7 @@ public class ResourceCollectionTest
Path two = MavenTestingUtils.getTestResourcePathDir("org/eclipse/jetty/util/resource/two"); Path two = MavenTestingUtils.getTestResourcePathDir("org/eclipse/jetty/util/resource/two");
Path three = MavenTestingUtils.getTestResourcePathDir("org/eclipse/jetty/util/resource/three"); Path three = MavenTestingUtils.getTestResourcePathDir("org/eclipse/jetty/util/resource/three");
ResourceCollection rc = Resource.of( ResourceCollection rc = Resource.combine(
resourceFactory.newResource(one), resourceFactory.newResource(one),
resourceFactory.newResource(two), resourceFactory.newResource(two),
resourceFactory.newResource(three) resourceFactory.newResource(three)
@ -91,7 +91,7 @@ public class ResourceCollectionTest
Path two = MavenTestingUtils.getTestResourcePathDir("org/eclipse/jetty/util/resource/two"); Path two = MavenTestingUtils.getTestResourcePathDir("org/eclipse/jetty/util/resource/two");
Path three = MavenTestingUtils.getTestResourcePathDir("org/eclipse/jetty/util/resource/three"); Path three = MavenTestingUtils.getTestResourcePathDir("org/eclipse/jetty/util/resource/three");
ResourceCollection rc = Resource.of( ResourceCollection rc = Resource.combine(
resourceFactory.newResource(one), resourceFactory.newResource(one),
resourceFactory.newResource(two), resourceFactory.newResource(two),
resourceFactory.newResource(three) resourceFactory.newResource(three)
@ -113,7 +113,7 @@ public class ResourceCollectionTest
Path two = MavenTestingUtils.getTestResourcePathDir("org/eclipse/jetty/util/resource/two"); Path two = MavenTestingUtils.getTestResourcePathDir("org/eclipse/jetty/util/resource/two");
Path three = MavenTestingUtils.getTestResourcePathDir("org/eclipse/jetty/util/resource/three"); Path three = MavenTestingUtils.getTestResourcePathDir("org/eclipse/jetty/util/resource/three");
ResourceCollection rc = Resource.of( ResourceCollection rc = Resource.combine(
resourceFactory.newResource(one), resourceFactory.newResource(one),
resourceFactory.newResource(two), resourceFactory.newResource(two),
resourceFactory.newResource(three) resourceFactory.newResource(three)
@ -139,7 +139,7 @@ public class ResourceCollectionTest
Path three = MavenTestingUtils.getTestResourcePathDir("org/eclipse/jetty/util/resource/three"); Path three = MavenTestingUtils.getTestResourcePathDir("org/eclipse/jetty/util/resource/three");
Path twoDir = MavenTestingUtils.getTestResourcePathDir("org/eclipse/jetty/util/resource/two/dir"); Path twoDir = MavenTestingUtils.getTestResourcePathDir("org/eclipse/jetty/util/resource/two/dir");
ResourceCollection rc1 = Resource.of( ResourceCollection rc1 = Resource.combine(
List.of( List.of(
resourceFactory.newResource(one), resourceFactory.newResource(one),
resourceFactory.newResource(two), resourceFactory.newResource(two),
@ -147,7 +147,7 @@ public class ResourceCollectionTest
) )
); );
ResourceCollection rc2 = Resource.of( ResourceCollection rc2 = Resource.combine(
List.of( List.of(
// the original ResourceCollection // the original ResourceCollection
rc1, rc1,

View File

@ -64,7 +64,7 @@ public class OverlayManager
resourceBases.add(webApp.getResourceBase()); resourceBases.add(webApp.getResourceBase());
} }
webApp.setBaseResource(Resource.of(resourceBases)); webApp.setBaseResource(Resource.combine(resourceBases));
} }
/** /**

View File

@ -241,6 +241,6 @@ public class QuickStartDescriptorProcessor extends IterativeDescriptorProcessor
List<Resource> collection = new ArrayList<>(); List<Resource> collection = new ArrayList<>();
collection.add(context.getResourceBase()); collection.add(context.getResourceBase());
collection.addAll(metaInfResources); collection.addAll(metaInfResources);
context.setBaseResource(Resource.of(collection)); context.setBaseResource(Resource.combine(collection));
} }
} }

View File

@ -332,7 +332,7 @@ public class MetaInfConfiguration extends AbstractConfiguration
List<Resource> collection = new ArrayList<>(); List<Resource> collection = new ArrayList<>();
collection.add(context.getResourceBase()); collection.add(context.getResourceBase());
collection.addAll(resources); collection.addAll(resources);
context.setBaseResource(Resource.of(collection)); context.setBaseResource(Resource.combine(collection));
} }
} }

View File

@ -452,7 +452,7 @@ public class WebInfConfiguration extends AbstractConfiguration
webInf = _resourceFactory.newResource(extractedWebInfDir.getCanonicalPath()); webInf = _resourceFactory.newResource(extractedWebInfDir.getCanonicalPath());
Resource rc = Resource.of(webInf, webApp); Resource rc = Resource.combine(webInf, webApp);
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
LOG.debug("context.baseResource={}", rc); LOG.debug("context.baseResource={}", rc);

View File

@ -64,7 +64,7 @@ public class OverlayManager
resourceBases.add(webApp.getBaseResource()); resourceBases.add(webApp.getBaseResource());
} }
webApp.setBaseResource(Resource.of(resourceBases)); webApp.setBaseResource(Resource.combine(resourceBases));
} }
/** /**

View File

@ -242,6 +242,6 @@ public class QuickStartDescriptorProcessor extends IterativeDescriptorProcessor
List<Resource> collection = new ArrayList<>(); List<Resource> collection = new ArrayList<>();
collection.add(context.getBaseResource()); collection.add(context.getBaseResource());
collection.addAll(metaInfResources); collection.addAll(metaInfResources);
context.setBaseResource(Resource.of(collection)); context.setBaseResource(Resource.combine(collection));
} }
} }

View File

@ -325,7 +325,7 @@ public class MetaInfConfiguration extends AbstractConfiguration
List<Resource> collection = new ArrayList<>(); List<Resource> collection = new ArrayList<>();
collection.add(context.getBaseResource()); collection.add(context.getBaseResource());
collection.addAll(resources); collection.addAll(resources);
context.setBaseResource(Resource.of(collection)); context.setBaseResource(Resource.combine(collection));
} }
} }

View File

@ -450,7 +450,7 @@ public class WebInfConfiguration extends AbstractConfiguration
webInf = _resourceFactory.newResource(extractedWebInfDir.getCanonicalPath()); webInf = _resourceFactory.newResource(extractedWebInfDir.getCanonicalPath());
Resource rc = Resource.of(webInf, webApp); Resource rc = Resource.combine(webInf, webApp);
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
LOG.debug("context.baseResource={}", rc); LOG.debug("context.baseResource={}", rc);