001/* 002 * Copyright 2002-2020 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.core; 018 019/** 020 * Common interface for managing aliases. Serves as a super-interface for 021 * {@link org.springframework.beans.factory.support.BeanDefinitionRegistry}. 022 * 023 * @author Juergen Hoeller 024 * @since 2.5.2 025 */ 026public interface AliasRegistry { 027 028 /** 029 * Given a name, register an alias for it. 030 * @param name the canonical name 031 * @param alias the alias to be registered 032 * @throws IllegalStateException if the alias is already in use 033 * and may not be overridden 034 */ 035 void registerAlias(String name, String alias); 036 037 /** 038 * Remove the specified alias from this registry. 039 * @param alias the alias to remove 040 * @throws IllegalStateException if no such alias was found 041 */ 042 void removeAlias(String alias); 043 044 /** 045 * Determine whether the given name is defined as an alias 046 * (as opposed to the name of an actually registered component). 047 * @param name the name to check 048 * @return whether the given name is an alias 049 */ 050 boolean isAlias(String name); 051 052 /** 053 * Return the aliases for the given name, if defined. 054 * @param name the name to check for aliases 055 * @return the aliases, or an empty array if none 056 */ 057 String[] getAliases(String name); 058 059}