Skip to content

Package: DateInstanceBuilder

DateInstanceBuilder

nameinstructionbranchcomplexitylinemethod
DateInstanceBuilder(CloneBuilderImpl, UnitOfWorkImpl)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
buildClone(Object, Field, Object, CloneConfiguration)
M: 0 C: 13
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
mergeChanges(Field, Object, Object, Object)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
populatesAttributes()
M: 0 C: 2
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /**
2: * Copyright (C) 2020 Czech Technical University in Prague
3: * <p>
4: * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
5: * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
6: * version.
7: * <p>
8: * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9: * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
10: * details. You should have received a copy of the GNU General Public License along with this program. If not, see
11: * <http://www.gnu.org/licenses/>.
12: */
13: package cz.cvut.kbss.jopa.sessions;
14:
15: import cz.cvut.kbss.jopa.utils.EntityPropertiesUtils;
16:
17: import java.lang.reflect.Field;
18: import java.util.Date;
19:
20: class DateInstanceBuilder extends AbstractInstanceBuilder {
21:
22: DateInstanceBuilder(CloneBuilderImpl builder, UnitOfWorkImpl uow) {
23: super(builder, uow);
24: }
25:
26: @Override
27: Object buildClone(Object cloneOwner, Field field, Object original, CloneConfiguration config) {
28:• if (original == null) {
29: return null;
30: }
31: final Date orig = (Date) original;
32: return new Date(orig.getTime());
33: }
34:
35: @Override
36: void mergeChanges(Field field, Object target, Object originalValue, Object cloneValue) {
37: EntityPropertiesUtils.setFieldValue(field, target, cloneValue);
38: }
39:
40: @Override
41: boolean populatesAttributes() {
42: return true;
43: }
44: }