Skip to content

Method: preventCaching()

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.change;
19:
20: import cz.cvut.kbss.jopa.model.metamodel.FieldSpecification;
21:
22: /**
23: * Record of a single change to an attribute.
24: */
25: public class ChangeRecord {
26:
27: private final FieldSpecification<?, ?> attribute;
28:
29: private Object newValue;
30:
31: private boolean preventsCaching;
32:
33: public ChangeRecord(FieldSpecification<?, ?> att, Object value) {
34: assert att != null;
35: this.attribute = att;
36: this.newValue = value;
37: }
38:
39: /**
40: * Returns the new value of the attribute.
41: *
42: * @return Object
43: */
44: public Object getNewValue() {
45: return newValue;
46: }
47:
48: /**
49: * Sets the new value of the attribute in case this change record needs to be updated.
50: *
51: * @param value The value to set
52: */
53: public void setNewValue(Object value) {
54: this.newValue = value;
55: }
56:
57: /**
58: * Gets the attribute to which this change record is bound.
59: *
60: * @return the attribute
61: */
62: public FieldSpecification<?, ?> getAttribute() {
63: return attribute;
64: }
65:
66: /**
67: * Marks this change record to prevent caching.
68: *
69: * @see #doesPreventCaching()
70: */
71: public void preventCaching() {
72: this.preventsCaching = true;
73: }
74:
75: /**
76: * Whether this change record prevents caching of the instance on which the change is applied.
77: *
78: * @return Whether this change record prevents caching
79: */
80: public boolean doesPreventCaching() {
81: return preventsCaching;
82: }
83:
84: @Override
85: public String toString() {
86: return "ChangeRecord{" +
87: "attribute='" + attribute.getName() + '\'' +
88: ", newValue=" + newValue +
89: ", preventsCaching=" + preventsCaching +
90: '}';
91: }
92: }