@Test public void shouldCreateAdler32hasher() { Hasher hasher = HasherFactory.createHasher("Adler32"); assertThat(hasher.getClass().getTypeName(), is(Adler32Hasher.class.getTypeName())); }
public static Hasher createHasher(String hasherType) { Hasher hasher; switch (hasherType) { case "MD5": hasher = new MD5Hasher(); break; case "SHA1": hasher = new SHA1Hasher(); break; case "SHA256": hasher = new SHA256Hasher(); break; case "SHA384": hasher = new SHA384Hasher(); break; case "Adler32": hasher = new Adler32Hasher(); break; case "CRC32b": hasher = new CRC32Hasher(); break; default: hasher = new SHA512Hasher(); } return hasher; }
HasherFactory { public static Hasher createHasher(String hasherType) { Hasher hasher; switch (hasherType) { case "MD5": hasher = new MD5Hasher(); break; case "SHA1": hasher = new SHA1Hasher(); break; case "SHA256": hasher = new SHA256Hasher(); break; case "SHA384": hasher = new SHA384Hasher(); break; case "Adler32": hasher = new Adler32Hasher(); break; case "CRC32b": hasher = new CRC32Hasher(); break; default: hasher = new SHA512Hasher(); } return hasher; } }
HasherFactory { public static Hasher createHasher(String hasherType) { Hasher hasher; switch (hasherType) { case "MD5": hasher = new MD5Hasher(); break; case "SHA1": hasher = new SHA1Hasher(); break; case "SHA256": hasher = new SHA256Hasher(); break; case "SHA384": hasher = new SHA384Hasher(); break; case "Adler32": hasher = new Adler32Hasher(); break; case "CRC32b": hasher = new CRC32Hasher(); break; default: hasher = new SHA512Hasher(); } return hasher; }  }
HasherFactory { public static Hasher createHasher(String hasherType) { Hasher hasher; switch (hasherType) { case "MD5": hasher = new MD5Hasher(); break; case "SHA1": hasher = new SHA1Hasher(); break; case "SHA256": hasher = new SHA256Hasher(); break; case "SHA384": hasher = new SHA384Hasher(); break; case "Adler32": hasher = new Adler32Hasher(); break; case "CRC32b": hasher = new CRC32Hasher(); break; default: hasher = new SHA512Hasher(); } return hasher; }  static Hasher createHasher(String hasherType); }
HasherFactory { public static Hasher createHasher(String hasherType) { Hasher hasher; switch (hasherType) { case "MD5": hasher = new MD5Hasher(); break; case "SHA1": hasher = new SHA1Hasher(); break; case "SHA256": hasher = new SHA256Hasher(); break; case "SHA384": hasher = new SHA384Hasher(); break; case "Adler32": hasher = new Adler32Hasher(); break; case "CRC32b": hasher = new CRC32Hasher(); break; default: hasher = new SHA512Hasher(); } return hasher; }  static Hasher createHasher(String hasherType);  }