English 中文(简体)
土库曼地产测绘
原标题:dozer Boolean property mapping

看来,如果该财产的存取人被定义为<条码>isProperty(<>,而不是<条码>>植被保护()。

The following groovy script show the problem:

import org.dozer.*

class ProductCommand {
    Boolean foo 
}

public class ProductDto  {

    private Boolean foo;        

    public Boolean isFoo() { this.foo }    
    public void setFoo(Boolean p0) { this.foo = p0 }           
}

def mapper =  new DozerBeanMapper()

dto = new ProductDto(foo: true)
assert dto.isFoo()

ProductCommand mappedCmd = mapper.map(dto, ProductCommand)
assert mappedCmd.foo

关于最后一行的说法失败了。 但是,如果我改名为ProductDto.isFoo()ProductDto.getFoo(>。

Dozer绘图档案中是否有旗帜/图象,将指示它使用isget 进入海底房地产? 或者,我可以增加每个羊毛财产的习惯规则,但这并不是非常令人信服的。

Although the example above is written in Groovy, I ve no reason to believe the same behaviour wouldn t be exhibited by the equivalent Java code.

These DTOs are generated by JAXB (which generates an "is" accessor, rather than a "get" accessor for booleans), so I can t rename the accessors. I m using Dozer 5.3.2.

问题回答

May be you can use custom getter method to use it.

这里的示例(在编织物档案中填写)

<mapping>
  <class-a>ProductDto</class-a>
  <class-b>ProductCommand</class-b>
<field>
  <a get-method="isFoo">foo</a>
  <b>foo</b>
</field>
</mapping>

So now dozer will use isFoo instead of predefined getFoo. Hope this works for you. :)

Generating "is" methods for the Boolean wrapper class is a bug in JAXB, see Java Beans, BeanUtils, and the Boolean wrapper class and http://java.net/jira/browse/JAXB-131 for details. Seems to be fixed in jaxb 2.1.13

这是日本宇宙航空研究开发机构、小型-bboolean的模版。 应为<条码>。 您可以使用可推广的Introspection备选办法,后来版本为日本宇宙航空研究开发局,也可以使用旧的Boolean Recter xjc plugin rel=“nofollow”http://fisheye5.cenqua.com/browse/~rawr=MAIN/jaxbcommons/www/bean-getter/index.html。

还有另一种方式是进行正确的推土测绘(我认为是最清洁的):

<mapping>
    <class-a>ProductDto</class-a>
    <class-b>ProductCommand</class-b>
    <field>
       <a is-accessible=”true”>foo</a>
       <b is-accessible=”true”>foo</b>
    </field>
</mapping>

OR 前面已经提到的方式:

<mapping>
    <class-a>ProductDto</class-a>
    <class-b>ProductCommand</class-b>
    <field>
       <a get-method=”isFoo”>foo</a>
       <b>foo</b>
    </field>
</mapping>




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签