001// Generated by delombok at Sun Jul 30 17:21:56 UTC 2023 002package de.cuioss.test.jsf.util; 003 004import javax.faces.application.Application; 005import javax.faces.context.ExternalContext; 006import javax.faces.context.FacesContext; 007import org.apache.myfaces.test.mock.MockExternalContext22; 008import org.apache.myfaces.test.mock.MockFacesContext22; 009import org.apache.myfaces.test.mock.MockHttpServletResponse; 010import de.cuioss.test.jsf.config.decorator.ApplicationConfigDecorator; 011import de.cuioss.test.jsf.config.decorator.BeanConfigDecorator; 012import de.cuioss.test.jsf.config.decorator.ComponentConfigDecorator; 013import de.cuioss.test.jsf.config.decorator.RequestConfigDecorator; 014import lombok.NonNull; 015 016/** 017 * Holder for for {@link JsfRuntimeSetup} that provides shorthands for accessing 018 * contained JSF-Objects like {@link FacesContext}, {@link ExternalContext}, 019 * {@link Application}, ... and implicit accessor for objects like 020 * {@link BeanConfigDecorator}, {@link ComponentConfigDecorator}, 021 * {@link ApplicationConfigDecorator} and {@link RequestConfigDecorator} 022 * 023 * @author Oliver Wolff 024 */ 025public class JsfEnvironmentHolder { 026 @NonNull 027 private final JsfRuntimeSetup runtimeSetup; 028 029 /** 030 * @return an {@link ComponentConfigDecorator} for the contained 031 * {@link JsfRuntimeSetup} 032 */ 033 public ComponentConfigDecorator getComponentConfigDecorator() { 034 return new ComponentConfigDecorator(getApplication(), getFacesContext()); 035 } 036 037 /** 038 * @return an {@link BeanConfigDecorator} for the contained 039 * {@link JsfRuntimeSetup} 040 */ 041 public BeanConfigDecorator getBeanConfigDecorator() { 042 return new BeanConfigDecorator(getFacesContext()); 043 } 044 045 /** 046 * @return an {@link ApplicationConfigDecorator} for the contained 047 * {@link JsfRuntimeSetup} 048 */ 049 public ApplicationConfigDecorator getApplicationConfigDecorator() { 050 return new ApplicationConfigDecorator(getApplication(), getFacesContext()); 051 } 052 053 /** 054 * @return an {@link ApplicationConfigDecorator} for the contained 055 * {@link JsfRuntimeSetup} 056 */ 057 public RequestConfigDecorator getRequestConfigDecorator() { 058 return new RequestConfigDecorator((MockFacesContext22) getFacesContext(), (MockExternalContext22) getExternalContext()); 059 } 060 061 /** 062 * @return an {@link FacesContext} for the contained {@link JsfRuntimeSetup} 063 */ 064 public FacesContext getFacesContext() { 065 return runtimeSetup.getFacesContext(); 066 } 067 068 /** 069 * @return an {@link Application} for the contained {@link JsfRuntimeSetup} 070 */ 071 public Application getApplication() { 072 return runtimeSetup.getApplication(); 073 } 074 075 /** 076 * @return an {@link ExternalContext} for the contained {@link JsfRuntimeSetup} 077 */ 078 public ExternalContext getExternalContext() { 079 return runtimeSetup.getExternalContext(); 080 } 081 082 /** 083 * @return an {@link MockHttpServletResponse} for the contained 084 * {@link JsfRuntimeSetup} 085 */ 086 public MockHttpServletResponse getResponse() { 087 return runtimeSetup.getResponse(); 088 } 089 090 @java.lang.SuppressWarnings("all") 091 @lombok.Generated 092 public JsfEnvironmentHolder(@NonNull final JsfRuntimeSetup runtimeSetup) { 093 if (runtimeSetup == null) { 094 throw new java.lang.NullPointerException("runtimeSetup is marked non-null but is null"); 095 } 096 this.runtimeSetup = runtimeSetup; 097 } 098}