From 5a56b36ba5fa3d912375f85f2ac5ed66e2eef108 Mon Sep 17 00:00:00 2001 From: Manolo Carrasco Date: Sat, 18 Jan 2014 13:29:56 +0100 Subject: Safe type casting --- .../src/main/java/com/google/gwt/query/client/GQ.java | 6 +++++- .../com/google/gwt/query/client/builders/JsonFactory.java | 3 ++- .../main/java/com/google/gwt/query/vm/JsonFactoryJre.java | 13 +++++++++---- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/GQ.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/GQ.java index 46cee7e1..27dbbe78 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/GQ.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/GQ.java @@ -44,9 +44,13 @@ public abstract class GQ { return ret; } - public static T create(String s) { + public static Binder create(String s) { return getFactory().create(s); } + + public static Binder create() { + return getFactory().create(); + } public static AjaxTransport getAjaxTransport() { if (ajaxTransport == null) { diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonFactory.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonFactory.java index adcd5212..4bc57c9c 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonFactory.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonFactory.java @@ -4,5 +4,6 @@ import com.google.gwt.query.client.Binder; public interface JsonFactory { T create(Class clz); - T create(String s); + Binder create(String s); + Binder create(); } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonFactoryJre.java b/gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonFactoryJre.java index abef1b8f..d234d854 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonFactoryJre.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonFactoryJre.java @@ -284,11 +284,16 @@ public class JsonFactoryJre implements JsonFactory { InvocationHandler handler = new JsonBuilderHandler(jso); return (Binder)Proxy.newProxyInstance(Binder.class.getClassLoader(), new Class[] {Binder.class}, handler); } - - @SuppressWarnings("unchecked") - public T create(String s) { + + @Override + public Binder create(String s) { Binder ret = createBinder(); ret.parse(Properties.wrapPropertiesString(s)); - return (T)ret; + return ret; + } + + @Override + public Binder create() { + return createBinder(); } } -- cgit v1.2.3