方法拦截获取属性名称

时间:2015-05-21 18:29:29

标签: java reflection proxy-classes method-invocation method-interception

我正在寻找一个实用程序类或库,以类型安全的方式为我提供属性的名称。我有类似以下类似的东西:

PropertyDescriptor descriptor = property(on(Foo.class).getBar());

assertThat(descriptor.getName()).isEqualTo("bar")

要正确实施这样的便利方法,需要IMHO安静很多工作。由于最终类等的处理可能非常复杂(参见mockito,easymock等)。

1 个答案:

答案 0 :(得分:1)

您可以将QueryDSL's aliases用作:

$('#productSubmit').click(function(e) {
  var data = new FormData($('input[name^="image"]'));     
  jQuery.each($('input[name^="image"]')[0].files, function(i, file) {
    data.append(i, file);
  });
  console.log(data);
  $.ajax({
    type: "POST",
    url: "http://test-app.appspot.com/items/data.id/images",
    //enctype: 'multipart/form-data',
    mimeType: 'multipart/form-data',
    contentType: false,
    processData: false,
    data: data,
    success: function (data) {
      alert("Data Uploaded: ");
      $('#product_data').submit();
    },
    error: function(jqXhr, textStatus, errorThrown) {
      alert(11);
      console.log( errorThrown );
    }
  });   
});
相关问题