As I was again trying to remember how to sort a list of objects in Java bases on multiple keys, I had the luminous idea to finally write it down.
We have a list of pizza’s, and I want them sorted according to size, number of toppings and furthermore by name. This means that there will be groups ordered by size and within those groups the pizza’s are ordered into groups by number of toppings and in those groups the pizza’s are ordered by name.
We want to end up with a list like this:
- Pizza’s 34cm:
- Anchovy (34cm, tomato, cheese, Anchovies)
- Prosciutto (34cm, tomato, cheese and ham)
- Chicken Special (34cm, tomato, cheese, chicken and turkey pieces)
- Vulcano (34cm, tomato, cheese, mushrooms and ham)
- Peperone (34cm, tomato, cheese, mushrooms, ham, capsicum, chili peppers and onions)
- Pizza’s 30cm:
- Anchovy (30cm, tomato, cheese, Anchovies)
- Prosciutto (30cm, tomato, cheese and ham)
- Chicken Special (30cm, tomato, cheese, chicken and turkey pieces)
- Vulcano (30cm, tomato, cheese, mushrooms and ham)
- Peperone (30cm, tomato, cheese, mushrooms, ham, capsicum, chili peppers and onions)
- Pizza’s 26cm:
- Anchovy (26cm, tomato, cheese, Anchovies)
- Prosciutto (26cm, tomato, cheese and ham)
- Chicken Special (26cm, tomato, cheese, chicken and turkey pieces)
- Vulcano (26cm, tomato, cheese, mushrooms and ham)
- Peperone (26cm, tomato, cheese, mushrooms, ham, capsicum, chili peppers and onions)
read on
Today I was trying to figure out how to exclude certain resources/classes from the war that was being deployed to my embedded server in Eclipse. I couldn’t find out how to do this in the Eclipse settings file.
Apparently, it has nothing to do with the source folder you see in the Project Explorer view, or the export settings in the Buildpath dialogs: instead you need to edit the Eclipse settings file “project-war.settingsorg.eclipse.wst.common.component” (viewable in the Navigator view) and modify the deployed source folders in there. Changes there do *not* reflect in the Project explorer (at least not with my version of Eclipse, Galileo). I’ve removed the test sourcefolder from there and everything was honky dory.
| <?xml version="1.0" encoding="UTF-8"?> <project-modules id="moduleCoreId" project-version="1.5.0"> <wb-module deploy-name="foo-war"> <wb-resource deploy-path="/" source-path="/src/main/webapp"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/> <property name="context-root" value="foo"/> <property name="java-output-path"/> </wb-module> </project-modules> |
Here’s a list implementation I came up with to enable true paged data fetching completely transparent to any List
user. It works independent of persistence layers, such as JPA implementations etc and it can be used by anything that only needs a List, such as a < rich:dataTable >
.
read on
Some time ago I came across a very interesting article by Robert C. Martin (1996 column in pdf) about how packages are supposed to be made up and how it helps building a release, debug and shared-workload strategy. I don’t think it all applies to modern package management, especially for web applications, but it is an interesting perspective that deserves some attention.
granularity.pdf (original source offline: www.objectmentor.com/publications/granularity.pdf)
My summary of his article (as I understood all of it):
read on