Uses an IdentityMap to make sure we don't recurse infinitely on the same object in a cyclic object model.
Proxies
@param obj
@return
483252
public Object copy(final Object obj, final PersistenceBroker broker)
    {
        return clone(obj, IdentityMapFactory.getIdentityMap(), broker);
    }
1089632
private Object extractObjectToStore(Object obj)
    {
        Object result = obj;
        // only do something if obj != null
        if(result != null)
        {
            // ProxyObjects only have to be updated if their real
            // subjects have been loaded
            result = getProxyFactory().getRealObjectIfMaterialized(obj);
            // null for unmaterialized Proxy
            if (result == null)
            {
                if(logger.isDebugEnabled())
                    logger.debug("No materialized object could be found -> nothing to store," +
                            " object was " + ObjectUtils.identityToString(obj));
            }
        }
        return result;
    }
124593
public static PBES2Parameters getInstance(Object obj)
    {
        if (obj instanceof PBES2Parameters) {
            return (PBES2Parameters) obj;
        }
        if (obj instanceof org.bouncycastle.asn1.pkcs.PBES2Parameters) {
            return new PBES2Parameters(((org.bouncycastle.asn1.pkcs.PBES2Parameters) obj).getKeyDerivationFunc(),
                ((org.bouncycastle.asn1.pkcs.PBES2Parameters) obj).getEncryptionScheme());
        }
        if (obj != null) {
            return new PBES2Parameters(ASN1Sequence.getInstance(obj));
        }
        return null;
    }
590107
public static Stream<Map.Entry<Method, Object>> getters(Object obj) {
		return getters(obj, Predicates.alwaysTrue());
	}
698191
public String putObject(Object obj) {
    String objectId = UUID.randomUUID().toString();
    cachedObjects.put(objectId, obj);
    return objectId;
  }
1143905
public void cache(Identity oid, Object obj)
    {
        try
        {
            jcsCache.put(oid.toString(), obj);
        }
        catch (CacheException e)
        {
            throw new RuntimeCacheException(e);
        }
    }
1044386
public MappedClass getMappedClass(final Object obj) {
        if (obj == null) {
            return null;
        }

        Class type = (obj instanceof Class) ? (Class) obj : obj.getClass();
        if (ProxyHelper.isProxy(obj)) {
            type = ProxyHelper.getReferentClass(obj);
        }

        MappedClass mc = mappedClasses.get(type.getName());
        if (mc == null) {
            mc = new MappedClass(type, this);
            // no validation
            addMappedClass(mc, false);
        }
        return mc;
    }
1138205
public <T extends BaseProxy> T editProxy(final T object) {
    AutoBean<T> bean = this.checkStreamsNotCrossed(object);
    this.checkLocked();

    @SuppressWarnings("unchecked")
    final AutoBean<T> previouslySeen =
        (AutoBean<T>) this.state.editedProxies.get(BaseProxyCategory.stableId(bean));
    if (previouslySeen != null && !previouslySeen.isFrozen()) {
      /*
       * If we've seen the object before, it might be because it was passed in as a method argument.
       * This does not guarantee its mutability, so check that here before returning the cached
       * object.
       */
      return previouslySeen.as();
    }

    // Create editable copies
    final AutoBean<T> parent = bean;
    bean = this.cloneBeanAndCollections(bean);
    bean.setTag(Constants.PARENT_OBJECT, parent);
    return bean.as();
  }
708262
public static <T> T convertToGenericObject(Object object) {

        try {
            return (T) innerConvertToGenericObject(object, new IdentityHashMap<Object, Object>());
        } catch (Throwable t) {
            throw new ConvertException(t);
        }
    }
710468
public T toDomain(RiakObject obj, Location location)
    {
        T domainObject;
        if (obj.isDeleted())
        {
            domainObject = newDomainInstance();
        }
        else
        {
            domainObject = toDomain(obj.getValue(), obj.getContentType());

            AnnotationUtil.populateIndexes(obj.getIndexes(), domainObject);
            AnnotationUtil.populateLinks(obj.getLinks(), domainObject);
            AnnotationUtil.populateUsermeta(obj.getUserMeta(), domainObject);
            AnnotationUtil.setContentType(domainObject, obj.getContentType());
            AnnotationUtil.setVTag(domainObject, obj.getVTag());
        }

        AnnotationUtil.setKey(domainObject, location.getKey());
        AnnotationUtil.setBucketName(domainObject, location.getNamespace().getBucketName());
        AnnotationUtil.setBucketType(domainObject, location.getNamespace().getBucketType());

        AnnotationUtil.setVClock(domainObject, obj.getVClock());
        AnnotationUtil.setTombstone(domainObject, obj.isDeleted());
        AnnotationUtil.setLastModified(domainObject, obj.getLastModified());

        return domainObject;
    }
688256
private <T> T getProxyObject(
      T originalObject, AdWordsSession session, Class<T> cls, boolean isUtility) {
    // Find the retry strategy of this class type.
    ApiRetryStrategy retryStrategy =
        ApiRetryStrategyManager.getRetryStrategy(cls.getSimpleName(), isUtility);

    // If no corresponding retry strategy, just use the original object instead of a wrapping proxy.
    if (retryStrategy == null) {
      return originalObject;
    }

    InvocationHandler invocationHandler =
        new ApiInvocationHandlerWithRateLimiter(originalObject, session, retryStrategy);
    return Reflection.newProxy(cls, invocationHandler);
  }
519705
private static KunderaProxy getProxyInstance(Class factory, CglibLazyInitializer instance)
    {
        KunderaProxy proxy;
        try
        {
            Enhancer.registerCallbacks(factory, new Callback[] { instance, null });
            proxy = (KunderaProxy) factory.newInstance();
        }
        catch (IllegalAccessException e)
        {
            throw new LazyInitializationException(e);
        }
        catch (InstantiationException e)
        {
            throw new LazyInitializationException(e);
        }
        finally
        {
            Enhancer.registerCallbacks(factory, null);
        }
        return proxy;
    }
638395
public void cache(Identity oid, Object obj)
    {
        if ((obj != null))
        {
            SoftReference ref = new SoftReference(obj);
            objectTable.put(oid, ref);
        }
    }
562088
public Object getRealObjectIfMaterialized(Object objectOrProxy)
    {
        if(isNormalOjbProxy(objectOrProxy))
        {
            String msg;

            try
            {
                IndirectionHandler handler = getIndirectionHandler(objectOrProxy);

                return handler.alreadyMaterialized() ? handler.getRealSubject() : null;
            }
            catch(ClassCastException e)
            {
                // shouldn't happen but still ...
                msg = "The InvocationHandler for the provided Proxy was not an instance of " + IndirectionHandler.class.getName();
                log.error(msg);
                throw new PersistenceBrokerException(msg, e);
            }
            catch(IllegalArgumentException e)
            {
                msg = "Could not retrieve real object for given Proxy: " + objectOrProxy;
                log.error(msg);
                throw new PersistenceBrokerException(msg, e);
            }
            catch(PersistenceBrokerException e)
            {
                log.error("Could not retrieve real object for given Proxy: " + objectOrProxy);
                throw e;
            }
        }
        else if(isVirtualOjbProxy(objectOrProxy))
        {
            try
            {
                VirtualProxy proxy = (VirtualProxy) objectOrProxy;

                return proxy.alreadyMaterialized() ? proxy.getRealSubject() : null;
            }
            catch(PersistenceBrokerException e)
            {
                log.error("Could not retrieve real object for VirtualProxy: " + objectOrProxy);
                throw e;
            }
        }
        else
        {
            return objectOrProxy;
        }
    }
606049
def _get_proxy_object(self, obj, ProxyKlass, proxy_klass_attribute):
        
        proxy_object = obj
        if not isinstance(obj, ProxyKlass):
            proxy_object = ProxyKlass(**{proxy_klass_attribute: obj})
        return proxy_object
783699
public static Map<String, Object> getPropertyMap(Object obj) {
        Assert.notNull(obj, "Argument cannot be null");

        try {
            BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass());
            PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
            Map<String, Object> propertyMap = new HashMap<String, Object>(propertyDescriptors.length);
            for (PropertyDescriptor pd : propertyDescriptors) {
                Method getter = pd.getReadMethod();
                if (getter != null) {
                    propertyMap.put(pd.getName(), getter.invoke(obj));
                }
            }
            return propertyMap;
        }
        catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
1294401
function makeProxy(object) {
    if (((typeof(object) === 'object') && (!Array.isArray(object))) ||
        (typeof(object) === 'function')) {

      /* Only non-array objects and functions get proxied */
      var proxyId = messages.addProxy(object);
      var definition = defineProxy(object);
      return { proxy: { id: proxyId, definition: definition }};

    } else {

      /* Arrays and normal objects go through as values */
      return { resolve: object };
    }
  }