JavaFX SimpleObjectProperty< T> vs SimpleTProperty [英] JavaFX SimpleObjectProperty<T> vs SimpleTProperty

查看:401
本文介绍了JavaFX SimpleObjectProperty< T> vs SimpleTProperty的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用

SimpleStringProperty SimpleObjectProperty<之间有什么区别? String>

SimpleIntegerProperty vs SimpleObjectProperty<整数>

除了返回包装器而不是原始类型?(它可以自动转换)

Besides returning wrappers and not primitive types?(It can be auto casted anyways)

推荐答案

API为特定类型添加了其他功能。所以 ObjectProperty 实际上只定义了作为属性的API,并且只能定义所有可能类型共有的功能。另一方面, StringProperty 定义(通过其超类 StringExpression )方法,例如 concat(.. 。) 返回另一个 ObservableValue< String> ,这是与提供的值连接的当前值。类似地, IntegerProperty 定义特定于数字的功能,例如 add 除以 等等等。

The API adds additional functionality for the specific types. So ObjectProperty really just defines the API for "being a property" and can only define functionality common to all possible types. On the other hand, StringProperty defines (via its superclass StringExpression) methods such as concat(...) which returns another ObservableValue<String> which is the current value concatenated with the provided value. Similarly, IntegerProperty defines numeric-specific functionality such as add, divide, etc etc.

因此,特定类型只是为特定于这些类型的更通用类型添加额外功能。它只是继承的标准用法。

So the specific types just add extra functionality to the more general type that is specific to those types. It is just the standard use of inheritance.

(注意, IntegerProperty 未实现 Property< Integer> ,它实现 Property< Number> 。)

(Note though, that IntegerProperty does not implement Property<Integer>, it implements Property<Number>.)

这篇关于JavaFX SimpleObjectProperty&lt; T&gt; vs SimpleTProperty的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆