View Javadoc
1   /*
2    * SPDX-FileCopyrightText: Copyright (c) 2012-2025 Yegor Bugayenko
3    * SPDX-License-Identifier: MIT
4    */
5   package com.jcabi.manifests;
6   
7   import java.io.InputStream;
8   import java.util.Collection;
9   import java.util.Collections;
10  
11  /**
12   * Manifests in streams.
13   *
14   * Append attributes from {@code MANIFEST.MF} file:
15   *
16   * <pre> Manifests.append(
17   *   new StreamsMfs(this.getClass().getResourceAsStream("MANIFEST.MF"))
18   * );</pre>
19   *
20   * <p>The class is immutable and thread-safe.
21   *
22   * @since 1.1
23   */
24  public final class StreamsMfs implements Mfs {
25  
26      /**
27       * Streams.
28       */
29      private final transient Collection<InputStream> streams;
30  
31      /**
32       * Ctor.
33       * @param stream Stream
34       */
35      public StreamsMfs(final InputStream stream) {
36          this(Collections.singleton(stream));
37      }
38  
39      /**
40       * Ctor.
41       * @param list Files
42       */
43      public StreamsMfs(final Collection<InputStream> list) {
44          this.streams = Collections.unmodifiableCollection(list);
45      }
46  
47      @Override
48      public Collection<InputStream> fetch() {
49          return Collections.unmodifiableCollection(this.streams);
50      }
51  
52  }