001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.service.persistence.impl;
016    
017    import com.liferay.portal.kernel.model.BaseModel;
018    import com.liferay.portal.kernel.util.OrderByComparator;
019    
020    import java.util.List;
021    
022    /**
023     * @author Shuyang Zhou
024     */
025    public class ReverseTableMapper<L extends BaseModel<L>, R extends BaseModel<R>>
026            implements TableMapper<L, R> {
027    
028            public ReverseTableMapper(TableMapper<R, L> tableMapper) {
029                    _tableMapper = tableMapper;
030            }
031    
032            @Override
033            public boolean addTableMapping(
034                    long companyId, long leftPrimaryKey, long rightPrimaryKey) {
035    
036                    return _tableMapper.addTableMapping(
037                            companyId, rightPrimaryKey, leftPrimaryKey);
038            }
039    
040            @Override
041            public long[] addTableMappings(
042                    long companyId, long leftPrimaryKey, long[] rightPrimaryKeys) {
043    
044                    return _tableMapper.addTableMappings(
045                            companyId, rightPrimaryKeys, leftPrimaryKey);
046            }
047    
048            @Override
049            public long[] addTableMappings(
050                    long companyId, long[] leftPrimaryKeys, long rightPrimaryKey) {
051    
052                    return _tableMapper.addTableMappings(
053                            companyId, rightPrimaryKey, leftPrimaryKeys);
054            }
055    
056            @Override
057            public boolean containsTableMapping(
058                    long leftPrimaryKey, long rightPrimaryKey) {
059    
060                    return _tableMapper.containsTableMapping(
061                            rightPrimaryKey, leftPrimaryKey);
062            }
063    
064            @Override
065            public int deleteLeftPrimaryKeyTableMappings(long leftPrimaryKey) {
066                    return _tableMapper.deleteRightPrimaryKeyTableMappings(leftPrimaryKey);
067            }
068    
069            @Override
070            public int deleteRightPrimaryKeyTableMappings(long rightPrimaryKey) {
071                    return _tableMapper.deleteLeftPrimaryKeyTableMappings(rightPrimaryKey);
072            }
073    
074            @Override
075            public boolean deleteTableMapping(
076                    long leftPrimaryKey, long rightPrimaryKey) {
077    
078                    return _tableMapper.deleteTableMapping(rightPrimaryKey, leftPrimaryKey);
079            }
080    
081            @Override
082            public long[] deleteTableMappings(
083                    long leftPrimaryKey, long[] rightPrimaryKeys) {
084    
085                    return _tableMapper.deleteTableMappings(
086                            rightPrimaryKeys, leftPrimaryKey);
087            }
088    
089            @Override
090            public long[] deleteTableMappings(
091                    long[] leftPrimaryKeys, long rightPrimaryKey) {
092    
093                    return _tableMapper.deleteTableMappings(
094                            rightPrimaryKey, leftPrimaryKeys);
095            }
096    
097            @Override
098            public void destroy() {
099                    _tableMapper.destroy();
100            }
101    
102            @Override
103            public List<L> getLeftBaseModels(
104                    long rightPrimaryKey, int start, int end, OrderByComparator<L> obc) {
105    
106                    return _tableMapper.getRightBaseModels(
107                            rightPrimaryKey, start, end, obc);
108            }
109    
110            @Override
111            public long[] getLeftPrimaryKeys(long rightPrimaryKey) {
112                    return _tableMapper.getRightPrimaryKeys(rightPrimaryKey);
113            }
114    
115            @Override
116            public TableMapper<R, L> getReverseTableMapper() {
117                    return _tableMapper;
118            }
119    
120            @Override
121            public List<R> getRightBaseModels(
122                    long leftPrimaryKey, int start, int end, OrderByComparator<R> obc) {
123    
124                    return _tableMapper.getLeftBaseModels(leftPrimaryKey, start, end, obc);
125            }
126    
127            @Override
128            public long[] getRightPrimaryKeys(long leftPrimaryKey) {
129                    return _tableMapper.getLeftPrimaryKeys(leftPrimaryKey);
130            }
131    
132            @Override
133            public boolean matches(String leftColumnName, String rightColumnName) {
134                    return _tableMapper.matches(rightColumnName, leftColumnName);
135            }
136    
137            private final TableMapper<R, L> _tableMapper;
138    
139    }