001/* 002 * Copyright 2002-2012 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.beans.factory.parsing; 018 019import org.springframework.beans.factory.config.BeanDefinition; 020import org.springframework.beans.factory.config.BeanReference; 021 022/** 023 * Base implementation of {@link ComponentDefinition} that provides a basic implementation of 024 * {@link #getDescription} which delegates to {@link #getName}. Also provides a base implementation 025 * of {@link #toString} which delegates to {@link #getDescription} in keeping with the recommended 026 * implementation strategy. Also provides default implementations of {@link #getInnerBeanDefinitions} 027 * and {@link #getBeanReferences} that return an empty array. 028 * 029 * @author Rob Harrop 030 * @author Juergen Hoeller 031 * @since 2.0 032 */ 033public abstract class AbstractComponentDefinition implements ComponentDefinition { 034 035 /** 036 * Delegates to {@link #getName}. 037 */ 038 @Override 039 public String getDescription() { 040 return getName(); 041 } 042 043 /** 044 * Returns an empty array. 045 */ 046 @Override 047 public BeanDefinition[] getBeanDefinitions() { 048 return new BeanDefinition[0]; 049 } 050 051 /** 052 * Returns an empty array. 053 */ 054 @Override 055 public BeanDefinition[] getInnerBeanDefinitions() { 056 return new BeanDefinition[0]; 057 } 058 059 /** 060 * Returns an empty array. 061 */ 062 @Override 063 public BeanReference[] getBeanReferences() { 064 return new BeanReference[0]; 065 } 066 067 /** 068 * Delegates to {@link #getDescription}. 069 */ 070 @Override 071 public String toString() { 072 return getDescription(); 073 } 074 075}