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.portlet;
016    
017    import com.liferay.portal.kernel.util.Accessor;
018    import com.liferay.portal.model.Portlet;
019    
020    import java.util.List;
021    
022    /**
023     * @author Carlos Sierra Andr??s
024     */
025    public interface PortletResourceAccessor
026            extends Accessor<Portlet, List<String>> {
027    
028            public static PortletResourceAccessor FOOTER_PORTAL_CSS =
029                    new PortalPortletResourceAccessor() {
030    
031                            @Override
032                            public List<String> get(Portlet portlet) {
033                                    return portlet.getFooterPortalCss();
034                            }
035    
036                    };
037    
038            public static PortletResourceAccessor FOOTER_PORTAL_JAVASCRIPT =
039                    new PortalPortletResourceAccessor() {
040    
041                            @Override
042                            public List<String> get(Portlet portlet) {
043                                    return portlet.getFooterPortalJavaScript();
044                            }
045    
046                    };
047    
048            public static PortletResourceAccessor FOOTER_PORTLET_CSS =
049                    new DefaultPortletResourceAccessor() {
050    
051                            @Override
052                            public List<String> get(Portlet portlet) {
053                                    return portlet.getFooterPortletCss();
054                            }
055    
056                    };
057    
058            public static PortletResourceAccessor FOOTER_PORTLET_JAVASCRIPT =
059                    new DefaultPortletResourceAccessor() {
060    
061                            @Override
062                            public List<String> get(Portlet portlet) {
063                                    return portlet.getFooterPortletJavaScript();
064                            }
065    
066                    };
067    
068            public static PortletResourceAccessor HEADER_PORTAL_CSS =
069                    new PortalPortletResourceAccessor() {
070    
071                            @Override
072                            public List<String> get(Portlet portlet) {
073                                    return portlet.getHeaderPortalCss();
074                            }
075    
076                    };
077    
078            public static PortletResourceAccessor HEADER_PORTAL_JAVASCRIPT =
079                    new PortalPortletResourceAccessor() {
080    
081                            @Override
082                            public List<String> get(Portlet portlet) {
083                                    return portlet.getHeaderPortalJavaScript();
084                            }
085    
086                    };
087    
088            public static PortletResourceAccessor HEADER_PORTLET_CSS =
089                    new DefaultPortletResourceAccessor() {
090    
091                            @Override
092                            public List<String> get(Portlet portlet) {
093                                    return portlet.getHeaderPortletCss();
094                            }
095    
096                    };
097    
098            public static PortletResourceAccessor HEADER_PORTLET_JAVASCRIPT =
099                    new DefaultPortletResourceAccessor() {
100    
101                            @Override
102                            public List<String> get(Portlet portlet) {
103                                    return portlet.getHeaderPortletJavaScript();
104                            }
105    
106                    };
107    
108            public boolean isPortalResource();
109    
110            public static abstract class DefaultPortletResourceAccessor
111                    implements PortletResourceAccessor {
112    
113                    @Override
114                    @SuppressWarnings("rawtypes")
115                    public Class<List<String>> getAttributeClass() {
116                            return (Class)List.class;
117                    }
118    
119                    @Override
120                    public Class<Portlet> getTypeClass() {
121                            return Portlet.class;
122                    }
123    
124                    @Override
125                    public boolean isPortalResource() {
126                            return false;
127                    }
128    
129            }
130    
131            public static abstract class PortalPortletResourceAccessor
132                    implements PortletResourceAccessor {
133    
134                    @Override
135                    @SuppressWarnings("rawtypes")
136                    public Class<List<String>> getAttributeClass() {
137                            return (Class)List.class;
138                    }
139    
140                    @Override
141                    public Class<Portlet> getTypeClass() {
142                            return Portlet.class;
143                    }
144    
145                    @Override
146                    public boolean isPortalResource() {
147                            return true;
148                    }
149    
150            }
151    
152    }