{"action":"closed","issue":{"url":"https://api.github.com/repos/npgall/cqengine/issues/48","repository_url":"https://api.github.com/repos/npgall/cqengine","labels_url":"https://api.github.com/repos/npgall/cqengine/issues/48/labels{/name}","comments_url":"https://api.github.com/repos/npgall/cqengine/issues/48/comments","events_url":"https://api.github.com/repos/npgall/cqengine/issues/48/events","html_url":"https://github.com/npgall/cqengine/issues/48","id":123664644,"number":48,"title":"Consider adding support to use lambda functions as attributes","user":{"login":"langzhaozhi","id":10590720,"avatar_url":"https://avatars.githubusercontent.com/u/10590720?v=3","gravatar_id":"","url":"https://api.github.com/users/langzhaozhi","html_url":"https://github.com/langzhaozhi","followers_url":"https://api.github.com/users/langzhaozhi/followers","following_url":"https://api.github.com/users/langzhaozhi/following{/other_user}","gists_url":"https://api.github.com/users/langzhaozhi/gists{/gist_id}","starred_url":"https://api.github.com/users/langzhaozhi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/langzhaozhi/subscriptions","organizations_url":"https://api.github.com/users/langzhaozhi/orgs","repos_url":"https://api.github.com/users/langzhaozhi/repos","events_url":"https://api.github.com/users/langzhaozhi/events{/privacy}","received_events_url":"https://api.github.com/users/langzhaozhi/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/npgall/cqengine/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"closed","locked":false,"assignee":{"login":"npgall","id":2853258,"avatar_url":"https://avatars.githubusercontent.com/u/2853258?v=3","gravatar_id":"","url":"https://api.github.com/users/npgall","html_url":"https://github.com/npgall","followers_url":"https://api.github.com/users/npgall/followers","following_url":"https://api.github.com/users/npgall/following{/other_user}","gists_url":"https://api.github.com/users/npgall/gists{/gist_id}","starred_url":"https://api.github.com/users/npgall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/npgall/subscriptions","organizations_url":"https://api.github.com/users/npgall/orgs","repos_url":"https://api.github.com/users/npgall/repos","events_url":"https://api.github.com/users/npgall/events{/privacy}","received_events_url":"https://api.github.com/users/npgall/received_events","type":"User","site_admin":false},"assignees":[{"login":"npgall","id":2853258,"avatar_url":"https://avatars.githubusercontent.com/u/2853258?v=3","gravatar_id":"","url":"https://api.github.com/users/npgall","html_url":"https://github.com/npgall","followers_url":"https://api.github.com/users/npgall/followers","following_url":"https://api.github.com/users/npgall/following{/other_user}","gists_url":"https://api.github.com/users/npgall/gists{/gist_id}","starred_url":"https://api.github.com/users/npgall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/npgall/subscriptions","organizations_url":"https://api.github.com/users/npgall/orgs","repos_url":"https://api.github.com/users/npgall/repos","events_url":"https://api.github.com/users/npgall/events{/privacy}","received_events_url":"https://api.github.com/users/npgall/received_events","type":"User","site_admin":false}],"milestone":null,"comments":2,"created_at":"2015-12-23T14:02:26Z","updated_at":"2016-09-20T00:17:48Z","closed_at":"2016-09-20T00:17:47Z","body":"(1)对象上的属性支持lambda,而当前使用匿名内部类的方式非常不爽，尤其Java8了，看到匿名内部类就有种本能的退缩感觉（The property on the object supports lambda, and the current use of anonymous inner classes is very uncomfortable, especially Java8 when seeiing the anonymous inner class has a kind of instinctive retreat）\r\n\r\neg:\r\n public static final Attribute<Car, Integer> CAR_ID = new SimpleAttribute<Car, Integer>( \"carId\") {\r\n        @Override\r\n        public Integer getValue(Car car, QueryOptions queryOptions ) {\r\n            return car.carId;\r\n        }\r\n    };\r\n\r\n该被类似如下简洁lambda代替：should be replaced by some followings:\r\n\r\npublic static final Attribute<Car, Integer> CAR_ID = new SimpleAttribute<Car,Integer>(\"carId\", (car,queryOptions) => car.carId );\r\n\r\n\r\n(2) 应该支持基本类型的属性，类似 Java8 中的 IntFunction，DoubleFunction 之类，原因是查询往往在大数据量中的应用，应该想尽一切办法消除自动装箱拆箱的性能损耗以达到最高的运行效率[Should support the primitives types of attributes, like DoubleFunction IntFunction similar in java8. The reason is that queries are often in a large amount of data application, CQEngine should try every possible way to eliminate the performance loss of the automatic boxing and unboxing in order to achieve the highest efficiency]\r\n\r\neg:\r\n\r\npublic static final Attribute<Car, Integer> CAR_ID = new SimpleAttribute<Car, Integer>( \"carId\") {\r\n        @Override\r\n        public Integer getValue(Car car, QueryOptions queryOptions ) {\r\n            return car.carId;\r\n        }\r\n    };\r\n\r\n可使用如下：(Maybe use followings:)\r\n\r\npublic static final IntAttribute<Car> CAR_ID = new IntAttribute<Car>(\"carId\"){\r\n        @Override\r\n        public int getValue(Car car, QueryOptions queryOptions ) {\r\n            //no boxing Integer here!\r\n            return car.carId;\r\n        }\r\n    };\r\n\r\nand lambda support above:\r\n\r\npublic static final IntAttribute<Car> CAR_ID = new IntAttribute<Car>(\"carId\", (car,queryOptions)  => car.carId);\r\n"}}
{"actor":{"display_login":"npgall"}}