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.repository.capabilities;
016    
017    import com.liferay.portal.kernel.repository.DocumentRepository;
018    import com.liferay.portal.kernel.repository.capabilities.Capability;
019    import com.liferay.portal.kernel.repository.capabilities.CapabilityProvider;
020    
021    /**
022     * @author Adolfo P??rez
023     */
024    public abstract class BaseCapabilityRepository<R>
025            implements DocumentRepository {
026    
027            public BaseCapabilityRepository(
028                    R repository, CapabilityProvider capabilityProvider) {
029    
030                    _repository = repository;
031                    _capabilityProvider = capabilityProvider;
032            }
033    
034            @Override
035            public <T extends Capability> T getCapability(Class<T> capabilityClass) {
036                    return _capabilityProvider.getCapability(capabilityClass);
037            }
038    
039            @Override
040            public abstract long getRepositoryId();
041    
042            @Override
043            public <T extends Capability> boolean isCapabilityProvided(
044                    Class<T> capabilityClass) {
045    
046                    return _capabilityProvider.isCapabilityProvided(capabilityClass);
047            }
048    
049            protected R getRepository() {
050                    return _repository;
051            }
052    
053            private final CapabilityProvider _capabilityProvider;
054            private final R _repository;
055    
056    }