Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6f68669
commit 6bce1ad
Showing
21 changed files
with
237 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
javers-core/src/main/java/org/javers/core/metamodel/type/ClassType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package org.javers.core.metamodel.type; | ||
|
||
import org.javers.common.reflection.ReflectionUtil; | ||
import org.javers.common.validation.Validate; | ||
import java.lang.reflect.Type; | ||
import java.util.Optional; | ||
|
||
import static org.javers.common.validation.Validate.argumentIsNotNull; | ||
|
||
/** | ||
* Class or ParametrizedType | ||
*/ | ||
abstract class ClassType extends JaversType { | ||
|
||
private final Class baseJavaClass; | ||
|
||
ClassType(Type baseJavaType) { | ||
this(baseJavaType, Optional.empty()); | ||
} | ||
|
||
ClassType(Type baseJavaType, Optional<String> name) { | ||
this(baseJavaType, name, 0); | ||
} | ||
|
||
ClassType(Type baseJavaType, Optional<String> name, int expectedArgs) { | ||
super(baseJavaType, name, expectedArgs); | ||
Validate.argumentIsNotNull(name); | ||
this.baseJavaClass = ReflectionUtil.extractClass(baseJavaType); | ||
} | ||
|
||
@Override | ||
public boolean canBePrototype() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean isInstance(Object cdo) { | ||
argumentIsNotNull(cdo); | ||
return baseJavaClass.isAssignableFrom(cdo.getClass()); | ||
} | ||
|
||
/** | ||
* Type for JSON representation. | ||
* | ||
* For Values it's simply baseJavaType. | ||
* | ||
* For ManagedTypes (references to Entities and ValueObjects) it's GlobalId | ||
* because JaVers serializes references in the 'dehydrated' form. | ||
*/ | ||
protected Type getRawDehydratedType() { | ||
return baseJavaClass; | ||
} | ||
|
||
public Class getBaseJavaClass() { | ||
return baseJavaClass; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.