Skip to contentPackage: Converter
Converter
Coverage
1: /**
2: * Copyright (C) 2023 Czech Technical University in Prague
3: *
4: * This program is free software: you can redistribute it and/or modify it under
5: * the terms of the GNU General Public License as published by the Free Software
6: * Foundation, either version 3 of the License, or (at your option) any
7: * later version.
8: *
9: * This program is distributed in the hope that it will be useful, but WITHOUT
10: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12: * details. You should have received a copy of the GNU General Public License
13: * along with this program. If not, see <http://www.gnu.org/licenses/>.
14: */
15: package cz.cvut.kbss.jopa.model.annotations;
16:
17: import java.lang.annotation.ElementType;
18: import java.lang.annotation.Retention;
19: import java.lang.annotation.RetentionPolicy;
20: import java.lang.annotation.Target;
21:
22: /**
23: * Specifies that the annotated class is a converter and defines its scope.
24: * <p>
25: * A converter class must be annotated with the Converter annotation. If the autoApply element is specified as true, the
26: * persistence provider must automatically apply the converter to all mapped attributes of the specified target type for
27: * all entities in the persistence unit.
28: * <p>
29: * Note that Id attributes, version attributes, relationship attributes, and attributes explicitly annotated as
30: * Enumerated or Temporal will not be converted.
31: * <p>
32: * Note that if autoApply is true, the Convert annotation may be used to override or disable auto-apply conversion on a
33: * per-attribute basis.
34: * <p>
35: * If autoApply is false, only those attributes of the target type for which the Convert annotation has been specified
36: * will be converted.
37: * <p>
38: * If there is more than one converter defined for the same target type, the Convert annotation should be used to
39: * explicitly specify which converter to use.
40: */
41: @Target(ElementType.TYPE)
42: @Retention(RetentionPolicy.RUNTIME)
43: public @interface Converter {
44:
45: /**
46: * Whether to apply the converter automatically.
47: */
48: boolean autoApply() default false;
49: }