public GlobalId createId(Object targetCdo, OwnerContext ownerContext) {
        Validate.argumentsAreNotNull(targetCdo);

        Optional<ObjectAccessProxy> cdoProxy = objectAccessHook.createAccessor(targetCdo);

        Class<?> targetClass = cdoProxy.map((p) -> p.getTargetClass()).orElse(targetCdo.getClass());
        ManagedType targetManagedType = typeMapper.getJaversManagedType(targetClass);

        if (targetManagedType instanceof EntityType) {
            if (cdoProxy.isPresent() && cdoProxy.get().getLocalId().isPresent()){
                return createInstanceId(cdoProxy.get().getLocalId().get(), targetClass);
            }
            else {
                return ((EntityType) targetManagedType).createIdFromInstance(targetCdo);
            }
        }

        if (targetManagedType instanceof ValueObjectType && !hasOwner(ownerContext)) {
            return new UnboundedValueObjectId(targetManagedType.getName());
        }

        if (targetManagedType instanceof ValueObjectType && hasOwner(ownerContext)) {
            String pathFromRoot = createPathFromRoot(ownerContext.getOwnerId(), ownerContext.getPath());

            if (ownerContext.requiresObjectHasher()) {
                return new ValueObjectIdWithPlaceholder(targetManagedType.getName(),
                        getRootOwnerId(ownerContext),
                        pathFromRoot);
            } else if (ownerContext.getOwnerId() instanceof ValueObjectIdWithHash) {
                return new ValueObjectIdWithPlaceholderOnParent(targetManagedType.getName(),
                        (ValueObjectIdWithHash)ownerContext.getOwnerId(),
                        ownerContext.getPath());
            }
            else {
                return new ValueObjectId(targetManagedType.getName(), getRootOwnerId(ownerContext), pathFromRoot);
            }
        }

        throw new JaversException(JaversExceptionCode.NOT_IMPLEMENTED);
    }
public GlobalId createId ( Object targetCdo , OwnerContext ownerContext ) { Validate . argumentsAreNotNull ( targetCdo ) ; Optional < ObjectAccessProxy > cdoProxy = objectAccessHook . createAccessor ( targetCdo ) ; Class < ? > targetClass = cdoProxy . map ( ( p ) -> p . getTargetClass ( ) ) . orElse ( targetCdo . getClass ( ) ) ; ManagedType targetManagedType = typeMapper . getJaversManagedType ( targetClass ) ; if ( targetManagedType instanceof EntityType ) { if ( cdoProxy . isPresent ( ) && cdoProxy . get ( ) . getLocalId ( ) . isPresent ( ) ) { return createInstanceId ( cdoProxy . get ( ) . getLocalId ( ) . get ( ) , targetClass ) ; } else { return ( ( EntityType ) targetManagedType ) . createIdFromInstance ( targetCdo ) ; } } if ( targetManagedType instanceof ValueObjectType && ! hasOwner ( ownerContext ) ) { return new UnboundedValueObjectId ( targetManagedType . getName ( ) ) ; } if ( targetManagedType instanceof ValueObjectType && hasOwner ( ownerContext ) ) { String pathFromRoot = createPathFromRoot ( ownerContext . getOwnerId ( ) , ownerContext . getPath ( ) ) ; if ( ownerContext . requiresObjectHasher ( ) ) { return new ValueObjectIdWithPlaceholder ( targetManagedType . getName ( ) , getRootOwnerId ( ownerContext ) , pathFromRoot ) ; } else if ( ownerContext . getOwnerId ( ) instanceof ValueObjectIdWithHash ) { return new ValueObjectIdWithPlaceholderOnParent ( targetManagedType . getName ( ) , ( ValueObjectIdWithHash ) ownerContext . getOwnerId ( ) , ownerContext . getPath ( ) ) ; } else { return new ValueObjectId ( targetManagedType . getName ( ) , getRootOwnerId ( ownerContext ) , pathFromRoot ) ; } } throw new JaversException ( JaversExceptionCode . NOT_IMPLEMENTED ) ; }
@param ownerContext for bounded ValueObjects, optional