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.apache.maven.api.services; 20 21 import java.util.List; 22 import java.util.Map; 23 import java.util.Optional; 24 25 import org.apache.maven.api.Service; 26 import org.apache.maven.api.annotations.Nonnull; 27 28 public interface Lookup extends Service { 29 /** 30 * Performs a lookup for given typed component. 31 * 32 * @param type The component type. 33 * @return The component. 34 * @param <T> The component type. 35 * @throws LookupException if no such component or there is some provisioning related issue. 36 */ 37 @Nonnull 38 <T> T lookup(Class<T> type); 39 40 /** 41 * Performs a lookup for given typed component. 42 * 43 * @param type The component type. 44 * @param name The component name. 45 * @return The component. 46 * @param <T> The component type. 47 * @throws LookupException if no such component or there is some provisioning related issue. 48 */ 49 @Nonnull 50 <T> T lookup(Class<T> type, String name); 51 52 /** 53 * Performs a lookup for optional typed component. 54 * 55 * @param type The component type. 56 * @return Optional carrying component or empty optional if no such component. 57 * @param <T> The component type. 58 * @throws LookupException if there is some provisioning related issue. 59 */ 60 @Nonnull 61 <T> Optional<T> lookupOptional(Class<T> type); 62 63 /** 64 * Performs a lookup for optional typed component. 65 * 66 * @param type The component type. 67 * @param name The component name. 68 * @return Optional carrying component or empty optional if no such component. 69 * @param <T> The component type. 70 * @throws LookupException if there is some provisioning related issue. 71 */ 72 @Nonnull 73 <T> Optional<T> lookupOptional(Class<T> type, String name); 74 75 /** 76 * Performs a collection lookup for given typed components. 77 * 78 * @param type The component type. 79 * @return The list of components. The list may be empty if no components found. 80 * @param <T> The component type. 81 * @throws LookupException if there is some provisioning related issue. 82 */ 83 @Nonnull 84 <T> List<T> lookupList(Class<T> type); 85 86 /** 87 * Performs a collection lookup for given typed components. 88 * 89 * @param type The component type. 90 * @return The map of components. The map may be empty if no components found. 91 * @param <T> The component type. 92 * @throws LookupException if there is some provisioning related issue. 93 */ 94 @Nonnull 95 <T> Map<String, T> lookupMap(Class<T> type); 96 }