protected static < T extends Serializable > T asT ( final Object service , final Class < T > type ) { return type . cast ( service ) ; }
Cast the object to the original one with the type . The object must extend Serializable .