info.archinnov.achilles.annotations.CodecRegistry Maven / Gradle / Ivy
/*
* Copyright (C) 2012-2016 DuyHai DOAN
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package info.archinnov.achilles.annotations;
import java.lang.annotation.*;
/**
*
* Marker annotation to be used on configuration class
* for compile-time code generation. The type (class,
* abstract class or interface) having this
* annotation will expose a list of codecs to be used by
* Achilles during source code parsing.
*
* Usage:
*
*
*
* public class MyOwnType {...}
* {@literal @}CodecRegistry
* public [class | abstract class | interface] MyCodecRegistry {
*
* //Source type = int, target type = String (according to IntToStringCodec codec)
* {@literal @}Codec(IntToStringCodec.class)
* private int intToString;
*
* //Source type = MyOwnType, target type = String (according to MyOwnTypeToStringCodec codec)
* {@literal @}Codec(MyOwnTypeToStringCodec.class)
* private MyOwnType myOwnTypeToString;
*
* //Source type = AnotherBean, target type = String (because of {@literal @}JSON)
* {@literal @}JSON
* private AnotherBean beanToJSON;
*
* //Source type = MyEnum, target type = int (because of Encoding.ORDINAL)
* {@literal @}Enumerated(Encoding.ORDINAL)
* private MyEnum enumToOrdinal;
* }
*
*
*
* Note: it is possible to declare several codec registries in your source code,
* just annotate them with {@literal @}CodecRegistry
*
* Warning: it is not possible to declare 2 different codecs for the same source type
* for all registered codec registries.
* Achilles will raise a compilation error when encountering such case. Ex:
*
*
*
* {@literal @}CodecRegistry
* public class MyCodecRegistry {
*
* {@literal @}Codec(MyOwnTypeToStringCodec.class)
* private MyOwnType myOwnTypeToString;
*
* // ERROR, not possible to have a 2nd codec for the same source type MyOwnType
* {@literal @}Codec(MyOwnTypeToBytesCodec.class)
* private MyOwnType myOwnTypeToBytes;
* }
*
*
* @see Codec Registry
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
@Documented
public @interface CodecRegistry {
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy