View Javadoc
1   package org.synchronoss.cpo.core.transform;
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  import org.synchronoss.cpo.core.CpoException;
26  
27  /**
28   * {@code CpoTransform} converts an attribute's value between the raw form stored/read at the
29   * datastore and the form exposed on the Java bean, e.g. clob-to-string or gzip compression.
30   * Implementations are configured per-attribute in the meta XML and instantiated reflectively, so
31   * they must provide a public no-arg constructor.
32   *
33   * @param <D> the raw datastore-side type
34   * @param <J> the Java bean-side type
35   * @author Michael Bellomo
36   * @since 9/19/10
37   */
38  public interface CpoTransform<D, J> {
39  
40    /**
41     * Converts a raw datastore value into the bean-side representation.
42     *
43     * @param inObject the raw value read from the datastore
44     * @return the value to set on the bean attribute
45     * @throws CpoException if the value cannot be converted
46     */
47    J transformIn(D inObject) throws CpoException;
48  
49    /**
50     * Converts a bean attribute's value into the raw datastore-side representation.
51     *
52     * @param attributeObject the value read from the bean attribute
53     * @return the value to bind to the datastore
54     * @throws CpoException if the value cannot be converted
55     */
56    D transformOut(J attributeObject) throws CpoException;
57  }