Boon supports for coercion and JSON serialization gets timezone locale UUID URL URI File and Path it had Class but I did not advertise it
Boon supports for coercion and JSON serialization gets timezone locale UUID URL URI File and Path it had Class but I did not advertise it
I added support for timezone, locale, UUID, URL, URI, File and Path.
RichardHightower commented 4 minutes ago
/**
*
* @author l man
*/
public static class Sample
implements Serializable {
private static final long serialVersionUID = 1L;
private URL url;
private URI uri;
private File file;
private Date date;
private final UUID persistId;
private Path path;
private Locale locale;
private TimeZone timeZone;
private static final AtomicLongFieldUpdater<Sample> EFFECTIVEDATE_UPDATER
= AtomicLongFieldUpdater.newUpdater(Sample.class, "effectiveDate");
public Sample() {
this.persistId = UUID.randomUUID();
this.effectiveDate = System.currentTimeMillis();
try {
url = new URL("http://www.google.com");
} catch (MalformedURLException e) {
e.printStackTrace();
}
try {
uri = new URI("http://www.google.com");
} catch (URISyntaxException e) {
e.printStackTrace();
}
file =new File("/usr/local/bin/vertx");
date = new Date();
path = file.toPath();
locale = Locale.CANADA;
timeZone = TimeZone.getTimeZone("PST");
}
public UUID getPersistId() {
return persistId;
}
private volatile long effectiveDate;
public final long getEffectiveDate() {
return effectiveDate;
}
public final void setEffectiveDate(long effectiveDate) {
EFFECTIVEDATE_UPDATER.compareAndSet(this, this.effectiveDate, effectiveDate);
}
...
@Test
public void test4() {
Sample sample1 = new Sample();
String json = JsonFactory.toJson(sample1);
puts(json);
puts (sample1);
ok = json.contains(""effectiveDate"") || die();
Sample sample2 = JsonFactory.fromJson(json, Sample.class);
puts ("sample2", sample2);
puts ("sample2", JsonFactory.toJson(sample2));
ok = sample1.equals(sample2);
}