我开始阅读有关瓦尔哈拉项目的内容,而且有一些我真的不明白的事情就是这样Value Types
.
这就是我的理解:
1)对象是否无法将其作为参考进行比较?
final ValueType a = new ValueType();
final ValueType b = a;
System.out.println(a==b); returns false????
Run Code Online (Sandbox Code Playgroud)
在Google AutoValue
代码示例中,它说明了
if(o == this){return true;}//equals method implementation what is this? I am comparing references here right?
Run Code Online (Sandbox Code Playgroud)
2)根据维基百科,高效的小"对象"没有继承.做什么Small Objects?
和Without inheritance
意味着什么?
这是不可能使用VT?
public final class ValueType extends Any //is this not possible??
Run Code Online (Sandbox Code Playgroud)
3)为什么使用它们?将使用哪种方案以及如何使用它.
4)Google AutoValue Library
简而言之,值类型对象是没有标识的对象,即如果它们各自的内部状态相等,则认为两个值对象相等.我的问题是:他们是否有州,他们应该实施equals
和hashcode
.什么是没有身份的对象是什么意思?
5)这个断言是否正确?
public static void …
Run Code Online (Sandbox Code Playgroud)