Skip to content

Method: getPostRegister()

1: /*
2: * JOPA
3: * Copyright (C) 2024 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.sessions.util;
19:
20: import cz.cvut.kbss.jopa.model.descriptors.Descriptor;
21:
22: import java.util.ArrayList;
23: import java.util.Collection;
24: import java.util.Collections;
25: import java.util.List;
26: import java.util.Objects;
27: import java.util.function.Consumer;
28:
29: public class CloneConfiguration {
30:
31: private Descriptor descriptor;
32:
33: private final List<Consumer<Object>> postRegister = new ArrayList<>(1);
34:
35: private boolean forPersistenceContext;
36:
37: private CloneConfiguration() {
38: }
39:
40: public CloneConfiguration(Descriptor descriptor, boolean forPersistenceContext) {
41: this.descriptor = Objects.requireNonNull(descriptor);
42: this.forPersistenceContext = forPersistenceContext;
43: }
44:
45: public CloneConfiguration addPostRegisterHandlers(Collection<Consumer<Object>> handlers) {
46: postRegister.addAll(handlers);
47: return this;
48: }
49:
50: public Descriptor getDescriptor() {
51: return descriptor;
52: }
53:
54: public List<Consumer<Object>> getPostRegister() {
55: return Collections.unmodifiableList(postRegister);
56: }
57:
58: public CloneConfiguration forPersistenceContext(boolean value) {
59: this.forPersistenceContext = value;
60: return this;
61: }
62:
63: public boolean isForPersistenceContext() {
64: return forPersistenceContext;
65: }
66:
67: public static CloneConfiguration withDescriptor(Descriptor descriptor) {
68: final CloneConfiguration configuration = new CloneConfiguration();
69: configuration.descriptor = descriptor;
70: return configuration;
71: }
72: }