This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| aList.stream() | |
| .collect(Collectors.groupingBy(AnObject::getKeyField, toDescSortedList())) | |
| .values() | |
| .stream() | |
| .map(list -> list.get(0)) | |
| .collect(Collectors.toMap(AnObject::getKeyField, AnObject::getValueField)); | |
| private static <AnObject> Collector<AnObject,?,List<AnObject>> toDescSortedList() { | |
| return Collectors.collectingAndThen( | |
| Collectors.toCollection(ArrayList::new), list -> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // source: http://stackoverflow.com/a/2641047/1201725 | |
| // | |
| // [name] is the name of the event "click", "mouseover", .. | |
| // same as you'd pass it to bind() | |
| // [fn] is the handler function | |
| $.fn.bindFirst = function(name, fn) { | |
| // bind as you normally would | |
| // don't want to miss out on any jQuery magic | |
| this.on(name, fn); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Convert list to string with delimiter | |
| * @param <T> class of the collection | |
| * @param values Given long values | |
| * @param classTypeParam Pass class type to get fields, do not set null | |
| * @param fieldName Name of the field of the object to get value of | |
| * @param delimiter Given delimiter | |
| * @return ({1L,3L,5L} + Long.class + null + ",") --> ("1,3,5") | |
| * ({{id:1},{id:2},{id:3}} + ObjectClass.class + "id" + ",") --> ("1,2,3") | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * By the design pattern below, you can easily run any code blocks on a Service in Spring MVC. | |
| * This provides a easy usage way of threads, high code maintainability and readability. | |
| */ | |
| public class SpringServiceThread { | |
| @Service | |
| public class ThreadService { | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT | |
| t.field1, | |
| t.field2, | |
| contains.id is not null contains_record | |
| FROM | |
| table t | |
| LEFT JOIN | |
| (select tom.* from table_one_to_many_relation tom where tom.id = 1) contains on contains.table_id = t.id |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** Design pattern below provides setting nullable values to the prepared statement easily | |
| * Set nullable value to PreparedStatement | |
| * @param ps PreparedStatement object | |
| * @param value Value to set | |
| * @param type Type of the value at DBMS (ex: Types.VARCHAR) | |
| * @param index Index of the value inside query string | |
| * @return Given PreparedStatement object with the value set | |
| * @throws SQLException | |
| * @throws TypeConstraintException If the type of the given value not found | |
| */ |
NewerOlder