1 /*
2 * Copyright 2011-2020 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.springframework.data.mapping;
17
18 import org.springframework.lang.Nullable;
19
20 /**
21 * Value object to capture {@link Association}s.
22 *
23 * @param <P> {@link PersistentProperty}s the association connects.
24 * @author Jon Brisbin <jbrisbin@vmware.com>
25 * @author Mark Paluch
26 */
27 public class Association<P extends PersistentProperty<P>> {
28
29 private final P inverse;
30 private final @Nullable P obverse;
31
32 /**
33 * Creates a new {@link Association} between the two given {@link PersistentProperty}s.
34 *
35 * @param inverse
36 * @param obverse
37 */
38 public Association(P inverse, @Nullable P obverse) {
39 this.inverse = inverse;
40 this.obverse = obverse;
41 }
42
43 public P getInverse() {
44 return inverse;
45 }
46
47 @Nullable
48 public P getObverse() {
49 return obverse;
50 }
51 }
52