001/* 002 * Copyright 2012-2017 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 * http://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.boot.jackson; 018 019import java.lang.annotation.Documented; 020import java.lang.annotation.ElementType; 021import java.lang.annotation.Retention; 022import java.lang.annotation.RetentionPolicy; 023import java.lang.annotation.Target; 024 025import com.fasterxml.jackson.databind.JsonDeserializer; 026import com.fasterxml.jackson.databind.JsonSerializer; 027 028import org.springframework.core.annotation.AliasFor; 029import org.springframework.stereotype.Component; 030 031/** 032 * {@link Component} that provides {@link JsonSerializer} and/or {@link JsonDeserializer} 033 * implementations to be registered with Jackson when {@link JsonComponentModule} is in 034 * use. Can be used to annotate {@link JsonSerializer} or {@link JsonDeserializer} 035 * implementations directly or a class that contains them as inner-classes. For example: 036 * <pre class="code"> 037 * @JsonComponent 038 * public class CustomerJsonComponent { 039 * 040 * public static class Serializer extends JsonSerializer<Customer> { 041 * 042 * // ... 043 * 044 * } 045 * 046 * public static class Deserializer extends JsonDeserializer<Customer> { 047 * 048 * // ... 049 * 050 * } 051 * 052 * } 053 * 054 * </pre> 055 * 056 * @see JsonComponentModule 057 * @since 1.4.0 058 * @author Phillip Webb 059 */ 060@Target(ElementType.TYPE) 061@Retention(RetentionPolicy.RUNTIME) 062@Documented 063@Component 064public @interface JsonComponent { 065 066 /** 067 * The value may indicate a suggestion for a logical component name, to be turned into 068 * a Spring bean in case of an autodetected component. 069 * @return the component name 070 */ 071 @AliasFor(annotation = Component.class) 072 String value() default ""; 073 074}