Wednesday, January 21, 2009

Eclipse Templates - Iterating Over a Map

Here is another code template. This one, I cannot take the credit for, but I have added it to my toolbox of great Eclipse Templates. It will give you the ability to iterate over a Map using the Map.Entry. Enjoy:

for (Iterator<Map.Entry<${type},${type2}>> it = ${variableName:var(java.util.Map)}.entrySet().iterator(); it.hasNext();) {  
    Map.Entry<${type},${type2}> entry = it.next();  
       ${type} key = entry.getKey();  
       ${type2} value = entry.getValue();  
       // do something with the key and the value  
}

Monday, January 19, 2009

Eclipse Templates - Jakarta Commons ToString, HashCode, Equals

Hey everyone,

I just wanted to take the time to share with you a code template that I created that has been very helpful in a project that I am currently working on. This template will give you the ability to create the toString(), equals(), hashCode() methods using the Jakarta Commons library. Enjoy:



${:import(org.apache.commons.lang.builder.EqualsBuilder,org.apache.commons.lang.builder.HashCodeBuilder,org.apache.commons.lang.builder.ReflectionToStringBuilder)}
@Override
public boolean equals(Object obj) {
return EqualsBuilder.reflectionEquals(this, obj);
}

@Override
public String toString() {
return ReflectionToStringBuilder.toString(this);
}

@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}

Saturday, January 17, 2009

Code Retreat - Hope I can make it.

Okay, okay, okay. I admit it. I am a huge geek. Because of that, this announcement sounds too cool to pass up. Let's see if I will be able to attend or not:

Greetings!

Are you a programmer who is serious about improving your craft? Do you love coding with others who feel the same way? Do you spend too much time toiling in thankless corporate legacy-code saltmines? Do you remember the joy of programming?

If so, please contact me. We are putting together a group of attendees for the first CodeRetreat, a week from Saturday in Ann Arbor, MI:

http://coderetreat.ning.com/

You need not be agile, and you need not be a Master-level programmer, to attend. You do need to be passionate about craft, open-minded, with a good attitude, a sense of humor, and a laptop.

We'll likely work in Eclipse and RubyMine.

We'll do everything in pairs or tuples.

We'll supply free food.

We'll code 80% of the time, and discuss 20% of the time.

Then, at the end of the day, we'll go out for beers.

It will be a blast.

If you know anyone else who might have fun and fit in at CodeRetreat #1, please send them our way as well.