Skip to content

Instantly share code, notes, and snippets.

View Tires's full-sized avatar

Tires

View GitHub Profile
@Tires
Tires / Jsf.java
Created March 26, 2016 00:07
Extract a wrapped JSF facade
@SuppressWarnings("unchecked")
public static <S, T extends S> T unwrap(S source, Class<T> targetType) {
while (source != null) {
if (targetType.isInstance(source))
return (T)source;
if (!(source instanceof FacesWrapper))
break;
source = ((FacesWrapper<S>)source).getWrapped();
}
return null;