k4h4shi
9/10/2017 - 12:23 PM

Javaのenumについて ref: http://qiita.com/k4h4shi/items/82340ec696db6034949e

public final class Constants {
    static final String CONST_STR = "文字列の定数値です";
    static final Integer CONST_INT = 0;
}
public enum Enum {
    // 命名を行う余地を持つ
    ENUM("文字列の定数値1です");
    ENUM("文字列の定数値1です");

    private String constStr;    

    private Enum(String constStr) {
        this.constStr = constStr;
    }
}
public final class Constants {
    static final String CONST_STR_1 = "文字列の定数値1です";
    static final String CONST_STR_2 = "文字列の定数値2です";
}

interface Engineer {
  void work();
} 

class Tester implements Engineer {
  void work() { System.out.println("I'm testing!"); } 
}

class Programmer implements Engineer {
  void work() { System.out.println("I'm programming!"); }
}

enum JobType {
  TESTER(), PROGRAMMER();
}

interface EmployeeFactory {
  Employee create(JobType);
}

class EmployeeFactoryImpl implements EmployeeFactory {

  @Override
  public Employee create(JobType jobType) {
    switch(jobType) {
      case TESTER:
        return new Tester();
      case PROGRAMMER:
        return new Programmer();
    }
  }
}