diff --git a/core/src/main/java/org/jclouds/Wrapper.java b/core/src/main/java/org/jclouds/Wrapper.java index e5a740a46c..d80839f894 100644 --- a/core/src/main/java/org/jclouds/Wrapper.java +++ b/core/src/main/java/org/jclouds/Wrapper.java @@ -51,8 +51,14 @@ public interface Wrapper { * if the wrapped context is not assignable from the specified class. * @see #getWrappedType() */ - C unwrap(TypeToken type); - + C unwrap(TypeToken type) throws IllegalArgumentException; + + /** + * shortcut for {@code unwrap(TypeToken.of(clazz))} + * @see #unwrap(TypeToken) + */ + C unwrap(Class clazz) throws IllegalArgumentException; + /** * shortcut for {@code unwrap(getWrappedType())} * diff --git a/core/src/main/java/org/jclouds/internal/BaseWrapper.java b/core/src/main/java/org/jclouds/internal/BaseWrapper.java index b28208c5f9..d93ac915a7 100644 --- a/core/src/main/java/org/jclouds/internal/BaseWrapper.java +++ b/core/src/main/java/org/jclouds/internal/BaseWrapper.java @@ -53,7 +53,12 @@ public abstract class BaseWrapper implements Wrapper { checkArgument(checkNotNull(type, "type").isAssignableFrom(wrappedType), "wrapped type: %s not assignable from %s", wrappedType, type); return (C) wrapped; } - + + @Override + public C unwrap(Class clazz) { + return unwrap (TypeToken.of(checkNotNull(clazz, "clazz"))); + } + @Override public TypeToken getWrappedType() { return wrappedType;