Finds or creates a near object for the given far object.
@param farObject The far object that is to be wrapped by the near object
@return The near object that corresponds to the given far object
975648
public Object getNearObject(Object farObject) {
        Object nearObject = null;
        if (farObject instanceof BridgeFacet) {
            BridgeFacet facet = (BridgeFacet) farObject;
            if (facet.hasBridgeFacets()) {
                BridgeFacets facets = facet.getBridgeFacets();
                if (facets.hasNearObject()) {
                    nearObject = nearType.cast(facets.getNearObject());
                }
            }
        }
        if (nearObject == null) {
            if (!farType.isInstance(farObject)) {
                RuntimeException exception = new ClassCastException("Class: " + display(farType) + ": object: " + display(farObject));
                if (logger.isTraceEnabled()) {
                    logger.trace("Far type: " + display(farType), exception);
                }
                throw exception;
            }
            Class<?>[] interfaces = new Class[] { BridgeFacet.class };
            final BridgeFacets facets;
            if (farObject instanceof BaseBridgeFacet && ((BaseBridgeFacet) farObject).hasBridgeFacets()) {
                facets = ((BaseBridgeFacet) farObject).getBridgeFacets();
            } else {
                Map<Integer,Object> helperInstances = new HashMap<>();
                for (int i = 0; i < helpers.length; i++) {
                    Object helper = helpers[i];
                    if (helper instanceof Class) {
                        Class<?> helperType = (Class<?>) helper;
                        try {
                            Object helperInstance = helperType.newInstance();
                            helperInstances.put(i, helperInstance);
                        } catch (Throwable throwable) {
                            throw ExceptionWrapper.wrap(throwable);
                        }
                    }
                }
                facets = new BridgeFacets(farType.cast(farObject), this, helperInstances);
                for (Object helperInstance : helperInstances.values()) {
                    if (helperInstance instanceof BaseBridgeFacet) {
                        ((BaseBridgeFacet) helperInstance).setBridgeFacets(facets);
                    }
                }
            }
            if (farObject instanceof BaseBridgeFacet && !((BaseBridgeFacet) farObject).hasBridgeFacets()) {
                ((BaseBridgeFacet) farObject).setBridgeFacets(facets);
            }
            nearObject = newProxyInstance(getClass().getClassLoader(), nearType, interfaces, (object, method, parameters) -> {
                Object result;
                if (logger.isTraceEnabled()) {
                    logger.trace("Facets getter: " + display(facetsGetter));
                }
                if (method.equals(facetsGetter)) {
                    result = facets;
                } else if (method.equals(facetsChecker)) {
                    result = Boolean.TRUE;
                } else {
                    Binding binding = methodMap.get(method);
                    if (binding == null) {
                        String message = "No binding found: " + display(nearType) + ": " + display(method);
                        logger.warn(message);
                        throw new UnsupportedOperationException(message);
                    }
                    result = binding.invoke(facets, parameters);
                    Class<?> returnType = method.getReturnType();
                    if (logger.isTraceEnabled()) {
                        logger.trace("Return type: " + displayWithTypes(returnType));
                    }
                    if (result instanceof TypedIterable) {
                        TypedIterable<?> typedIterable = (TypedIterable<?>) result;
                        Class<?> baseType = typedIterable.getType();
                        if (logger.isTraceEnabled()) {
                            logger.trace("Iterable base type: " + display(baseType));
                        }
                        if (registry.hasFarType(baseType)) {
                            Class<?> type = getNearType(baseType);
                            result = getAdaptedIterable(returnType, typedIterable, type);
                        } else if (registry.hasNearType(baseType)) {
                            result = getAdaptedIterable(returnType, typedIterable, baseType);
                        } else if (logger.isTraceEnabled()) {
                            logger.trace("Iterable base type not found in registry");
                        }
                    } else if (registry.hasNearType(returnType)) {
                        Class<?> farType1 = registry.getFarType(method.getReturnType());
                        if (logger.isTraceEnabled()) {
                            logger.trace("Far type of return type: " + display(farType1));
                        }
                        if (farType1.isInstance(result)) {
                            BridgeFactory factory = registry.getBridgeFactory(farType1);
                            if (logger.isTraceEnabled()) {
                                logger.trace("Far type of return type factory: " + display(factory.getFarType()));
                                logger.trace("Result: " + display(result));
                                logger.trace("Return type: " + display(returnType) + ": factory PO type: " + display(factory.getNearType()));
                            }
                            try {
                                result = factory.getNearObject(result);
                            } catch (ClassCastException exception) {
                                if (logger.isTraceEnabled()) {
                                    logger.trace("Stack trace", exception);
                                }
                                throw exception;
                            }
                        }
                    } else if (logger.isTraceEnabled()) {
                        logger.trace("Not adapted");
                    }
                }
                return result;
            });
            facets.setNearObject(nearObject);
        }
        return nearObject;
    }
630590
public static final Function<Long,Boolean> notEq(final Long object) {
        return (Function<Long,Boolean>)((Function)FnObject.notEq(object));
    }
121869
public static Location getObjectLocation(ShanksSimulation simulation,
            PercipientShanksAgent agent, Object object) {
        try {
            if (agent.getCurrentLocation().is3DLocation()) {
                ContinuousPortrayal3D devicesPortrayal;
                devicesPortrayal = (ContinuousPortrayal3D) simulation
                        .getScenarioPortrayal().getPortrayals()
                        .get(Scenario3DPortrayal.MAIN_DISPLAY_ID)
                        .get(ScenarioPortrayal.DEVICES_PORTRAYAL);
                Continuous3D devicesField = (Continuous3D) devicesPortrayal
                        .getField();
                Double3D loc = devicesField.getObjectLocation(object);
                return new Location(loc);
            } else if (agent.getCurrentLocation().is2DLocation()) {
                ContinuousPortrayal2D devicesPortrayal = (ContinuousPortrayal2D) simulation
                        .getScenarioPortrayal().getPortrayals()
                        .get(Scenario2DPortrayal.MAIN_DISPLAY_ID)
                        .get(ScenarioPortrayal.DEVICES_PORTRAYAL);
                Continuous2D devicesField = (Continuous2D) devicesPortrayal
                        .getField();
                Double2D loc = devicesField.getObjectLocation(object);
                return new Location(loc);
            }
        } catch (DuplicatedPortrayalIDException e) {
            e.printStackTrace();
        } catch (ScenarioNotFoundException e) {
            e.printStackTrace();
        } catch (ShanksException e) {
            e.printStackTrace();
        }
        return null;

    }
50350
public Object nextElement() 
    {
        if (_array == null)
        {
            return null;
        }
        else
        {
            synchronized(this){
                if (_index < _array.length)
                {
                    Object obj = _array[_index];
                    _index++;
                    return obj;
                }
                else
                {
                    return null;
                }
            }
        }
    }
1202832
public Frustum setToFrustum (
        double left, double right, double bottom, double top, double near, double far) {
        return setToProjection(left, right, bottom, top, near, far, Vector3.UNIT_Z, false, false);
    }
100648
function(obj) {
                var P = this.pointClosestTo(obj);
                return (P === null) ? null : P.distanceFrom(obj);
              }
1052688
public synchronized E intern(@NonNull final E object) {
      return map.computeIfAbsent(object, o -> object);
   }
537290
public Object getRealSubject() throws PersistenceBrokerException
	{
		if (_realSubject == null)
		{
			beforeMaterialization();
			_realSubject = materializeSubject();
			afterMaterialization();
		}
		return _realSubject;
	}
432733
public function farray() {
		if(is_object($this->sth)) {
			$retval = $this->sth->fetchAll();
		}
		else {
			throw new Exception(__METHOD__ .": statement handle was not created");
		}
		
		return($retval);
	}
344891
public RangeObject getNext()
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(this, tc, "getNext", Integer.valueOf(cursor));

    int curr = cursor;
    cursor = cursor < (blockVector.size() - 1) ? cursor + 1 : cursor;

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "getNext", new Object[] {blockVector.get(curr), Integer.valueOf(cursor)});

    return (RangeObject) blockVector.get(curr);
  }
1328240
public static int getSize(final Object iObject) {
    if (iObject == null)
      return 0;

    if (!isMultiValue(iObject))
      return 0;

    if (iObject instanceof Collection<?>)
      return ((Collection<Object>) iObject).size();
    if (iObject instanceof Map<?, ?>)
      return ((Map<?, Object>) iObject).size();
    if (iObject.getClass().isArray())
      return Array.getLength(iObject);
    return 0;
  }
519863
public static final GVRPickedObject pickSceneObject(GVRSceneObject sceneObject) {
        GVRCameraRig cam = sceneObject.getGVRContext().getMainScene().getMainCameraRig();
        GVRTransform t = cam.getHeadTransform();
        float[] lookat = cam.getLookAt();
        return NativePicker.pickSceneObject(sceneObject.getNative(), t.getPositionX(), t.getPositionY(), t.getPositionZ(),
                lookat[0], lookat[1], lookat[2]);
    }
260663
public static final Function<Long,Boolean> eq(final Long object) {
        return (Function<Long,Boolean>)((Function)FnObject.eq(object));
    }
65340
function findObject(c, obj, path, alreadyParsed) {
    if (!path) {
        path = [];
    }

    // Recursive reference : boooh, very wrong
    if (!alreadyParsed) {
        alreadyParsed = [];
    }
    var keys = Object.keys(obj);
    alreadyParsed.push(obj);
    for (var key = 0; key < keys.length; key++) {
        var i = keys[key];
        if (i == "NativeModule" && isElectron) {
            break;
        }
        if (obj[i] === c) {
            path.push(i);
            return path;
        } else if (["object", "function"].indexOf(typeof(obj[i])) >= 0 && alreadyParsed.indexOf(obj[i]) == -1 && obj[i] !== null && obj[i] !== undefined) {
            path.push(i);
            var founded = findObject(c, obj[i], path, alreadyParsed);
            if (founded) {
                return founded;
            } else {
                path.pop();
            }
        }
    };
    return null;
}
1153033
@Override
    public Serializable getRealObject() throws IOException, ClassNotFoundException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "getRealObject");

        Serializable obj = null;

        // We 'have' a real object, though we may not still have a ref to to it.
        if (hasRealObject) {
            obj = realObject;

            // if it is null it may be because we previously serialized & threw away the strong ref
            if ((obj == null) && (hasSerializedRealObject)) {

                // Unless the value really is a null, we will have set a SoftReference for it
                if (softRefToRealObject != null) {

                    // Can we get it back from the SoftReference?
                    obj = softRefToRealObject.get();
                    // If not, deserialize from the message.
                    if (obj == null) {
                        obj = deserializeToRealObject();
                    }
                }

            }

            // If we hadn't previously serialized the message, then whatever was in realObject is the real
            // value, even if it is null.
        }

        // If we didn't 'have' a real object at all, just deserialize the one in the message
        else {
            obj = deserializeToRealObject();
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "getRealObject", (obj == null ? "null" : obj.getClass()));
        return obj;
    }
899775
public <T, K extends Serializable>
    T findById(
                    final Class<T> type,
                    final K id
                    )
    {
       _LOG_.info( "findById: type=" + type + ", ID=" + id );
       long  ts_start = System.currentTimeMillis();

       T  p_object = null;
       try {
           p_object = getDAO( type ).get( id );
       } catch (Exception ex) {
           throw new RepositoryException( ex );
       }

       _LOG_.info( "findById: elapsed time (ms)=" +  (System.currentTimeMillis() - ts_start) );
       _LOG_.debug( (p_object == null ? "findById: object NOT found" : "findById: object found") );
       if (p_object == null) {
           ObjectNotFoundException  ex = new ObjectNotFoundException( "type=" + type + ", id=" + id );
           ex.setType( type );
           ex.setId( id );
           throw ex;
       }

       return p_object;
   }
940353
@SuppressWarnings("null")
    // TODO: Too much code, improve this, possibly by breaking it
    public static final Object getObject(Object obj, String fieldName)
    {
        Field embeddedField;
        try
        {
            embeddedField = obj.getClass().getDeclaredField(fieldName);
            if (embeddedField != null)
            {
                if (!embeddedField.isAccessible())
                {
                    embeddedField.setAccessible(true);
                }
                Object embededObject = embeddedField.get(obj);
                if (embededObject == null)
                {
                    Class embeddedObjectClass = embeddedField.getType();
                    if (Collection.class.isAssignableFrom(embeddedObjectClass))
                    {
                        if (embeddedObjectClass.equals(List.class))
                        {
                            return new ArrayList();
                        }
                        else if (embeddedObjectClass.equals(Set.class))
                        {
                            return new HashSet();
                        }
                    }
                    else
                    {
                        embededObject = embeddedField.getType().newInstance();
                        embeddedField.set(obj, embededObject);
                    }

                }
                return embededObject;
            }
            else
            {
                throw new PropertyAccessException("Embedded object not found: " + fieldName);
            }

        }
        catch (Exception e)
        {
            throw new PropertyAccessException(e);
        }
    }