Closed GoogleCodeExporter closed 9 years ago
All right, I got it. After I annotate the class I need to run WoblyGenerator
and pass it directory that contains the annotated source code which will inject
generated code into the sources. Unfortunately this seems not to work for my
particular purpose. For my code:
import java.io.Serializable;
import net.minidev.json.JSONArray;
import net.minidev.json.JSONObject;
import com.wowd.wobly.WoblyImpl;
import com.wowd.wobly.annotations.WoblyField;
public class WoblyParcel extends WoblyImpl {
@WoblyField(id = 0)
JSONObject jsonObject;
@WoblyField(id = 1)
JSONArray jsonArray;
public WoblyParcel(Serializable value) {
if (JSONObject.class.isInstance(value))
jsonObject = (JSONObject) value;
else if (JSONArray.class.isInstance(value))
jsonArray = (JSONArray) value;
else
throw new IllegalArgumentException("Unsupported serializable type: " + value);
}
public Serializable get() {
return jsonObject == null ? jsonArray : jsonObject;
}
}
I always get this stacktrace
java.lang.IllegalArgumentException: next type for class
net.minidev.json.JSONObject of index 0, class java.lang.Class
at com.wowd.wobly.generation.WoblyGeneratorUtils.extractNextType(WoblyGeneratorUtils.java:91)
at com.wowd.wobly.generation.types.impl.MapTypeCodeGenerator.defaultTypeFormat(MapTypeCodeGenerator.java:163)
at com.wowd.wobly.generation.types.TypeCodeHandler.defaultTypeFormat(TypeCodeHandler.java:121)
at com.wowd.wobly.generation.WoblyGeneratorUtils.adjusFormatForCompressed(WoblyGeneratorUtils.java:317)
at com.wowd.wobly.generation.WoblyCodeGenerator.generateWriteFieldCode(WoblyCodeGenerator.java:178)
at com.wowd.wobly.generation.WoblyCodeGenerator.generateWriteMethod(WoblyCodeGenerator.java:270)
at com.wowd.wobly.generation.WoblyCodeGenerator.generateFieldsAndMethods(WoblyCodeGenerator.java:647)
at com.wowd.wobly.generation.WoblyCodeGenerator.generateRegularCode(WoblyCodeGenerator.java:721)
at com.wowd.wobly.generation.WoblyCodeGenerator.generateCode(WoblyCodeGenerator.java:677)
at com.wowd.wobly.updater.GenerateAndReplace.update(GenerateAndReplace.java:130)
at com.wowd.wobly.updater.GenerateAndReplace$1.execute(GenerateAndReplace.java:198)
at com.wowd.wobly.updater.GenerateAndReplace$1.execute(GenerateAndReplace.java:1)
at com.wowd.common.functions.impl.FilterProcedure.execute(FilterProcedure.java:40)
at com.wowd.wobly.updater.SourceFilesVisitor.visitDir(SourceFilesVisitor.java:69)
at com.wowd.wobly.updater.SourceFilesVisitor.visitDir(SourceFilesVisitor.java:60)
at com.wowd.wobly.updater.SourceFilesVisitor.visitDir(SourceFilesVisitor.java:60)
at com.wowd.wobly.updater.SourceFilesVisitor.visitDir(SourceFilesVisitor.java:60)
at com.wowd.wobly.updater.SourceFilesVisitor.visitPackage(SourceFilesVisitor.java:38)
at com.wowd.wobly.updater.GenerateAndReplace.updateInPackage(GenerateAndReplace.java:190) WoblyParcel error
at com.wowd.wobly.WoblyGenerator.updatePackage(WoblyGenerator.java:60)
at com.wowd.wobly.WoblyGenerator.updateSourceFolder(WoblyGenerator.java:49)
at Generator.main(Generator.java:19)
Original comment by bost...@gmail.com
on 18 Feb 2012 at 3:32
As explained here
http://stackoverflow.com/questions/9334067/how-to-use-wobly-serializer-on-androi
d, won't fix
Original comment by ikabi...@gmail.com
on 2 Apr 2013 at 6:09
Original issue reported on code.google.com by
bost...@gmail.com
on 17 Feb 2012 at 6:57