List of usage examples for java.lang ClassCastException fillInStackTrace
public synchronized Throwable fillInStackTrace()
From source file:com.chiorichan.configuration.serialization.ConfigurationSerialization.java
/** * Attempts to deserialize the given arguments into a new instance of the given class. * <p />/*from www .ja v a 2s. c o m*/ * The class must implement {@link ConfigurationSerializable}, including the extra methods as specified in the javadoc of ConfigurationSerializable. * <p /> * If a new instance could not be made, an example being the class not fully implementing the interface, null will be returned. * * @param args * Arguments for deserialization * @return New instance of the specified class */ public static ConfigurationSerializable deserializeObject(Map<String, Object> args) { Class<? extends ConfigurationSerializable> clazz = null; if (args.containsKey(SERIALIZED_TYPE_KEY)) { try { String alias = (String) args.get(SERIALIZED_TYPE_KEY); if (alias == null) { throw new IllegalArgumentException("Cannot have null alias"); } clazz = getClassByAlias(alias); if (clazz == null) { throw new IllegalArgumentException("Specified class does not exist ('" + alias + "')"); } } catch (ClassCastException ex) { ex.fillInStackTrace(); throw ex; } } else { throw new IllegalArgumentException("Args doesn't contain type key ('" + SERIALIZED_TYPE_KEY + "')"); } return new ConfigurationSerialization(clazz).deserialize(args); }
From source file:bammerbom.ultimatecore.bukkit.configuration.ConfigurationSerialization.java
/** * Attempts to deserialize the given arguments into a new instance of the * given class./*from www . jav a2 s . c om*/ * <p/> * The class must implement {@link ConfigurationSerializable}, including the * extra methods as specified in the javadoc of ConfigurationSerializable. * <p/> * If a new instance could not be made, an example being the class not fully * implementing the interface, null will be returned. * * @param args Arguments for deserialization * @return New instance of the specified class */ public static ConfigurationSerializable deserializeObject(Map<String, ?> args) { Class<? extends ConfigurationSerializable> clazz = null; if (args.containsKey(SERIALIZED_TYPE_KEY)) { try { String alias = (String) args.get(SERIALIZED_TYPE_KEY); if (alias == null) { throw new IllegalArgumentException("Cannot have null alias"); } clazz = getClassByAlias(alias); if (clazz == null) { throw new IllegalArgumentException("Specified class does not exist ('" + alias + "')"); } } catch (ClassCastException ex) { ex.fillInStackTrace(); throw ex; } } else { throw new IllegalArgumentException("Args doesn't contain type key ('" + SERIALIZED_TYPE_KEY + "')"); } return new ConfigurationSerialization(clazz).deserialize(args); }