/** * One and only implementation of restore state. Makes all other implementations unnecessary. * * @param context FacesContext * @param state the state to be restored. */ public void restoreState(FacesContext context, Object state) { FacesContext fc = FacesContext.getCurrentInstance(); Object[] savedState = (Object[]) state; component.initialState = (Boolean) savedState[savedState.length - 1]; int length = (savedState.length - 1) / 2; for (int i = 0; i < length; i++) { Object value = savedState[i * 2 + 1]; if (Void.TYPE.equals(value)) { value = null; } Serializable serializable = (Serializable) savedState[i * 2]; if (value != null) { if (value instanceof Collection) { value = restoreAttachedState(fc, value); } else if (value instanceof StateHolderSaver) { value = ((StateHolderSaver) value).restore(context); } else { value = (value instanceof Serializable ? value : restoreAttachedState(fc, value)); } } if (value instanceof Map) { for (Map.Entry<String, Object> entry : ((Map<String, Object>) value).entrySet()) { this.put(serializable, entry.getKey(), entry.getValue()); } } else if (value instanceof List) { for (Object o : ((List<Object>) value)) { this.add(serializable, o); } } else { put(serializable, value); } } }
public static boolean isVoid(ResolvedType returnType) { return Void.class.equals(returnType.getErasedType()) || Void.TYPE.equals(returnType.getErasedType()); }