forked from javers/javers
/
ValueObjectType.java
55 lines (48 loc) · 1.38 KB
/
ValueObjectType.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package org.javers.core.metamodel.type;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
/**
* ValueObject class in client's domain model.
* <br/><br/>
*
* Has list of mutable properties but no unique identifier.
* <br/><br/>
*
* Two ValueObjects are compared property by property.
* <br/><br/>
*
* Example:
* <pre>
* class Address {
* private String city;
* private String street;
* private String zip;
* ...
* }
* </pre>
*
* @author bartosz walacik
*/
public class ValueObjectType extends ManagedType{
private final boolean defaultType;
ValueObjectType(ManagedClass valueObject){
super(valueObject);
this.defaultType = false;
}
public ValueObjectType(Class baseJavaClass, List<JaversProperty> allProperties){
this(new ManagedClass(baseJavaClass, allProperties, Collections.emptyList(), ManagedPropertiesFilter.empty(), false));
}
ValueObjectType(ManagedClass valueObject, Optional<String> typeName, boolean isDefault) {
super(valueObject, typeName);
this.defaultType = isDefault;
}
@Override
ValueObjectType spawn(ManagedClass managedClass, Optional<String> typeName) {
return new ValueObjectType(managedClass, typeName, defaultType);
}
@Override
public boolean canBePrototype() {
return !defaultType;
}
}