From: Manolo Carrasco Date: Sat, 18 Jan 2014 12:29:56 +0000 (+0100) Subject: Safe type casting X-Git-Tag: gwtquery-project-1.4.3~44^2~17 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5a56b36ba5fa3d912375f85f2ac5ed66e2eef108;p=gwtquery.git Safe type casting --- 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(); } }