View Javadoc
1   package org.synchronoss.cpo.core;
2   
3   /*-
4    * [[
5    * core
6    * ==
7    * Copyright (C) 2003 - 2026 Exaxis LLC, Synchronoss Technologies Inc
8    * ==
9    * This program is free software: you can redistribute it and/or modify
10   * it under the terms of the GNU Lesser General Public License as
11   * published by the Free Software Foundation, either version 3 of the
12   * License, or (at your option) any later version.
13   *
14   * This program is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   * GNU General Lesser Public License for more details.
18   *
19   * You should have received a copy of the GNU General Lesser Public
20   * License along with this program.  If not, see
21   * <http://www.gnu.org/licenses/lgpl-3.0.html>.
22   * ]]
23   */
24  
25  /**
26   * {@code CpoData} is the binding between a single bean attribute and the mechanics needed to move
27   * its value into and out of the datastore: invoking the bean's getter/setter reflectively and
28   * applying any configured {@code CpoTransform} on the way in or out.
29   *
30   * @author dberry
31   */
32  public interface CpoData {
33  
34    /**
35     * Invokes the bean's getter for the bound attribute.
36     *
37     * @return the value returned by the attribute's getter
38     * @throws CpoException if the getter cannot be invoked
39     */
40    Object invokeGetter() throws CpoException;
41  
42    /**
43     * Invokes the bean's setter for the bound attribute.
44     *
45     * @param instanceObject the value to pass to the attribute's setter
46     * @throws CpoException if the setter cannot be invoked
47     */
48    void invokeSetter(Object instanceObject) throws CpoException;
49  
50    /**
51     * Transforms a value read from the datastore into the form expected by the bean attribute,
52     * applying the attribute's configured transform (if any).
53     *
54     * @param datasourceObject the raw value read from the datastore
55     * @return the value to pass to the bean's setter, transformed if a transform is configured
56     * @throws CpoException if the transform fails
57     */
58    Object transformIn(Object datasourceObject) throws CpoException;
59  
60    /**
61     * Transforms a value read from the bean attribute into the form expected by the datastore,
62     * applying the attribute's configured transform (if any).
63     *
64     * @param attributeObject the raw value read from the bean's getter
65     * @return the value to bind to the datastore statement, transformed if a transform is configured
66     * @throws CpoException if the transform fails
67     */
68    Object transformOut(Object attributeObject) throws CpoException;
69  }