org.codehaus.plexus.component.CastUtils Maven / Gradle / Ivy
package org.codehaus.plexus.component;
import org.apache.xbean.recipe.RecipeHelper;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.google.common.collect.Multimap;
@SuppressWarnings({"unchecked", "UnusedDeclaration"})
public final class CastUtils {
private CastUtils() {
//utility class, never constructed
}
public static Map cast(Map, ?> p) {
return (Map) p;
}
public static Map cast(Map, ?> p, Class t, Class u) {
return (Map) p;
}
public static Multimap cast(Multimap, ?> p) {
return (Multimap) p;
}
public static Multimap cast(Multimap, ?> p, Class t, Class u) {
return (Multimap) p;
}
public static Collection cast(Collection> p) {
return (Collection) p;
}
public static Collection cast(Collection> p, Class cls) {
return (Collection) p;
}
public static List cast(List> p) {
return (List) p;
}
public static List cast(List> p, Class cls) {
return (List) p;
}
public static Iterator cast(Iterator> p) {
return (Iterator) p;
}
public static Iterator cast(Iterator> p, Class cls) {
return (Iterator) p;
}
public static Set cast(Set> p) {
return (Set) p;
}
public static Set cast(Set> p, Class cls) {
return (Set) p;
}
public static Map.Entry cast(Map.Entry, ?> p) {
return (Map.Entry) p;
}
public static Map.Entry cast(Map.Entry, ?> p, Class pc, Class uc) {
return (Map.Entry) p;
}
// todo remove when recipe helper accecpts nulls
public static boolean isAssignableFrom(Class> expected, Class> actual) {
return actual != null && RecipeHelper.isAssignableFrom( expected, actual );
}
}