package org.beanmaker.util;

public class IdNamePair {

	private final String id;
	private final String name;
	
	public IdNamePair(final int id, final String name) {
		if (id < 0)
			throw new IllegalArgumentException("id must be zero or positive");
		
		this.id = Integer.toString(id);
		this.name = name;
	}
	
	public IdNamePair(final long id, final String name) {
		if (id < 0)
			throw new IllegalArgumentException("id must be zero or positive");
		
		this.id = Long.toString(id);
		this.name = name;
	}
	
	public IdNamePair(final String id, final String name) {
		this.id = id;
		this.name = name;
	}
	
	public String getId() {
		return id;
	}
	
	public String getName() {
		return name;
	}
}


@@ -45,16 +45,50 @@
 NamePair
+ implements Comparable%3CIdNamePair%3E
  %7B%0A%0A%09pri
@@ -722,12 +722,463 @@
 name;%0A%09%7D
+%0A%0A%09// Assumes only one %22please select ...%22 element with id %220%22, throws an IllegalStateException otherwise.%0A%09@Override%0A%09public int compareTo(final IdNamePair idNamePair) %7B%0A%09%09if (id.equals(%220%22) && idNamePair.id.equals(%220%22))%0A%09%09%09throw new IllegalStateException(%22More than one 'please select' field in IdNamePair collection.%22);%0A%0A%09%09if (id.equals(%220%22))%0A%09%09%09return -1;%0A%09%09if (idNamePair.id.equals(%220%22))%0A%09%09%09return 1;%0A%0A%09%09return name.compareTo(idNamePair.name);%0A%09%7D
 %0A%7D%0A%0A

Implement Comparable<IdNamePair>