/** * {@inheritDoc} */ public Object invoke(Object proxy, Method method, Object[] argument) { if (method.getDeclaringClass() != annotationType) { if (method.getName().equals(HASH_CODE)) { return hashCodeRepresentation(); } else if (method.getName().equals(EQUALS) && method.getParameterTypes().length == 1) { return equalsRepresentation(proxy, argument[0]); } else if (method.getName().equals(TO_STRING)) { return toStringRepresentation(); } else /* if (method.getName().equals("annotationType")) */ { return annotationType; } } Object value = values.get(method).resolve(); if (!asWrapper(method.getReturnType()).isAssignableFrom(value.getClass())) { throw new AnnotationTypeMismatchException(method, value.getClass().toString()); } return value; }
/** * Validates contained value against its member definition * and if ok returns the value. * Otherwise, if the value type mismatches definition * or the value itself describes an error, * throws appropriate exception. * <br> Note, this method may return null if this element was constructed * with such value. * * @see #rethrowError() * @see #copyValue() * @return actual valid value or null if no value */ public Object validateValue() throws Throwable { if (tag == ERROR) { rethrowError(); } if (value == NO_VALUE) { return null; } if (elementType == value.getClass() || elementType.isInstance(value)) { // nested annotation value return copyValue(); } else { throw new AnnotationTypeMismatchException(definingMethod, value.getClass().getName()); } }
} else if (value instanceof AnnotationTypeMismatchException) { AnnotationTypeMismatchException e = (AnnotationTypeMismatchException) value; throw new AnnotationTypeMismatchException(e.element(), e.foundType()); } else if (value instanceof ArrayStoreException) { ArrayStoreException e = (ArrayStoreException) value;
protected RuntimeException generateException() { return new AnnotationTypeMismatchException(method, attr.type.toString()); } };
protected RuntimeException generateException() { return new AnnotationTypeMismatchException(method, attr.type.toString()); } };
/** * Validates contained value against its member definition * and if ok returns the value. * Otherwise, if the value type mismatches definition * or the value itself describes an error, * throws appropriate exception. * <br> Note, this method may return null if this element was constructed * with such value. * * @see #rethrowError() * @see #copyValue() * @return actual valid value or null if no value */ public Object validateValue() throws Throwable { if (tag == ERROR) { rethrowError(); } if (value == NO_VALUE) { return null; } if (elementType == value.getClass() || elementType.isInstance(value)) { // nested annotation value return copyValue(); } else { throw new AnnotationTypeMismatchException(definingMethod, value.getClass().getName()); } }
@Override public Object invoke(Object proxy, Method method, Object[] argument) { if (method.getDeclaringClass() != annotationType) { if (method.getName().equals(HASH_CODE)) { return hashCodeRepresentation(); } else if (method.getName().equals(EQUALS) && method.getParameterTypes().length == 1) { return equalsRepresentation(proxy, argument[0]); } else if (method.getName().equals(TO_STRING)) { return toStringRepresentation(); } else /* if (method.getName().equals("annotationType")) */ { return annotationType; } } Object value = values.get(method).resolve(); if (!asWrapper(method.getReturnType()).isAssignableFrom(value.getClass())) { throw new AnnotationTypeMismatchException(method, value.getClass().toString()); } return value; }
/** * Validates contained value against its member definition * and if ok returns the value. * Otherwise, if the value type mismatches definition * or the value itself describes an error, * throws appropriate exception. * <br> Note, this method may return null if this element was constructed * with such value. * * @see #rethrowError() * @see #copyValue() * @return actual valid value or null if no value * @throws Throwable wrapper throwable */ public Object validateValue() throws Throwable { if (tag == ERROR) { rethrowError(); } if (value == NO_VALUE) { return null; } if (elementType == value.getClass() || elementType.isInstance(value)) { // nested annotation value return copyValue(); } else { throw new AnnotationTypeMismatchException(definingMethod, value.getClass().getName()); } }
@Override public Object invoke(Object proxy, Method method, Object[] arguments) { if (method.getDeclaringClass() != annotationType) { if (method.getName().equals(HASH_CODE)) { return hashCodeRepresentation(); } else if (method.getName().equals(EQUALS) && method.getParameterTypes().length == 1) { return equalsRepresentation(proxy, arguments[0]); } else if (method.getName().equals(TO_STRING)) { return toStringRepresentation(); } else /* method.getName().equals("annotationType") */ { return annotationType; } } Object value = values.get(method).resolve(); if (!asWrapper(method.getReturnType()).isAssignableFrom(value.getClass())) { throw new AnnotationTypeMismatchException(method, value.getClass().toString()); } return value; }
/** * Validates contained value against its member definition * and if ok returns the value. * Otherwise, if the value type mismatches definition * or the value itself describes an error, * throws appropriate exception. * <br> Note, this method may return null if this element was constructed * with such value. * * @see #rethrowError() * @see #copyValue() * @return actual valid value or null if no value */ public Object validateValue() throws Throwable { if (tag == ERROR) { rethrowError(); } if (value == NO_VALUE) { return null; } if (elementType == value.getClass() || elementType.isInstance(value)) { // nested annotation value return copyValue(); } else { throw new AnnotationTypeMismatchException(definingMethod, value.getClass().getName()); } }
/** * Validates contained value against its member definition * and if ok returns the value. * Otherwise, if the value type mismatches definition * or the value itself describes an error, * throws appropriate exception. * <br> Note, this method may return null if this element was constructed * with such value. * * @see #rethrowError() * @see #copyValue() * @return actual valid value or null if no value */ public Object validateValue() throws Throwable { if (tag == ERROR) { rethrowError(); } if (value == NO_VALUE) { return null; } if (elementType == value.getClass() || elementType.isInstance(value)) { // nested annotation value return copyValue(); } else { throw new AnnotationTypeMismatchException(definingMethod, value.getClass().getName()); } }
/** * Validates contained value against its member definition * and if ok returns the value. * Otherwise, if the value type mismatches definition * or the value itself describes an error, * throws appropriate exception. * <br> Note, this method may return null if this element was constructed * with such value. * * @see #rethrowError() * @see #copyValue() * @return actual valid value or null if no value */ public Object validateValue() throws Throwable { if (tag == ERROR) { rethrowError(); } if (value == NO_VALUE) { return null; } if (elementType == value.getClass() || elementType.isInstance(value)) { // nested annotation value return copyValue(); } else { throw new AnnotationTypeMismatchException(definingMethod, value.getClass().getName()); } }
/** * Validates contained value against its member definition * and if ok returns the value. * Otherwise, if the value type mismatches definition * or the value itself describes an error, * throws appropriate exception. * <br> Note, this method may return null if this element was constructed * with such value. * * @see #rethrowError() * @see #copyValue() * @return actual valid value or null if no value */ public Object validateValue() throws Throwable { if (tag == ERROR) { rethrowError(); } if (value == NO_VALUE) { return null; } if (elementType == value.getClass() || elementType.isInstance(value)) { // nested annotation value return copyValue(); } else { throw new AnnotationTypeMismatchException(definingMethod, value.getClass().getName()); } }
/** * Validates contained value against its member definition * and if ok returns the value. * Otherwise, if the value type mismatches definition * or the value itself describes an error, * throws appropriate exception. * <br> Note, this method may return null if this element was constructed * with such value. * * @see #rethrowError() * @see #copyValue() * @return actual valid value or null if no value */ public Object validateValue() throws Throwable { if (tag == ERROR) { rethrowError(); } if (value == NO_VALUE) { return null; } if (elementType == value.getClass() || elementType.isInstance(value)) { // nested annotation value return copyValue(); } else { throw new AnnotationTypeMismatchException(definingMethod, value.getClass().getName()); } }
@Override public void validate() { if (entityClass == null) { throw new IllegalArgumentException("testentity class cannot be null"); } if (!entityClass.isAnnotationPresent(DeepEntity.class)) { throw new AnnotationTypeMismatchException(null, entityClass.getCanonicalName()); } super.validate(); /* let's validate fieldNames in @DeepField annotations */ Field[] deepFields = AnnotationUtils.filterDeepFields(entityClass); Map<String, Cell> colDefs = super.columnDefinitions(); /* colDefs is null if table does not exist. I.E. this configuration will be used as an output configuration object, and the output table is dynamically created */ if (colDefs == null) { return; } for (Field field : deepFields) { String annotationFieldName = AnnotationUtils.deepFieldName(field); if (!colDefs.containsKey(annotationFieldName)) { throw new DeepNoSuchFieldException("Unknown column name \'" + annotationFieldName + "\' specified for" + " field " + entityClass.getCanonicalName() + "#" + field.getName() + ". Please, " + "make sure the field name you specify in @DeepField annotation matches _exactly_ the column " + "name " + "in the database"); } } }
} else if (value instanceof AnnotationTypeMismatchException) { AnnotationTypeMismatchException e = (AnnotationTypeMismatchException) value; throw new AnnotationTypeMismatchException(e.element(), e.foundType()); } else if (value instanceof ArrayStoreException) { ArrayStoreException e = (ArrayStoreException) value;
} else if (value instanceof AnnotationTypeMismatchException) { AnnotationTypeMismatchException e = (AnnotationTypeMismatchException) value; throw new AnnotationTypeMismatchException(e.element(), e.foundType()); } else if (value instanceof ArrayStoreException) { ArrayStoreException e = (ArrayStoreException) value;
} else if (value instanceof AnnotationTypeMismatchException) { AnnotationTypeMismatchException e = (AnnotationTypeMismatchException) value; throw new AnnotationTypeMismatchException(e.element(), e.foundType()); } else if (value instanceof ArrayStoreException) { ArrayStoreException e = (ArrayStoreException) value;
} else if (value instanceof AnnotationTypeMismatchException) { AnnotationTypeMismatchException e = (AnnotationTypeMismatchException) value; throw new AnnotationTypeMismatchException(e.element(), e.foundType()); } else if (value instanceof ArrayStoreException) { ArrayStoreException e = (ArrayStoreException) value;
} else if (value instanceof AnnotationTypeMismatchException) { AnnotationTypeMismatchException e = (AnnotationTypeMismatchException) value; throw new AnnotationTypeMismatchException(e.element(), e.foundType()); } else if (value instanceof ArrayStoreException) { ArrayStoreException e = (ArrayStoreException) value;