Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,7 @@ public <T> Single<T> invoke(Class<T> returnType, String method, Object... args)

/**
* Invokes a hub method on the server using the specified method name and arguments.
* A Type can be retrieved using {@link TypeReference}
*
* @param returnType The expected return type.
* @param method The name of the server method to invoke.
Expand Down Expand Up @@ -1097,6 +1098,7 @@ public <T1, T2, T3, T4, T5, T6, T7, T8> Subscription on(String target, Action8<T
/**
* Registers a handler that will be invoked when the hub method with the specified method name is invoked.
* Should be used for generic classes and Parameterized Collections, like List or Map.
* A Type can be retrieved using {@link TypeReference}
*
* @param target The name of the hub method to define.
* @param callback The handler that will be raised when the hub method is invoked.
Expand All @@ -1113,6 +1115,7 @@ public <T1> Subscription on(String target, Action1<T1> callback, Type param1) {
/**
* Registers a handler that will be invoked when the hub method with the specified method name is invoked.
* Should be used for generic classes and Parameterized Collections, like List or Map.
* A Type can be retrieved using {@link TypeReference}
*
* @param target The name of the hub method to define.
* @param callback The handler that will be raised when the hub method is invoked.
Expand All @@ -1133,6 +1136,7 @@ public <T1, T2> Subscription on(String target, Action2<T1, T2> callback, Type pa
/**
* Registers a handler that will be invoked when the hub method with the specified method name is invoked.
* Should be used for generic classes and Parameterized Collections, like List or Map.
* A Type can be retrieved using {@link TypeReference}
*
* @param target The name of the hub method to define.
* @param callback The handler that will be raised when the hub method is invoked.
Expand All @@ -1157,6 +1161,7 @@ public <T1, T2, T3> Subscription on(String target, Action3<T1, T2, T3> callback,
/**
* Registers a handler that will be invoked when the hub method with the specified method name is invoked.
* Should be used for generic classes and Parameterized Collections, like List or Map.
* A Type can be retrieved using {@link TypeReference}
*
* @param target The name of the hub method to define.
* @param callback The handler that will be raised when the hub method is invoked.
Expand All @@ -1183,6 +1188,7 @@ public <T1, T2, T3, T4> Subscription on(String target, Action4<T1, T2, T3, T4> c
/**
* Registers a handler that will be invoked when the hub method with the specified method name is invoked.
* Should be used for generic classes and Parameterized Collections, like List or Map.
* A Type can be retrieved using {@link TypeReference}
*
* @param target The name of the hub method to define.
* @param callback The handler that will be raised when the hub method is invoked.
Expand Down Expand Up @@ -1212,6 +1218,7 @@ public <T1, T2, T3, T4, T5> Subscription on(String target, Action5<T1, T2, T3, T
/**
* Registers a handler that will be invoked when the hub method with the specified method name is invoked.
* Should be used for generic classes and Parameterized Collections, like List or Map.
* A Type can be retrieved using {@link TypeReference}
*
* @param target The name of the hub method to define.
* @param callback The handler that will be raised when the hub method is invoked.
Expand Down Expand Up @@ -1243,6 +1250,7 @@ public <T1, T2, T3, T4, T5, T6> Subscription on(String target, Action6<T1, T2, T
/**
* Registers a handler that will be invoked when the hub method with the specified method name is invoked.
* Should be used for generic classes and Parameterized Collections, like List or Map.
* A Type can be retrieved using {@link TypeReference}
*
* @param target The name of the hub method to define.
* @param callback The handler that will be raised when the hub method is invoked.
Expand Down Expand Up @@ -1277,6 +1285,7 @@ public <T1, T2, T3, T4, T5, T6, T7> Subscription on(String target, Action7<T1, T
/**
* Registers a handler that will be invoked when the hub method with the specified method name is invoked.
* Should be used for generic classes and Parameterized Collections, like List or Map.
* A Type can be retrieved using {@link TypeReference}
*
* @param target The name of the hub method to define.
* @param callback The handler that will be raised when the hub method is invoked.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

package com.microsoft.signalr;

import java.lang.reflect.Type;
import java.lang.reflect.ParameterizedType;

/**
* A utility for getting a Java Type from a literal Class.
*/
public class TypeReference<T> {

private final Type type;

/**
* Creates a new instance of {@link TypeReference}.
*
* To get the Type of Class Foo, use the following syntax:
* <pre>{@code
* Type fooType = (new TypeReference<Foo>() { }).getType();
* }</pre>
*/
public TypeReference() {
Type superclass = getClass().getGenericSuperclass();
if (superclass instanceof Class) {
throw new RuntimeException("Missing type parameter.");
}
this.type = ((ParameterizedType) superclass).getActualTypeArguments()[0];
}

/**
* Gets the referenced type.
*/
public Type getType() {
return this.type;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.core.type.TypeReference;

import io.reactivex.Completable;
import io.reactivex.Observable;
import io.reactivex.Single;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.core.type.TypeReference;

class JsonHubProtocolTest {
private JsonHubProtocol jsonHubProtocol = new JsonHubProtocol();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.core.type.TypeReference;

class MessagePackHubProtocolTest {
private MessagePackHubProtocol messagePackHubProtocol = new MessagePackHubProtocol();

Expand Down