Package org.springframework.core.convert

Examples of org.springframework.core.convert.TypeDescriptor


        }

        String[] parameterValue = rawParameters.get(parameterName);
        Object value = parameterValue == null ? null : parameterValue.length == 1 ? parameterValue[0] : parameterValue;

        result[i] = conversionService.convert(value, TypeDescriptor.forObject(value), new TypeDescriptor(param));
      }
    }

    return result;
  }
View Full Code Here


      Method method = invocation.getMethod();

      // Looking up the TypeDescriptor for the return type - yes, this way o.O
      MethodParameter parameter = new MethodParameter(method, -1);
      TypeDescriptor methodReturnTypeDescriptor = TypeDescriptor.nested(parameter, 0);

      Class<?> expectedReturnType = method.getReturnType();

      if (result != null && expectedReturnType.isInstance(result)) {
        return result;
View Full Code Here

    }

    @Override
    public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
        try {
            TypeDescriptor generic = getGenericType(getResolvableType(targetType));
            return this.conversionService.canConvert(sourceType, generic);
        } catch (Exception e) {
            e.printStackTrace()//TODO: implement catch
        }
        return false;
View Full Code Here

        if (source == null) {
            return null;
        }
        try {
            ResolvableType tgtResolvableType = getResolvableType(targetType);
            TypeDescriptor typeDescriptor = getGenericType(tgtResolvableType);
            //TODO: discover propName
            String propName = "hello.defaultMessage";
            //TODO: discover defaultValue
            Object defaultValue = conversionService.convert(source, sourceType, typeDescriptor);
            return new DynamicProp(propName, defaultValue);
View Full Code Here

    protected String convertToString(final Configuration configuration, final IProcessingContext processingContext, final Object object) {

        if (object == null) {
            return null;
        }
        final TypeDescriptor objectTypeDescriptor = TypeDescriptor.forObject(object);
        final TypeConverter typeConverter = getSpringConversionService(processingContext);
        if (typeConverter == null || !typeConverter.canConvert(objectTypeDescriptor, TYPE_STRING)) {
            return super.convertToString(configuration, processingContext, object);
        }
        return (String) typeConverter.convertValue(object, objectTypeDescriptor, TYPE_STRING);
View Full Code Here

    protected <T> T convertOther(final Configuration configuration, final IProcessingContext processingContext, final Object object, final Class<T> targetClass) {

        if (object == null) {
            return null;
        }
        final TypeDescriptor objectTypeDescriptor = TypeDescriptor.forObject(object);
        final TypeDescriptor targetTypeDescriptor = TypeDescriptor.valueOf(targetClass);
        final TypeConverter typeConverter = getSpringConversionService(processingContext);
        if (typeConverter == null || !typeConverter.canConvert(objectTypeDescriptor, targetTypeDescriptor)) {
            return super.convertOther(configuration, processingContext, object, targetClass);
        }
        return (T) typeConverter.convertValue(object, objectTypeDescriptor, targetTypeDescriptor);
View Full Code Here

    protected String convertToString(final Configuration configuration, final IProcessingContext processingContext, final Object object) {

        if (object == null) {
            return null;
        }
        final TypeDescriptor objectTypeDescriptor = TypeDescriptor.forObject(object);
        final TypeConverter typeConverter = getSpringConversionService(processingContext);
        if (typeConverter == null || !typeConverter.canConvert(objectTypeDescriptor, TYPE_STRING)) {
            return super.convertToString(configuration, processingContext, object);
        }
        return (String) typeConverter.convertValue(object, objectTypeDescriptor, TYPE_STRING);
View Full Code Here

    protected <T> T convertOther(final Configuration configuration, final IProcessingContext processingContext, final Object object, final Class<T> targetClass) {

        if (object == null) {
            return null;
        }
        final TypeDescriptor objectTypeDescriptor = TypeDescriptor.forObject(object);
        final TypeDescriptor targetTypeDescriptor = TypeDescriptor.valueOf(targetClass);
        final TypeConverter typeConverter = getSpringConversionService(processingContext);
        if (typeConverter == null || !typeConverter.canConvert(objectTypeDescriptor, targetTypeDescriptor)) {
            return super.convertOther(configuration, processingContext, object, targetClass);
        }
        return (T) typeConverter.convertValue(object, objectTypeDescriptor, targetTypeDescriptor);
View Full Code Here

      for (int i = 0; i < parameterTypes.length; i++) {
        if (i != 0) {
          sb.append(", ");
        }
        MethodParameter methodParameter = new MethodParameter(method, i);
        TypeDescriptor parameterTypeDescriptor = new TypeDescriptor(methodParameter);
        Class<?> parameterType = parameterTypeDescriptor.getObjectType();
        Annotation mappingAnnotation = findMappingAnnotation(parameterAnnotations[i]);
        if (mappingAnnotation != null) {
          Class<? extends Annotation> annotationType = mappingAnnotation.annotationType();

          if (annotationType.equals(YarnEnvironments.class)) {
View Full Code Here

    TypedValue result = readProperty(contextObject, eContext, this.name);

    // Dynamically create the objects if the user has requested that optional behavior
    if (result.getValue() == null && isAutoGrowNullReferences &&
        nextChildIs(Indexer.class, PropertyOrFieldReference.class)) {
      TypeDescriptor resultDescriptor = result.getTypeDescriptor();
      // Creating lists and maps
      if ((resultDescriptor.getType().equals(List.class) || resultDescriptor.getType().equals(Map.class))) {
        // Create a new collection or map ready for the indexer
        if (resultDescriptor.getType().equals(List.class)) {
          try {
            if (isWritableProperty(this.name,contextObject,eContext)) {
              List<?> newList = ArrayList.class.newInstance();
              writeProperty(contextObject, eContext, this.name, newList);
              result = readProperty(contextObject, eContext, this.name);
View Full Code Here

TOP

Related Classes of org.springframework.core.convert.TypeDescriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.