public interface Attribute extends BaseType {
int getMaxCount();
void setMaxCount(int maxCount);
int getMinCount();
void setMinCount(int minCount);
String getNotes();
void setNotes(String notes);
}package net.sf.javaprinciples.simm.model;
import java.util.List;
public interface BaseType extends Identifiable {
Type getType();
void setType(Type type);
String getClassifier();
void setClassifier(String classifier);
List<Extension> getExtension();
void setExtension(List<Extension> extension);
}package net.sf.javaprinciples.simm.model;
import java.util.List;
public interface ComplexType extends BaseType {
String getBaseClassifier();
void setBaseClassifier(String baseClassifier);
List<Attribute> getAttributes();
void setAttributes(List<Attribute> attributes);
}package net.sf.javaprinciples.simm.model;
public interface Identifiable {
String getId();
void setId(String id);
String getName();
void setName(String name);
}package net.sf.javaprinciples.simm.model;
import java.util.List;
public interface Package extends Identifiable {
List<ComplexType> getComplexTypes();
void setComplexTypes(List<ComplexType> complexTypes);
}package net.sf.javaprinciples.simm.model;
public class AttributeImpl extends BaseTypeImpl implements Attribute {
protected AttributeImpl() {}
@Override
public final native int getMaxCount() /*-{
return this.maxCount;
}-*/;
@Override
public final native void setMaxCount(int maxCount) /*-{
this.maxCount = maxCount;
}-*/;
@Override
public final native int getMinCount() /*-{
return this.minCount;
}-*/;
@Override
public final native void setMinCount(int minCount) /*-{
this.minCount = minCount;
}-*/;
@Override
public final native String getNotes() /*-{
return this.notes;
}-*/;
@Override
public final native void setNotes(String notes) /*-{
this.notes = notes;
}-*/;
}package net.sf.javaprinciples.simm.model;
import java.util.List;
import java.util.ArrayList;
public class BaseTypeImpl extends IdentifiableImpl implements BaseType {
protected BaseTypeImpl() {}
@Override
public final Type getType() {
String internal = getTypeInternal();
return internal != null ? Type.valueOf(internal) : null;
}
private final native String getTypeInternal() /*-{
return this.type;
}-*/;
@Override
public final void setType(Type type) {
setTypeInternal(type == null ? null : type.name());
}
private final native void setTypeInternal(String type) /*-{
this.type = type;
}-*/;
@Override
public final native String getClassifier() /*-{
return this.classifier;
}-*/;
@Override
public final native void setClassifier(String classifier) /*-{
this.classifier = classifier;
}-*/;
@Override
public final List<Extension> getExtension() {
return findArray("extension");
}
@Override
public final native void setExtension(List<Extension> extension) /*-{
this.extension = extension;
}-*/;
}package net.sf.javaprinciples.simm.model;
import java.util.List;
import java.util.ArrayList;
public class ComplexTypeImpl extends BaseTypeImpl implements ComplexType {
protected ComplexTypeImpl() {}
@Override
public final native String getBaseClassifier() /*-{
return this.baseClassifier;
}-*/;
@Override
public final native void setBaseClassifier(String baseClassifier) /*-{
this.baseClassifier = baseClassifier;
}-*/;
@Override
public final List<Attribute> getAttributes() {
return findArray("attributes");
}
@Override
public final native void setAttributes(List<Attribute> attributes) /*-{
this.attributes = attributes;
}-*/;
}package net.sf.javaprinciples.simm.model;
public class IdentifiableImpl extends JavascriptObjectSupport implements Identifiable {
protected IdentifiableImpl() {}
@Override
public final native String getId() /*-{
return this.id;
}-*/;
@Override
public final native void setId(String id) /*-{
this.id = id;
}-*/;
@Override
public final native String getName() /*-{
return this.name;
}-*/;
@Override
public final native void setName(String name) /*-{
this.name = name;
}-*/;
}package net.sf.javaprinciples.simm.model;
import java.util.List;
import java.util.ArrayList;
public class PackageImpl extends IdentifiableImpl implements Package {
protected PackageImpl() {}
@Override
public final List<ComplexType> getComplexTypes() {
return findArray("complexTypes");
}
@Override
public final native void setComplexTypes(List<ComplexType> complexTypes) /*-{
this.complexTypes = complexTypes;
}-*/;
}
I have several GWT native POJOS and a corresponding interface (all attached)
-- I can call the following :
Identifiable id = JavaScriptObject.createObject().cast();
BaseType baseType = JavaScriptObject.createObject().cast();
ComplexType complexType = JavaScriptObject.createObject().cast();
Package aPackage = JavaScriptObject.createObject().cast();
Attribute attribute = JavaScriptObject.createObject().cast();
When I debug through each of these lines all but the last lines execute a java line to create an object of {} and a simple type cast.
However the last line has an extra line of code inserted by the compiler.
static Object castTo(Object src, JavaScriptObject dstId) {
checkType(src == null || canCast(src, dstId));
return src;
}
This results in a ClassCastException being thrown.
Any pointers would be most appreciated.
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment