001package org.eclipse.aether.spi.connector.checksum; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import java.util.Collection; 023import java.util.List; 024 025import static java.util.stream.Collectors.toList; 026 027/** 028 * Component performing selection of {@link ChecksumAlgorithmFactory} based on known factory names. 029 * Note: this component is NOT meant to be implemented or extended by client, is exposed ONLY to make clients 030 * able to get {@link ChecksumAlgorithmFactory} instances. 031 * 032 * @noimplement This interface is not intended to be implemented by clients. 033 * @noextend This interface is not intended to be extended by clients. 034 * @since 1.8.0 035 */ 036public interface ChecksumAlgorithmFactorySelector 037{ 038 /** 039 * Returns factory for given algorithm name, or throws if algorithm not supported. 040 * 041 * @throws IllegalArgumentException if asked algorithm name is not supported. 042 */ 043 ChecksumAlgorithmFactory select( String algorithmName ); 044 045 /** 046 * Returns a list of factories for given algorithm names in order as collection is ordered, or throws if any of the 047 * algorithm name is not supported. The returned list has equal count of elements as passed in collection of names, 048 * and if names contains duplicated elements, the returned list of algorithms will have duplicates as well. 049 * 050 * @throws IllegalArgumentException if any asked algorithm name is not supported. 051 * @throws NullPointerException if passed in list of names is {@code null}. 052 * @since 1.9.0 053 */ 054 default List<ChecksumAlgorithmFactory> selectList( Collection<String> algorithmNames ) 055 { 056 return algorithmNames.stream() 057 .map( this::select ) 058 .collect( toList() ); 059 } 060 061 /** 062 * Returns a collection of supported algorithms. This set represents ALL the algorithms supported by Resolver, 063 * and is NOT in any relation to given repository layout used checksums, returned by method {@link 064 * org.eclipse.aether.spi.connector.layout.RepositoryLayout#getChecksumAlgorithmFactories()} (in fact, is super set 065 * of it). 066 */ 067 Collection<ChecksumAlgorithmFactory> getChecksumAlgorithmFactories(); 068}