Package com.codiform.moo

Examples of com.codiform.moo.TranslationException


      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


  }

  protected void checkValue(Object value) {
    if (value == null) {
      if (!canSupportNull()) {
        throw new TranslationException(
            "Cannot store null in primitive field " + getName()
                + " (" + getType().getSimpleName() + ")");
      }
    } else if (getType().isPrimitive()) {
      if (!PrimitiveAssignment.isCompatible(getType(), value.getClass())) {
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

    try {
      Constructor<T> constructor = destinationClass.getDeclaredConstructor();
      constructor.setAccessible( true );
      return constructor.newInstance();
    } catch( NoSuchMethodException exception ) {
      throw new TranslationException(
          "No no-argument constructor in class "
              + destinationClass.getName(), exception );
    } 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 );
    } catch( IllegalArgumentException exception ) {
      throw new TranslationException( String.format(
          "Error while instantiating %s", destinationClass ),
          exception );
    } catch( InvocationTargetException exception ) {
      throw new TranslationException( String.format(
          "Error thrown by constructor of %s", destinationClass ),
          exception );
    }
  }
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

  }

  protected void checkValue(Object value) {
    if (value == null) {
      if (!canSupportNull()) {
        throw new TranslationException(
            "Cannot store null in primitive field " + getName()
                + " (" + getType().getSimpleName() + ")");
      }
    } else if (getType().isPrimitive()) {
      if (!PrimitiveAssignment.isCompatible(getType(), value.getClass())) {
View Full Code Here

  public void setValue(Object instance, Object value) {
    checkValue( value );
    try {
      setter.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

    } else {
      try {
        getter.setAccessible( true );
        return getter.invoke( instance );
      } catch( IllegalArgumentException exception ) {
        throw new TranslationException( "Illegal argument to getter", exception );
      } catch( IllegalAccessException exception ) {
        throw new TranslationException( "Cannot access getter", exception );
      } catch( InvocationTargetException exception ) {
        throw new TranslationException( "Error while invoking getter", exception );
      }
    }
  }
View Full Code Here

  public void setValue(Object instance, Object value) {
    checkValue( value );
    try {
      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.