Package com.codiform.moo

Examples of com.codiform.moo.TranslationException


      } else {
        return configuration.getArrayTranslator().translate(value, fieldType
            .getComponentType(), translationSource);
      }
    } else {
      throw new TranslationException(String.format(
          "Cannot translate from source array type %s[] to destination type %s",
          valueType.getComponentType(), fieldType.getName()));
    }
  }
View Full Code Here


  private Object transformCollection(Object value, Field item,
      TranslationSource translationSource,
      com.codiform.moo.annotation.Translate annotation) {
    if (annotation != null) {
      throw new TranslationException(
          "Cannot use @Translate on a collection (cannot determine internal type due to erasure); use @TranslateCollection instead.");
    } else {
      return configuration.getCollectionTranslator().translate(value, item
          .getAnnotation(TranslateCollection.class),
          translationSource);
View Full Code Here

  private void setValue(T destination, Field field, Object value) {
    try {
      field.setAccessible(true);
      field.set(destination, value);
    } catch (IllegalArgumentException exception) {
      throw new TranslationException(String.format(
          "Could not set field: %s", field.getName()), exception);
    } catch (IllegalAccessException exception) {
      throw new TranslationException(String.format(
          "Could not set field: %s", field.getName()), exception);
    }
  }
View Full Code Here

      Object value = getValue(source, expression);
      value = transform(value, item, translationSource);
      setValue(destination, item, value);
    } catch (PropertyAccessException exception) {
      if( configuration.isSourcePropertyRequired()) {
        throw new TranslationException(
            "Could not find required source property for expression: "
                + expression, exception);
      }
    }
  }
View Full Code Here

   */
  public T create() {
    try {
      return destinationClass.newInstance();
    } catch (InstantiationException exception) {
      throw new TranslationException(String.format(
          "Error while instantiating %s", destinationClass),
          exception);
    } catch (IllegalAccessException exception) {
      throw new TranslationException(String.format(
          "Not allowed to instantiate %s", destinationClass),
          exception);
    }
  }
View Full Code Here

      TranslationSource translationSource) {
    if (value == null) {
      return null;
    } else if (value instanceof Collection || value instanceof Map) {
      if (property.shouldBeTranslated()) {
        throw new TranslationException(
            "Cannot use @Translate on a collection (cannot determine internal type due to erasure); use @TranslateCollection instead.");
      }
      return transformCollection(value, property, translationSource);
    } else if (value.getClass().isArray()) {
      return transformArray((Object[]) value, property, translationSource);
View Full Code Here

      } else {
        return configuration.getArrayTranslator().translate(value,
            fieldType.getComponentType(), translationSource);
      }
    } else {
      throw new TranslationException(
          String
              .format(
                  "Cannot translate from source array type %s[] to destination type %s",
                  valueType.getComponentType(), fieldType
                      .getName()));
View Full Code Here

      value = transform(value, property, translationSource);
      property.setValue(destination, value);
      return true;
    } catch (PropertyAccessException exception) {
      if (configuration.isSourcePropertyRequired()) {
        throw new TranslationException(
            "Could not find required source property for expression: "
                + property.getTranslationExpression(),
            exception);
      }
      return false;
View Full Code Here

    try {
      if (!method.isAccessible())
        method.setAccessible(true);
      method.invoke(instance, value);
    } catch (IllegalArgumentException exception) {
      throw new TranslationException(
          "Cannot set value for field property " + getName(),
          exception);
    } catch (IllegalAccessException exception) {
      throw new TranslationException(
          "Cannot set value for field property " + getName(),
          exception);
    } catch (InvocationTargetException exception) {
      throw new TranslationException("Cannot for method property "
          + getName(), exception);
    }
  }
View Full Code Here

    try {
      if (!field.isAccessible())
        field.setAccessible(true);
      field.set(instance, value);
    } catch (IllegalArgumentException exception) {
      throw new TranslationException(
          "Cannot set value for field property " + getName(),
          exception);
    } catch (IllegalAccessException exception) {
      throw new TranslationException(
          "Cannot set value for field property " + getName(),
          exception);
    }
  }
View Full Code Here

TOP

Related Classes of com.codiform.moo.TranslationException

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.