About withFields and withBean method in halbuilder-json for use in SCALA

49 views
Skip to first unread message

Lalkhum Sanga

unread,
May 9, 2014, 12:39:28 PM5/9/14
to halbuil...@googlegroups.com
Hi all,

I was trying to use the above mentioned methods (withFields and withBean methods in halbuilder-json) using Scala, but it is not giving anything back to me.

My code is

val representationFactory: String = (new JsonRepresentationFactory)
      .withFlag(
RepresentationFactory.PRETTY_PRINT)
      .newRepresentation()
      .withLink("self", "/sources/")
      .withBean(Customer("fsfs", "sss")
      .withFields(Customer("fsfs", "sss"))
      .withNamespace("ck", ROOT_URL + "{rel}")
      .withBeanBasedRepresentation("ck:leaves", "/lists/sampleassetid1", (Customer("/heylo", "heylo")))
      .withFieldBasedRepresentation("ck1:woohoo", "wahaha", Customer("/heylo", "heylo"))
      .toString(RepresentationFactory.HAL_JSON)


case class Customer(href: String, label: String)


Can anyone point out if i am missing something about withBean(..) and withFields(..) methods?

Many thanks,
Lalkhum Sanga

Mark Derricutt

unread,
May 13, 2014, 1:38:39 AM5/13/14
to halbuil...@googlegroups.com

On 10 May 2014, at 4:39, Lalkhum Sanga wrote:

I was trying to use the above mentioned methods (withFields and withBean methods in halbuilder-json) using Scala, but it is not giving anything back to me.

Replying on this list as well as the main hal list.

You can use either @JavaBean at the class level, or @BeanProperty at the field level to tell the scala compiler to generate javabean style getters/setters.

There may be reasons you might not want to do that tho for scala purity, so some means of generating a Reprentable instance might be useful ( I'll take a look at how I could maybe automate that using scala macros ).

Reply all
Reply to author
Forward
0 new messages