Obtains a MetaClass for an object either from the registry or in the case of
a GroovyObject from the object itself.

@param obj The object in question
@return The MetaClass
@since 1.5.0
519196
public static MetaClass getMetaClass(Object obj) {
        MetaClass mc = InvokerHelper.getMetaClass(obj);
        return new HandleMetaClass(mc, obj);
    }
249243
public static boolean isSameMetaClass(MetaClass mc, Object receiver) {
        //TODO: remove this method if possible by switchpoint usage
        return receiver instanceof GroovyObject && mc==((GroovyObject)receiver).getMetaClass(); 
    }
1337005
@SuppressWarnings("unchecked")
    public static <T> T getPropertyIfExists(Object instance, String property, Class<T> requiredType) {
        MetaClass metaClass = getMetaClass(instance);

        MetaProperty metaProperty = metaClass.getMetaProperty(property);
        if (metaProperty != null) {
            Object value = metaProperty.getProperty(instance);
            if (value != null && requiredType.isInstance(value)) {
                return (T) value;
            }
        }
        return null;
    }
96162
public Class getRealClass(Object objectOrProxy)
    {
        IndirectionHandler handler;

        if(isNormalOjbProxy(objectOrProxy))
        {
            String msg;

            try
            {
                handler = getIndirectionHandler(objectOrProxy);
                /*
                 arminw:
                 think we should return the real class
                 */
                // return handler.getIdentity().getObjectsTopLevelClass();
                return handler.getIdentity().getObjectsRealClass();
            }
            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);
            }
        }
        else if(isVirtualOjbProxy(objectOrProxy))
        {
            handler = VirtualProxy.getIndirectionHandler((VirtualProxy) objectOrProxy);
            /*
             arminw:
             think we should return the real class
             */
            // return handler.getIdentity().getObjectsTopLevelClass();
            return handler.getIdentity().getObjectsRealClass();
        }
        else
        {
            return objectOrProxy.getClass();
        }
    }
50720
public static Serializable copy(Serializable obj) {
        try {
            ByteArrayOutputStream buf = new ByteArrayOutputStream(4096);
            ObjectOutputStream out = new ObjectOutputStream(buf);
            out.writeObject(obj);
            out.close();

            ByteArrayInputStream buf2 = new ByteArrayInputStream(buf.toByteArray());
            ObjectInputStream in = new ObjectInputStream(buf2);
            Serializable            obj2 = (Serializable) in.readObject();
            in.close();

            return obj2;
        } catch (IOException e) {
            throw new RuntimeException(e);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
    }
637660
def _get_meta(obj):
        """"""
        if hasattr(obj, 'meta'):  # Spectrum or model
            meta = deepcopy(obj.meta)
        elif isinstance(obj, dict):  # Metadata
            meta = deepcopy(obj)
        else:  # Number
            meta = {}
        return meta
1030873
private ModelDescription getDescriptionFromObject(EDBObject obj) {
        String modelName = obj.getString(EDBConstants.MODEL_TYPE);
        String modelVersion = obj.getString(EDBConstants.MODEL_TYPE_VERSION);
        if (modelName == null || modelVersion == null) {
            throw new IllegalArgumentException("The object " + obj.getOID() + " contains no model information");
        }
        return new ModelDescription(modelName, modelVersion);
    }
1011390
public static Class<?> getUnproxyType(Object object) {
        Class<?> type = null;
        if (isClass(object)) {
            type = (Class<?>) object;
        } else if (object != null) {
            type = object.getClass();
        }
        return type == null ? null : getOriginalUnmockedType(type);
    }
475869
protected final Object getProperty(final Object obj, final String property) {
        if ((obj == null) || (property == null) || (property.trim().length() == 0)) {
            return null;
        }
        final String[] getterNames = createGetterNames(property);
        for (int i = 0; i < getterNames.length; i++) {
            final String getter = getterNames[i];
            try {
                final Class cl = obj.getClass();
                final Method m = cl.getMethod(getter, new Class[] {});
                return m.invoke(obj, new Object[] {});
            } catch (final IllegalAccessException e) {
                throw new RuntimeException("Accessing " + getter + " method of property '" + property + "' failed (private? protected?)! ["
                        + obj.getClass() + "]", e);
            } catch (final InvocationTargetException e) {
                throw new RuntimeException(
                        "Exception within " + getter + " method of property '" + property + "'! [" + obj.getClass() + "]", e.getCause());
            } catch (final NoSuchMethodException e) {
                if (i == getter.length() - 1) {
                    throw new RuntimeException("No " + getter + " method found for property! '" + property + "'! [" + obj.getClass() + "]",
                            e);
                }
            }
        }
        throw new IllegalStateException("No getters defined in 'createGetterNames()'!");
    }
57160
public static final Class<?> getComponentType(Object object) {
        Class<?> result = object.getClass().getComponentType();
        while (result.isArray()) {
            result = result.getComponentType();
        }
        return result;
    }
89250
@SuppressWarnings("unchecked")
    public BeanDesc getBeanDesc(Object obj){
        if(obj instanceof Map){
            return new MapBeanDescImpl((Map<String, Object>) obj);
        } else {
            return getBeanDesc(obj.getClass());
        }
    }
824887
public static List<String> getMethodNames(Object obj) {
		List<String> methods = new ArrayList<String>();

		Class<?> objClass = obj.getClass();

		for (Method method : objClass.getMethods()) {
			if (matchMethod(method, method.getName())) {
				methods.add(method.getName());
			}
		}

		return methods;
	}
657103
protected ClassDescriptor getClassDescriptor()
    {
        ClassDescriptor cld = (ClassDescriptor) m_classDescriptor.get();
        if(cld == null)
        {
            throw new OJBRuntimeException("Requested ClassDescriptor instance was already GC by JVM");
        }
        return cld;
    }
1049349
public static String simpleTypeName(Object obj) {
        if (obj == null) {
            return "null";
        }

        return simpleTypeName(obj.getClass(), false);
    }
297400
Object getInstanceOfClass(Class cls) {
		if (Boolean.class.isAssignableFrom(cls) || Boolean.TYPE.isAssignableFrom(cls)) {
			return Boolean.FALSE;
		} else if (Integer.TYPE.isAssignableFrom(cls) || Short.TYPE.isAssignableFrom(cls) || Integer.class.isAssignableFrom(cls) || Short.class.isAssignableFrom(cls)) {
			return 0;
		} else if (Long.TYPE.isAssignableFrom(cls) || Long.class.isAssignableFrom(cls)) {
			return 0L;
		} else if (Float.TYPE.isAssignableFrom(cls) || Float.class.isAssignableFrom(cls)) {
			return 0.1F;
		} else if (Double.TYPE.isAssignableFrom(cls) || Double.class.isAssignableFrom(cls)) {
			return 0.1D;
		} else if (cls.isArray()) {
			Class<?> comp = cls.getComponentType();
			Object instance = getInstanceOfClass(comp);
			return new Object[]{instance, instance};
		} else {
			try {
				return cls.newInstance();
			} catch (InstantiationException | IllegalAccessException ex) {
				return getObjectFromConstantFields(cls);
			}
		}
	}
1323172
@SuppressWarnings("unchecked")
	public static <T> Class<T> getClass(T obj) {
		return ((null == obj) ? null : (Class<T>) obj.getClass());
	}
1287493
public static ObjectNode getObj(ObjectNode obj, String fieldName) {
		return obj != null ? obj(obj.get(fieldName)) : null;
	}