66 67 final Map<String, ResourcePoolEntry> moduleContent = new LinkedHashMap<>(); 68 // lazily initialized 69 private ModuleDescriptor descriptor; 70 final String name; 71 72 private ResourcePoolModuleImpl(String name) { 73 this.name = name; 74 } 75 76 @Override 77 public String name() { 78 return name; 79 } 80 81 @Override 82 public Optional<ResourcePoolEntry> findEntry(String path) { 83 if (!path.startsWith("/")) { 84 path = "/" + path; 85 } 86 if (!path.startsWith("/" + name)) { 87 path = "/" + name + path; 88 } 89 return Optional.ofNullable(moduleContent.get(path)); 90 } 91 92 @Override 93 public ModuleDescriptor descriptor() { 94 if (descriptor == null) { 95 descriptor = readModuleDescriptor(this); 96 } 97 return descriptor; 98 } 99 100 @Override 101 public Set<String> packages() { 102 Set<String> pkgs = new HashSet<>(); 103 moduleContent.values().stream().filter(m -> m.type(). 104 equals(ResourcePoolEntry.Type.CLASS_OR_RESOURCE)).forEach(res -> { 105 // Module metadata only contains packages with .class files 106 if (ImageFileCreator.isClassPackage(res.path())) { 107 String[] split = ImageFileCreator.splitPath(res.path()); | 66 67 final Map<String, ResourcePoolEntry> moduleContent = new LinkedHashMap<>(); 68 // lazily initialized 69 private ModuleDescriptor descriptor; 70 final String name; 71 72 private ResourcePoolModuleImpl(String name) { 73 this.name = name; 74 } 75 76 @Override 77 public String name() { 78 return name; 79 } 80 81 @Override 82 public Optional<ResourcePoolEntry> findEntry(String path) { 83 if (!path.startsWith("/")) { 84 path = "/" + path; 85 } 86 if (!path.startsWith("/" + name + "/")) { 87 path = "/" + name + path; // path already starts with '/' 88 } 89 return Optional.ofNullable(moduleContent.get(path)); 90 } 91 92 @Override 93 public ModuleDescriptor descriptor() { 94 if (descriptor == null) { 95 descriptor = readModuleDescriptor(this); 96 } 97 return descriptor; 98 } 99 100 @Override 101 public Set<String> packages() { 102 Set<String> pkgs = new HashSet<>(); 103 moduleContent.values().stream().filter(m -> m.type(). 104 equals(ResourcePoolEntry.Type.CLASS_OR_RESOURCE)).forEach(res -> { 105 // Module metadata only contains packages with .class files 106 if (ImageFileCreator.isClassPackage(res.path())) { 107 String[] split = ImageFileCreator.splitPath(res.path()); |