01: /**
02: * Objective Database Abstraction Layer (ODAL)
03: * Copyright (c) 2004, The ODAL Development Group
04: * All rights reserved.
05: * For definition of the ODAL Development Group please refer to LICENCE.txt file
06: *
07: * Distributable under LGPL license.
08: * See terms of license at gnu.org.
09: */package com.completex.objective.components.persistency.rule.impl;
10:
11: import com.completex.objective.components.persistency.PersistentEntry;
12:
13: /**
14: * @author Gennady Krizhevsky
15: */
16: public class PopulateDefaultConvertor extends AbstractFieldConvertor {
17:
18: public static final PopulateDefaultConvertor POPULATE_DEFAULT_TRUE_CONVERTOR = newPopulateDefaultBooleanConvertor(Boolean.TRUE);
19: public static final PopulateDefaultConvertor POPULATE_DEFAULT_FALSE_CONVERTOR = newPopulateDefaultBooleanConvertor(Boolean.FALSE);
20:
21: private Object defaultValue;
22:
23: public PopulateDefaultConvertor(Object defaultValue) {
24: this .defaultValue = defaultValue;
25: }
26:
27: public void convert(PersistentEntry entry) throws Exception {
28: if (entry.isDirty()) {
29: return;
30: }
31:
32: setValue(entry, defaultValue);
33: }
34:
35: private static PopulateDefaultConvertor newPopulateDefaultBooleanConvertor(
36: Boolean value) {
37: return new PopulateDefaultConvertor(value);
38: }
39:
40: }
|