Skip to content

Instantly share code, notes, and snippets.

@Tires
Created March 26, 2016 00:07
Show Gist options
  • Save Tires/37923adef7a36e2f6a1a to your computer and use it in GitHub Desktop.
Save Tires/37923adef7a36e2f6a1a to your computer and use it in GitHub Desktop.
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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment