public class JavaTypeFactory extends Object implements JavaTypeMapper
The JavaTypeFactory
is used to infer HyperGraph types based on
Java beans. Java bean classes are converted to instances of
RecordType
and Java bean instances to the corresponding
Record
s. Only properties that are both readable and writeable
are mapped to HyperGraph Slot
s.
Modifier and Type | Field and Description |
---|---|
protected HyperGraph |
graph |
Constructor and Description |
---|
JavaTypeFactory() |
Modifier and Type | Method and Description |
---|---|
static void |
assignPrivate(Class<?> clazz,
Object x,
String field,
Object value) |
HGAtomType |
defineHGType(Class<?> javaClass,
HGHandle typeHandle)
Create a new HyperGraphDB type for the given Java class.
|
static Field |
findDeclaredField(Class<?> c,
String name) |
static Constructor<?> |
findDefaultConstructor(Class<?> c) |
static Constructor<?> |
findHandleArgsConstructor(Class<?> c) |
DefaultJavaTypeMapper |
getDefaultJavaMapper() |
HGAtomType |
getJavaBinding(HGHandle typeHandle,
HGAtomType hgType,
Class<?> javaClass)
Create a type wrapper for a given raw HyperGraphDB type.
|
JavaObjectMapper |
getJavaObjectMapper() |
List<JavaTypeMapper> |
getMappers() |
static HGHandle |
getSlotHandle(HyperGraph graph,
String label,
HGHandle type) |
static boolean |
isAbstract(Class<?> c) |
static boolean |
isDefaultConstructible(Class<?> c) |
static boolean |
isHGInstantiable(Class<?> c) |
static boolean |
isLink(Class<?> c) |
static Object |
retrievePrivate(Class<?> clazz,
Object x,
String field) |
void |
setHyperGraph(HyperGraph graph)
During load time, set the
HyperGraph
instance to which this atom belongs. |
protected HyperGraph graph
public static void assignPrivate(Class<?> clazz, Object x, String field, Object value)
public static boolean isAbstract(Class<?> c)
public static Constructor<?> findDefaultConstructor(Class<?> c)
public static boolean isDefaultConstructible(Class<?> c)
public static Field findDeclaredField(Class<?> c, String name) throws SecurityException
SecurityException
public static Constructor<?> findHandleArgsConstructor(Class<?> c)
public static boolean isLink(Class<?> c)
public static boolean isHGInstantiable(Class<?> c)
public static HGHandle getSlotHandle(HyperGraph graph, String label, HGHandle type)
public HGAtomType defineHGType(Class<?> javaClass, HGHandle typeHandle)
JavaTypeMapper
Create a new HyperGraphDB type for the given Java class. The HGHandle
of the type pre-created and provided as a parameter.
This method should return a brand new HGAtomType
that will subsequently
be saved as a type atom with handle typeHandle
and associated with
the javaClass
class. The method should return null
in
case it cannot (or it determines that it should not) create a HGAtomType
.
In the case the JavaTypeFactory will move on to try the next of the registered
type mappers.
defineHGType
in interface JavaTypeMapper
HGAtomType
corresponding to the passed in Java
class or null
if such a type could not be created.public HGAtomType getJavaBinding(HGHandle typeHandle, HGAtomType hgType, Class<?> javaClass)
JavaTypeMapper
Create a type wrapper for a given raw HyperGraphDB type. The type wrapper should work with the regular Java runtime instance of an atom and use the underlying HG type for actual storage and retrieval.
getJavaBinding
in interface JavaTypeMapper
typeHandle
- The handle of the type being wrapped.hgType
- The HyperGraphDB type instance to be wrappedjavaClass
- The Java class corresponding to this HyperGraphDB type.null
ifpublic void setHyperGraph(HyperGraph graph)
HGGraphHolder
During load time, set the HyperGraph
instance to which this atom belongs.
setHyperGraph
in interface HGGraphHolder
public DefaultJavaTypeMapper getDefaultJavaMapper()
public JavaObjectMapper getJavaObjectMapper()
public List<JavaTypeMapper> getMappers()
Copyright © 2015. All rights reserved.