Archive for November, 2011

JCommander 1.20

I just released JCommander 1.20. The main new feature is “parameter delegates”:

Parameter delegates

If you are writing many different tools in the same project, you will probably find that most of these tools can share configurations. While you can use inheritance with your objects to avoid repeating this code, the restriction to single inheritance of implementation might limit your flexibility. To address this problem, JCommander supports parameter delegates.

When JCommander encounters an object annotated with @ParameterDelegate in one of your objects, it acts as if this object had been added as a description object itself:

class Delegate {
  @Parameter(names = "-port")
  public int port;
}
class MainParams {
  @Parameter(names = "-v")
  public boolean verbose;
  @ParametersDelegate
  public Delegate delegate = new Delegate();
}

The example above specifies a delegate parameter Delegate which is then referenced in MainParams. You only need to add a MainParams object to your JCommander configuration in order to use the delegate:

MainParams p = new MainParams();
new JCommander(p).parse("-v", "-port", "1234");
Assert.assertTrue(p.isVerbose);
Assert.assertEquals(p.delegate.port, 1234);

Change log for 1.20

  • Added: Support for delegating parameter definitions to child classes (rodionmoiseev)
  • Added: @Parameter(commandNames) so that command names can be specified with annotations
  • Added: Support for enums (Adrian Muraru)
  • Fixed: Throw if an unknown option is found
  • Fixed: Main parameters are now validated as well (Connor Mullen)

  • Doom 3 source code

    Browsing the source code of Doom 3 comforts me in my belief that I’m simply not cut out for graphic programming.

    The new Google Reader

    Count me as one more Google Reader faithful user who really doesn’t like the new look.

    Google, don’t make the mistake of dismissing all the criticism as “They’re complaining because it’s different, they’ll get used to it, we just to wait them out” and take the time to ponder the new look.

    It’s basically black and white, with a lot (a lot) of empty space and a selection that turns the foreground (yes, the foreground, and the foreground only) of the font to red:

    I mean, the whole page seems to be using five colors total. Surely it’s possible to make a better use of colors without going all psychedelic on us?

    Any default theme of WordPress looks ten times better than Reader right now.

    Come on, Google, you can do better than this.