Skip to content

Instantly share code, notes, and snippets.

@kawasima
Created March 25, 2016 11:22
Show Gist options
  • Save kawasima/402c4ae011de4563dbeb to your computer and use it in GitHub Desktop.
Save kawasima/402c4ae011de4563dbeb to your computer and use it in GitHub Desktop.
public interface CodeEnum {
String getLabel();
String getCode();
}
public enum Gender implements CodeEnum {
FEMALE("F", "女"),
MALE("M", "男"),
OTHER("O", "その他");
private String label;
private String code;
Gender(String code, String label) {
this.label = label;
this.code = code;
}
@Override
public String getLabel() {
return label;
}
@Override
public String getCode() {
return code;
}
}
Arrays.stream(Gender.values())
.map(g -> "<option value=\"" + g.getCode()
+ "\">" + g.getLabel()
+ "</option>")
.forEach(System.out::println);
<option value="F">女</option>
<option value="M">男</option>
<option value="O">その他</option>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment