Method to convert an object to its type
For example when ArrayOfManagedObject is passed in
return a ManagedObject[]

@param dynaPropVal
@return
14429
public static Object convertProperty(Object dynaPropVal) {
        Object propertyValue = null;
        if (dynaPropVal == null) {
            throw new IllegalArgumentException("Unable to convertProperty on null object.");
        }
        Class<?> propClass = dynaPropVal.getClass();
        String propName = propClass.getName();
        //Check the dynamic propery for ArrayOfXXX object
        if (propName.contains("ArrayOf")) {
            String methodName = propName.substring(propName.indexOf("ArrayOf") + "ArrayOf".length());
            // If object is ArrayOfXXX object, then get the XXX[] by invoking getXXX() on the object. For Ex:
            // ArrayOfManagedObjectReference.getManagedObjectReference() returns ManagedObjectReference[] array.
            try {
                Method getMethod;
                try {
                    getMethod = propClass.getMethod("get" + methodName, (Class[]) null);
                }
                catch (NoSuchMethodException ignore) {
                    getMethod = propClass.getMethod("get_" + methodName.toLowerCase(), (Class[]) null);
                }
                propertyValue = getMethod.invoke(dynaPropVal, (Object[]) null);
            }
            catch (Exception e) {
                log.error("Exception caught trying to convertProperty", e);
            }
        }
        //Handle the case of an unwrapped array being deserialized.
        else if (dynaPropVal.getClass().isArray()) {
            propertyValue = dynaPropVal;
        }
        else {
            propertyValue = dynaPropVal;
        }

        return propertyValue;
    }
1136435
def _ConvertManagedType(self, managedType):
      
      if managedType:
         vmodlName = managedType.name
         wsdlName = managedType.wsdlName
         version = managedType.version
         parent = managedType.base[0]
         props = self._Filter(self._ConvertManagedPropertyType, managedType.property)
         methods = self._Filter(self._ConvertMethodType, managedType.method)
         moType = (vmodlName, wsdlName, parent, version, props, methods)
      else:
         moType = None
      return moType
75179
public function getBasicValueForArrayProperty(PropertyDefinition $propertyDefinition, $rawValue)
	{
		if (!$propertyDefinition->getIsArray() || !is_array($rawValue)) {
			return [];
		}

		$values = [];

		foreach ($rawValue as $rawValueItem) {

			if ($propertyDefinition->getType() == PropertyDefinition::BASIC_TYPE_INTEGER) {
				if (is_numeric($rawValueItem) || is_bool($rawValueItem) || is_string($rawValueItem)) {
					$values[] = intval($rawValueItem);
				}

			} else if ($propertyDefinition->getType() == PropertyDefinition::BASIC_TYPE_FLOAT) {
				if (is_numeric($rawValueItem) || is_bool($rawValueItem) || is_string($rawValueItem)) {
					$values[] = floatval($rawValueItem);
				}
			} else if ($propertyDefinition->getType() == PropertyDefinition::BASIC_TYPE_STRING) {
				if (!is_array($rawValueItem) && !is_object($rawValueItem)) {
					$values[] = strval($rawValueItem);
				}
			} else if ($propertyDefinition->getType() == PropertyDefinition::BASIC_TYPE_BOOLEAN) {
				if (!is_array($rawValueItem) && !is_object($rawValueItem)) {
					$values[] = boolval($rawValueItem);
				}
			} else {
				// skip this value
			}
		}

		return $values;
	}
1020766
public static <T> T convert(Type type, Object value, T defaultValue) throws ConvertException {
		return ConverterRegistry.getInstance().convert(type, value, defaultValue);
	}
132984
function baseIsTypedArray(value) {
    return isObjectLike(value) &&
      isLength(value.length) && !!typedArrayTags[objectToString.call(value)];
  }
1288031
private Object convertListToArray(List<?> rawValues, ExtendedAttributeDefinition attrDef, EvaluationContext context, boolean ignoreWarnings) throws ConfigEvaluatorException {
        // The implementation of this method is similar to convertListToVector,
        // but this method needs to handle primitive array types.  This could
        // be implemented by calling convertListToVector first, but that would
        // require boxing/unboxing the primitive values.  To avoid that, the
        // logic from the convertListToVector and convertObjectToSingleValue
        // methods is inlined for the primitive array types.

        int size = rawValues.size();
        int type = attrDef.getType();
        int i = 0;
        if (type == AttributeDefinition.BOOLEAN) {
            boolean[] retVal = new boolean[size];
            for (Object rawValue : rawValues) {
                String value = resolveStringValue(rawValue, attrDef, context, ignoreWarnings);
                retVal[i++] = Boolean.parseBoolean(value);
            }
            return retVal;
        } else if (type == AttributeDefinition.BYTE) {
            byte[] retVal = new byte[size];
            for (Object rawValue : rawValues) {
                String value = resolveStringValue(rawValue, attrDef, context, ignoreWarnings);
                retVal[i++] = Byte.parseByte(value);
            }
            return retVal;
        } else if (type == AttributeDefinition.CHARACTER) {
            char[] retVal = new char[size];
            for (Object rawValue : rawValues) {
                String value = resolveStringValue(rawValue, attrDef, context, ignoreWarnings);
                retVal[i++] = value.charAt(0);
            }
            return retVal;
        } else if (type == AttributeDefinition.DOUBLE) {
            double[] retVal = new double[size];
            for (Object rawValue : rawValues) {
                String value = resolveStringValue(rawValue, attrDef, context, ignoreWarnings);
                retVal[i++] = Double.parseDouble(value);
            }
            return retVal;
        } else if (type == AttributeDefinition.FLOAT) {
            float[] retVal = new float[size];
            for (Object rawValue : rawValues) {
                String value = resolveStringValue(rawValue, attrDef, context, ignoreWarnings);
                retVal[i++] = Float.parseFloat(value);
            }
            return retVal;
        } else if (type == AttributeDefinition.INTEGER) {
            int[] retVal = new int[size];
            for (Object rawValue : rawValues) {
                String value = resolveStringValue(rawValue, attrDef, context, ignoreWarnings);
                retVal[i++] = Integer.parseInt(value);
            }
            return retVal;
        } else if (type == AttributeDefinition.LONG) {
            long[] retVal = new long[size];
            for (Object rawValue : rawValues) {
                String value = resolveStringValue(rawValue, attrDef, context, ignoreWarnings);
                retVal[i++] = Long.parseLong(value);
            }
            return retVal;
        } else if (type == AttributeDefinition.SHORT) {
            short[] retVal = new short[size];
            for (Object rawValue : rawValues) {
                String value = resolveStringValue(rawValue, attrDef, context, ignoreWarnings);
                retVal[i++] = Short.parseShort(value);
            }
            return retVal;
        } else if (type == MetaTypeFactory.DURATION_TYPE) {
            return convertListToDurationArray(rawValues, attrDef, context, TimeUnit.MILLISECONDS, ignoreWarnings);
        } else if (type == MetaTypeFactory.DURATION_S_TYPE) {
            return convertListToDurationArray(rawValues, attrDef, context, TimeUnit.SECONDS, ignoreWarnings);
        } else if (type == MetaTypeFactory.DURATION_M_TYPE) {
            return convertListToDurationArray(rawValues, attrDef, context, TimeUnit.MINUTES, ignoreWarnings);
        } else if (type == MetaTypeFactory.DURATION_H_TYPE) {
            return convertListToDurationArray(rawValues, attrDef, context, TimeUnit.HOURS, ignoreWarnings);
        } else {
            // STRING, PID_TYPE, TOKEN_TYPE, and all other unknown/invalid types.
            return convertListToStringArray(rawValues, attrDef, context, ignoreWarnings);
        }
    }
1098284
private Map<String, TypeName> convertPropertiesToTypes(Map<String, ExecutableElement> properties) {
    Map<String, TypeName> types = new LinkedHashMap<>();
    for (Map.Entry<String, ExecutableElement> entry : properties.entrySet()) {
      ExecutableElement el = entry.getValue();
      types.put(entry.getKey(), TypeName.get(el.getReturnType()));
    }
    return types;
  }
1222715
def _ConvertManagedPropertyType(self, propType):
      
      if propType:
         name = propType.name
         version = propType.version
         aType = propType.type
         flags = self._ConvertAnnotations(propType.annotation)
         privId = propType.privId
         prop = (name, aType, version, flags, privId)
      else:
         prop = None
      return prop
779972
public static JavaConstant ofArrayVarHandle(TypeDescription typeDescription) {
            if (!typeDescription.isArray()) {
                throw new IllegalArgumentException("Not an array type: " + typeDescription);
            }
            return new Dynamic(new ConstantDynamic("arrayVarHandle",
                    JavaType.VAR_HANDLE.getTypeStub().getDescriptor(),
                    new Handle(Opcodes.H_INVOKESTATIC,
                            CONSTANT_BOOTSTRAPS,
                            "arrayVarHandle",
                            "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;Ljava/lang/Class;)Ljava/lang/invoke/VarHandle;",
                            false),
                    Type.getType(typeDescription.getDescriptor())), JavaType.VAR_HANDLE.getTypeStub());
        }
1366051
public static <T> T recoveredValue(Class<T> type, String properties) throws ExecutionException {
        return recoveredValueASArray(type, properties)[0];
    }
32296
private ProcessExtensionModel convertJsonVariables(ProcessExtensionModel processExtensionModel){
        if( processExtensionModel!=null && processExtensionModel.getExtensions()!=null
                && processExtensionModel.getExtensions().getProperties()!=null ){

            for(VariableDefinition variableDefinition:processExtensionModel.getExtensions().getProperties().values()){
                if(!variableTypeMap.keySet().contains(variableDefinition.getType())||variableDefinition.getType().equals("json")){
                    variableDefinition.setValue(objectMapper.convertValue(variableDefinition.getValue(), JsonNode.class));
                }
            }
        }
        return processExtensionModel;
    }
1350607
@SuppressWarnings("unchecked")
    static <T> Collection<T> asCollection(Object value, PDescriptor itemType) throws ProvidenceConfigException {
        if (value instanceof Collection) {
            Collection<T> out = new ArrayList<>();
            for (Object item : (Collection) value) {
                out.add((T) asType(itemType, item));
            }
            return out;
        }
        throw new ProvidenceConfigException(
                "Unable to convert " + value.getClass().getSimpleName() + " to a collection");
    }
394248
@SuppressWarnings("unchecked")
    private <T> List<T> getListValue(Class<T> type, String propertyName, EDBObject object) {
        List<T> temp = new ArrayList<>();
        for (int i = 0;; i++) {
            String property = getEntryNameForList(propertyName, i);
            Object obj = object.getObject(property);
            if (obj == null) {
                break;
            }
            if (OpenEngSBModel.class.isAssignableFrom(type)) {
                obj = convertEDBObjectToUncheckedModel(type, edbService.getObject(object.getString(property)));
            }
            temp.add((T) obj);
            object.remove(property);
        }
        return temp;
    }
426055
function arrayToObject(arrayOfObjects) {
    var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'id';

    var convertedObject = {};

    arrayOfObjects.forEach(function (object) {
      convertedObject[object[key]] = object;
    });

    return convertedObject;
  }
1117223
function(packedValue)
    {

        var result;

        var t = typeof(packedValue);
        if (t == "number" || t == "string" || t == "boolean" || packedValue == null || packedValue == undefined)
        {
            result = this.handleError(packedValue);
        }
        else if (packedValue instanceof Array)
        {
            result = [];
            for (var i = 0; i < packedValue.length; i++)
            {
                result[i] = this.deserialize(packedValue[i]);
            }
        }
        else if (t == "object")
        {
            for(var i = 0; i < packedValue.newTypes.length; i++)
            {
                this.addTypeDataToCache(packedValue.newTypes[i]);
            }
            for (var aRefID in packedValue.newRefs)
            {
                this.createProxy(aRefID, packedValue.newRefs[aRefID]);
            }
            if (packedValue.type == FABridge.TYPE_PRIMITIVE)
            {
                result = packedValue.value;
            }
            else if (packedValue.type == FABridge.TYPE_ASFUNCTION)
            {
                result = this.getFunctionProxy(packedValue.value);
            }
            else if (packedValue.type == FABridge.TYPE_ASINSTANCE)
            {
                result = this.getProxy(packedValue.value);
            }
            else if (packedValue.type == FABridge.TYPE_ANONYMOUS)
            {
                result = packedValue.value;
            }
        }
        return result;
    }
924592
public Object[] jcrValues( Property<?> property ) {
        @SuppressWarnings( "unchecked" )
        List<Object> values = (List<Object>)property.getValues();

        // convert CMIS values to JCR values
        switch (property.getType()) {
            case STRING:
                return asStrings(values);
            case BOOLEAN:
                return asBooleans(values);
            case DECIMAL:
                return asDecimals(values);
            case INTEGER:
                return asIntegers(values);
            case DATETIME:
                return asDateTime(values);
            case URI:
                return asURI(values);
            case ID:
                return asIDs(values);
            case HTML:
                return asHTMLs(values);
            default:
                return null;
        }
    }
29150
public static Type[] hsqlTypeFromVoltType(VoltType[] voltParameterTypes) {
        Type[] answer = new Type[voltParameterTypes.length];
        for (int idx = 0; idx < voltParameterTypes.length; idx++) {
            answer[idx] = hsqlTypeFromVoltType(voltParameterTypes[idx]);
        }
        return answer;
    }