Skip to contentPackage: ParticipationConstraints
ParticipationConstraints
Coverage
1: /*
2: * JOPA
3: * Copyright (C) 2023 Czech Technical University in Prague
4: *
5: * This library is free software; you can redistribute it and/or
6: * modify it under the terms of the GNU Lesser General Public
7: * License as published by the Free Software Foundation; either
8: * version 3.0 of the License, or (at your option) any later version.
9: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library.
17: */
18: package cz.cvut.kbss.jopa.model.annotations;
19:
20: import java.lang.annotation.Documented;
21: import java.lang.annotation.ElementType;
22: import java.lang.annotation.Retention;
23: import java.lang.annotation.RetentionPolicy;
24: import java.lang.annotation.Target;
25:
26: /**
27: * Allows to specify participation constraints of an attribute.
28: */
29: @Documented
30: @Retention(RetentionPolicy.RUNTIME)
31: @Target({ElementType.FIELD,ElementType.METHOD})
32: public @interface ParticipationConstraints {
33:
34: ParticipationConstraint[] value() default {};
35:
36: /**
37: * (Optional) Whether the annotated field can be empty, i.e. {@code null} for singular attributes and {@code null}
38: * or empty for plural attributes (this is up to the implementation).
39: * <p>
40: * This attributes corresponds to using a {@link ParticipationConstraint} with {@code min = 1}.
41: * <p>
42: * In case there are participation constraints specified as values of this annotation, the {@code nonEmpty} value is
43: * ignored.
44: *
45: * @return Whether the field can be empty
46: */
47: boolean nonEmpty() default false;
48: }