Skip to content

Instantly share code, notes, and snippets.

View runeflobakk's full-sized avatar

Rune Flobakk runeflobakk

View GitHub Profile
private Person per = new Person("Per", new Address("A-gate 5", "0560", "Oslo"), 30);
private Person kari = new Person("Kari", new Address("B-gate 4", "0560", "Oslo"), 37);
@Test
public void knowsWhichRelativesLivingInTheSamePostalCode() {
per.relateTo(SIBLING, kari);
Collection<Relative> nearbyRelatives = per.getRelativesWithSamePostalCode();
assertThat(nearbyRelatives, hasSize(1));
@runeflobakk
runeflobakk / EqualsAndHashCodeTemplate.java
Created August 23, 2011 10:57
equals() and hashCode() template for Eclipse. It uses EqualsBuilder and HashCodeBuilder in Apache Commons Lang.
${e:import(org.apache.commons.lang3.builder.EqualsBuilder)}
${h:import(org.apache.commons.lang3.builder.HashCodeBuilder)}
@Override
public boolean equals(Object object) {
if (object instanceof ${enclosing_type}) {
${enclosing_type} another = (${enclosing_type}) object;
return new EqualsBuilder().append(${replaceWithFieldName}, another.${replaceWithFieldName}).isEquals();
}
@runeflobakk
runeflobakk / gist:962518
Created May 9, 2011 13:28
Add this to your Wicket application class to limit Wicket dev mode warning to one per JVM instead of per test. Reduces clutter in build log.
private static boolean warnedAboutDevMode = false;
@Override
protected void outputDevelopmentModeWarning() {
if (warnedAboutDevMode) {
return;
}
super.outputDevelopmentModeWarning();
warnedAboutDevMode = true;
}