// Path: src/main/java/org/primefaces/material/MaterialWidgetBuilder.java
// public class MaterialWidgetBuilder extends WidgetBuilder {
// 
// 	private static final String KEY = MaterialWidgetBuilder.class.getName();
// 
// 	public static MaterialWidgetBuilder getInstance(final FacesContext context) {
// 
// 		MaterialWidgetBuilder wb = (MaterialWidgetBuilder) context.getExternalContext().getRequestMap().get(KEY);
// 
// 		if (wb == null) {
// 			wb = new MaterialWidgetBuilder(context);
// 
// 			context.getExternalContext().getRequestMap().put(KEY, wb);
// 		}
// 
// 		return wb;
// 	}
//     
//     public MaterialWidgetBuilder(FacesContext context) {
//         super(context);
//     }
// 
//     protected WidgetBuilder init(String widgetClass, String widgetVar, String id, boolean endFunction) throws IOException {
//     	this.endFunction = endFunction;
// 
//         context.getResponseWriter().write("MaterialPrime.cw(\"");
//         context.getResponseWriter().write(widgetClass);
//         context.getResponseWriter().write("\",\"");
//         context.getResponseWriter().write(widgetVar);
//         context.getResponseWriter().write("\",{");
//         context.getResponseWriter().write("id:\"");
//         context.getResponseWriter().write(id);
//         if (widgetVar == null) {
//         	context.getResponseWriter().write("\"");
//         } else {
// 	        context.getResponseWriter().write("\",widgetVar:\"");
// 	        context.getResponseWriter().write(widgetVar);
// 	        context.getResponseWriter().write("\"");
//         }
// 
//         return this;
//     }
// }


import java.io.IOException;
import java.util.List;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.model.SelectItem;
import org.primefaces.material.MaterialWidgetBuilder;
import org.primefaces.renderkit.InputRenderer;
import org.primefaces.util.WidgetBuilder;
						writer.writeAttribute("checked", selectItem.getValue().equals(radioButton.getValue())? "checked" : "", null);
					writer.endElement("input");	
					writer.startElement("label", null);
						writer.writeAttribute("for", inputId+i, null);
						writer.write(selectItem.getLabel());
					writer.endElement("label");	
					
				writer.endElement("p");
			}
			
		writer.endElement("div");
		
	}
	
	private String getInputClass(RadioButton radioButton) {
		String toReturn = "";

		toReturn += radioButton.getStyleClass();
		
		if(radioButton.isWithGap()){
			toReturn += " with-gap ";
		}

		return toReturn;
	}

	private void encodeScript(FacesContext context, RadioButton radioButton) throws IOException {
		String clientId = radioButton.getClientId();
		String widgetVar = radioButton.resolveWidgetVar();
		 
// Path: src/main/java/org/primefaces/material/MaterialWidgetBuilder.java
// public class MaterialWidgetBuilder extends WidgetBuilder {
// 
// 	private static final String KEY = MaterialWidgetBuilder.class.getName();
// 
// 	public static MaterialWidgetBuilder getInstance(final FacesContext context) {
// 
// 		MaterialWidgetBuilder wb = (MaterialWidgetBuilder) context.getExternalContext().getRequestMap().get(KEY);
// 
// 		if (wb == null) {
// 			wb = new MaterialWidgetBuilder(context);
// 
// 			context.getExternalContext().getRequestMap().put(KEY, wb);
// 		}
// 
// 		return wb;
// 	}
//     
//     public MaterialWidgetBuilder(FacesContext context) {
//         super(context);
//     }
// 
//     protected WidgetBuilder init(String widgetClass, String widgetVar, String id, boolean endFunction) throws IOException {
//     	this.endFunction = endFunction;
// 
//         context.getResponseWriter().write("MaterialPrime.cw(\"");
//         context.getResponseWriter().write(widgetClass);
//         context.getResponseWriter().write("\",\"");
//         context.getResponseWriter().write(widgetVar);
//         context.getResponseWriter().write("\",{");
//         context.getResponseWriter().write("id:\"");
//         context.getResponseWriter().write(id);
//         if (widgetVar == null) {
//         	context.getResponseWriter().write("\"");
//         } else {
// 	        context.getResponseWriter().write("\",widgetVar:\"");
// 	        context.getResponseWriter().write(widgetVar);
// 	        context.getResponseWriter().write("\"");
//         }
// 
//         return this;
//     }
// }


// Path: src/main/java/org/primefaces/material/component/radiobutton/RadioButtonRenderer.java
import java.io.IOException;
import java.util.List;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.model.SelectItem;
import org.primefaces.material.MaterialWidgetBuilder;
import org.primefaces.renderkit.InputRenderer;
import org.primefaces.util.WidgetBuilder;

						writer.writeAttribute("checked", selectItem.getValue().equals(radioButton.getValue())? "checked" : "", null);
					writer.endElement("input");	
					writer.startElement("label", null);
						writer.writeAttribute("for", inputId+i, null);
						writer.write(selectItem.getLabel());
					writer.endElement("label");	
					
				writer.endElement("p");
			}
			
		writer.endElement("div");
		
	}
	
	private String getInputClass(RadioButton radioButton) {
		String toReturn = "";

		toReturn += radioButton.getStyleClass();
		
		if(radioButton.isWithGap()){
			toReturn += " with-gap ";
		}

		return toReturn;
	}

	private void encodeScript(FacesContext context, RadioButton radioButton) throws IOException {
		String clientId = radioButton.getClientId();
		String widgetVar = radioButton.resolveWidgetVar();
		 
		WidgetBuilder wb = MaterialWidgetBuilder.getInstance(context);