/** * Validate that the given field and value are allowed in the context. * * @param param Field to evaluate * @param value Value to evaluate */ @SuppressWarnings("rawtypes") public static void validateField(Param param, Object value) { // Any null value is fine for fields we know about if (value == null) { return; } // Make sure the type is what we expect it to be Class acceptingClass = ACCEPTING_FIELDS.get(param); if (!acceptingClass.isInstance(value)) { String message = String.format( "%s expects type %s but found %s", param.getName(), acceptingClass.getName(), value.getClass().getName() ); throw new IllegalArgumentException(message); } }