View Javadoc
1   package fr.paris.lutece.plugins.extend.modules.rating.service.facade;
2   
3   import java.util.List;
4   import java.util.function.BiFunction;
5   import java.util.function.BinaryOperator;
6   import java.util.function.Consumer;
7   import javax.servlet.http.HttpServletRequest;
8   
9   import fr.paris.lutece.plugins.extend.modules.rating.business.Rating;
10  import fr.paris.lutece.plugins.extend.modules.rating.business.config.RatingExtenderConfig;
11  import static java.util.Objects.requireNonNull;
12  
13  
14  public class RatingTypeBuilderImpl implements RatingType.Builder
15  {
16  
17  	 String _strTitle; 
18  	 Class<? extends Rating> _type;
19  
20  	 Consumer<Rating> _doRating;
21  	 Consumer<Rating> _cancelRating;
22  	 QuinquaFunction< RatingExtenderConfig , String, String, String, HttpServletRequest ,String > _getPageAddOn;
23  	/**
24  	 * BinaryOperator to get the information value associate to the ExtenderType to export in the file export
25  	 */
26  	 BinaryOperator<String> _getInfoForExport;
27  	/**
28  	 * BinaryOperator to get the information value associate to the ExtenderType to write in the recap
29  	 */
30  	 BinaryOperator<String> _getInfoForRecap;
31  	/**
32  	 * BiFunction to get the list of extender type information object
33  	 * @param <T> the type of the output arguments of the getInfoExtender
34  	 */
35  	 BiFunction<String, String, List< Rating > > _getInfoExtender;
36  	
37  	/**
38  	 * BiFunction to get the list of extender type information object
39  	 * @param <T> the type of the output arguments of the getInfoExtenderByList
40  	 */
41  	 BiFunction<List<String>, String,  List<Rating> > _getInfoExtenderByList;
42  
43  		
44  	protected RatingTypeBuilderImpl( Class<? extends Rating>  type, String strTitle )
45  	{		
46  		requireNonNull( type );
47  		requireNonNull( strTitle );
48  		this._type= type;
49  		this._strTitle= strTitle;
50  	}
51  	public RatingTypeBuilderImpl doRating( final Consumer< Rating > doRating  ) 
52  	{	
53  		requireNonNull( doRating );
54  		this._doRating= doRating;
55  		return this;
56  	}
57  	public RatingTypeBuilderImpl cancelRating( final Consumer<Rating > cancelRating  )
58  	{
59  		requireNonNull( cancelRating );
60  		this._cancelRating= cancelRating;
61  		return this;	
62  	}
63  	public RatingTypeBuilderImpl getPageAddOn ( final QuinquaFunction< RatingExtenderConfig , String, String, String, HttpServletRequest ,String > getPageAddOn )
64  	{
65  		requireNonNull( getPageAddOn );
66  		this._getPageAddOn= getPageAddOn;
67  		return this;
68  	}
69  	
70  	public RatingTypeBuilderImpl getInfoForExport( final BinaryOperator<String> getInfoForExport )
71  	{
72  		requireNonNull( getInfoForExport );
73  		this._getInfoForExport= getInfoForExport;
74  		return this;
75  	}
76  	public RatingTypeBuilderImpl getInfoForRecap ( final BinaryOperator<String> getInfoForRecap )
77  	{
78  		requireNonNull( getInfoForRecap );
79  		this._getInfoForRecap= getInfoForRecap;
80  		return this;
81  	}
82  	public RatingTypeBuilderImpl getInfoExtender ( final BiFunction<String, String, List< Rating > > getInfoExtender )
83  	{
84  		requireNonNull( getInfoExtender );
85  		this._getInfoExtender= getInfoExtender;	
86  		return this;
87  	}
88  	public RatingTypeBuilderImpl getInfoExtenderByList ( final BiFunction<List<String>, String,  List<Rating> > getInfoExtenderByList )
89  	{
90  		requireNonNull( getInfoExtenderByList );
91  		this._getInfoExtenderByList= getInfoExtenderByList;
92  		return this;
93  	}
94  	 /**
95       * Returns a new RatingType built from the current state of this
96       * builder.
97       *
98       * @return a new RatingType
99       */
100     public RatingType build( )
101     {
102     	return RatingTypeImpl.create( this );
103     }
104     
105 
106 }