English 中文(简体)
Java 扩展属性、打字和鉴定的图书馆
原标题:Java library for extended attributes, typing and validation

背景: 我有一个目标模型,需要加以扩展,在几种特性中添加一些特性,而这种特性在各种装置之间可能有所不同。 例如,我的用户对象需要具备一些扩展属性。 在一些网站,用户需要若干识别资料,而在另一些网站,用户需要其他特征,如额外电话号码、地址和日期。 我更愿意避免维持几个物体模式和接口,而是将这种模型作为“可扩展物体特性”。

问题: 是否有一个 Java图书馆能够处理类型定义,提供分类的财产袋,列出财产的方法,执行打字,验证价值,将价值转换到和从Sting,并可能帮助处理相关的King查询和进行处理。

我需要能够按方案界定类型和属性。 最好能从配置档案中装载类型定义。

评论非常受欢迎。 谢谢。

问题回答

如果我获得你的权利,那么,用海峡机械师的标记就几乎是不可能的,正如你可能在某些类别中混杂在一起的,但可能含有密码,因此,你无需在你使用时重写抽象的方法。

trait Stackoverflow {
   val foo = "FOO"
}

trait MetaStackoverflow {
   val bar = "BAR"
}

class User(val name: String)

现改为:

scala> val u = new User("jjmontes") with Stackoverflow with MetaStackoverflow   
//u: User with Stackoverflow with MetaStackoverflow = $anon$1@8825a5

scala> u.bar  
//res0: java.lang.String = BAR

scala> u.foo  
//res1: java.lang.String = FOO

Or like this:

scala> class UserA(name: String) extends User(name) with Stackoverflow
//defined class UserA

scala> val u = new UserA("jjmontes")
//u: UserA = UserA@1aecf45

scala> u.foo
//res8: java.lang.String = FOO

scala> u.bar
<console>:12: error: value bar is not a member of UserA
              u.bar

Scala与Java有几乎完全的交错(只有少数几例病例除外,那里仍然有交错,但痛苦)。

这在java很困难。 但是,当然,你有:-

你可以使用格罗维,也可以使用 Java。

在java,你可以使用一些的地物文件、财产或XML、Json、Yaml。





相关问题
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 ...

热门标签