001/*
002 * Copyright 2002-2009 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.annotation;
018
019import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
020
021/**
022 * Enumeration determining autowiring status: that is, whether a bean should
023 * have its dependencies automatically injected by the Spring container using
024 * setter injection. This is a core concept in Spring DI.
025 *
026 * <p>Available for use in annotation-based configurations, such as for the
027 * AspectJ AnnotationBeanConfigurer aspect.
028 *
029 * @author Rod Johnson
030 * @author Juergen Hoeller
031 * @since 2.0
032 * @see org.springframework.beans.factory.annotation.Configurable
033 * @see org.springframework.beans.factory.config.AutowireCapableBeanFactory
034 */
035public enum Autowire {
036
037        /**
038         * Constant that indicates no autowiring at all.
039         */
040        NO(AutowireCapableBeanFactory.AUTOWIRE_NO),
041
042        /**
043         * Constant that indicates autowiring bean properties by name.
044         */
045        BY_NAME(AutowireCapableBeanFactory.AUTOWIRE_BY_NAME),
046
047        /**
048         * Constant that indicates autowiring bean properties by type.
049         */
050        BY_TYPE(AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE);
051
052
053        private final int value;
054
055
056        Autowire(int value) {
057                this.value = value;
058        }
059
060        public int value() {
061                return this.value;
062        }
063
064        /**
065         * Return whether this represents an actual autowiring value.
066         * @return whether actual autowiring was specified
067         * (either BY_NAME or BY_TYPE)
068         */
069        public boolean isAutowire() {
070                return (this == BY_NAME || this == BY_TYPE);
071        }
072
073}