001/*
002 * Copyright 2002-2019 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.config;
018
019import java.io.Serializable;
020
021import org.springframework.lang.Nullable;
022
023/**
024 * Simple marker class for an individually autowired property value, to be added
025 * to {@link BeanDefinition#getPropertyValues()} for a specific bean property.
026 *
027 * <p>At runtime, this will be replaced with a {@link DependencyDescriptor}
028 * for the corresponding bean property's write method, eventually to be resolved
029 * through a {@link AutowireCapableBeanFactory#resolveDependency} step.
030 *
031 * @author Juergen Hoeller
032 * @since 5.2
033 * @see AutowireCapableBeanFactory#resolveDependency
034 * @see BeanDefinition#getPropertyValues()
035 * @see org.springframework.beans.factory.support.BeanDefinitionBuilder#addAutowiredProperty
036 */
037@SuppressWarnings("serial")
038public final class AutowiredPropertyMarker implements Serializable {
039
040        /**
041         * The canonical instance for the autowired marker value.
042         */
043        public static final Object INSTANCE = new AutowiredPropertyMarker();
044
045
046        private AutowiredPropertyMarker() {
047        }
048
049        private Object readResolve() {
050                return INSTANCE;
051        }
052
053
054        @Override
055        public boolean equals(@Nullable Object obj) {
056                return (this == obj);
057        }
058
059        @Override
060        public int hashCode() {
061                return AutowiredPropertyMarker.class.hashCode();
062        }
063
064        @Override
065        public String toString() {
066                return "(autowired)";
067        }
068
069}