View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.eclipse.aether.spi.connector.checksum;
20  
21  import java.util.Collection;
22  import java.util.List;
23  
24  /**
25   * Component performing selection of {@link ChecksumAlgorithmFactory} based on known factory names.
26   * Note: this component is NOT meant to be implemented or extended by client, is exposed ONLY to make clients
27   * able to get {@link ChecksumAlgorithmFactory} instances.
28   *
29   * @noimplement This interface is not intended to be implemented by clients.
30   * @noextend This interface is not intended to be extended by clients.
31   * @since 1.8.0
32   */
33  public interface ChecksumAlgorithmFactorySelector {
34      /**
35       * Returns factory for given algorithm name, or throws if algorithm not supported.
36       *
37       * @throws IllegalArgumentException if asked algorithm name is not supported.
38       */
39      ChecksumAlgorithmFactory select(String algorithmName);
40  
41      /**
42       * Returns a list of factories in same order as algorithm names are ordered, or throws if any of the
43       * algorithm name is not supported. The returned list has equal count of elements as passed in collection of names,
44       * and if names contains duplicated elements, the returned list of algorithms will have duplicates as well.
45       *
46       * @throws IllegalArgumentException if any asked algorithm name is not supported.
47       * @throws NullPointerException if passed in list of names is {@code null}.
48       * @since 1.9.0
49       */
50      List<ChecksumAlgorithmFactory> selectList(Collection<String> algorithmNames);
51  
52      /**
53       * Returns immutable collection of all supported algorithms. This set represents ALL the algorithms supported by
54       * Resolver, and is NOT in any relation to given repository layout used checksums, returned by method {@link
55       * org.eclipse.aether.spi.connector.layout.RepositoryLayout#getChecksumAlgorithmFactories()} (in fact, is super set
56       * of it).
57       */
58      Collection<ChecksumAlgorithmFactory> getChecksumAlgorithmFactories();
59  
60      /**
61       * Returns {@code true} if passed in extension matches any known checksum extension. The extension string may
62       * start or contain dot ("."), but does not have to. In former case "ends with" is checked
63       * (i.e. "jar.sha1" -&gt; true; ".sha1" -&gt; true) while in latter equality (i.e. "sha1" -&gt; true).
64       *
65       * @since 1.9.3
66       */
67      boolean isChecksumExtension(String extension);
68  }