Guava CaseFormat - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Guava CaseFormat class.

This code example shows how to use the following methods:to
 
public enum IpState { 
   UNASSIGNED, ASSIGNED, UNRECOGNIZED;
 
   public String toString() {
      return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name());
   } 
 
   public static IpState fromValue(String state) {
      try { 
         return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(state, "state")));
      } catch (IllegalArgumentException e) {
         return UNRECOGNIZED;
      } 
   } 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:to
 
public enum BackupType { 
   DAILY, WEEKLY;
 
   public String value() {
      return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name());
   } 
 
   @Override 
   public String toString() {
      return value(); 
   } 
 
   public static BackupType fromValue(String backupType) {
      return valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(backupType, "backupType")));
   } 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:to
 
   PASSWORD_CREDENTIALS;
 
   @Override 
   public String toString() {
      return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name());
   } 
 
   public static CredentialType fromValue(String credentialType) {
      return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(credentialType,
               "credentialType"))); 
   } 
 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:to
 
public enum BlobType { 
   BLOCK_BLOB, PAGE_BLOB, UNRECOGNIZED;
 
   public String value() {
      return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name());
   } 
 
   @Override 
   public String toString() {
      return value(); 
   } 
 
   public static BlobType fromValue(String type) {
      try { 
         return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(type, "type")));
      } catch (IllegalArgumentException e) {
         return UNRECOGNIZED;
      } 
   } 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:to
 
public enum LeaseStatus { 
   LOCKED, UNLOCKED, UNRECOGNIZED;
 
   public String value() {
      return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name());
   } 
 
   @Override 
   public String toString() {
      return value(); 
   } 
 
   public static LeaseStatus fromValue(String type) {
      try { 
         return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(type, "type")));
      } catch (IllegalArgumentException e) {
         return UNRECOGNIZED;
      } 
   } 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:to
public enum ServerState { 
 
   ON, STARTING, OFF, STOPPING, RESTARTING, SAVING, RESTORING, UPDATING, UNRECOGNIZED;
 
   public String value() {
      return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name());
   } 
 
   @Override 
   public String toString() {
      return value(); 
   } 
 
   public static ServerState fromValue(String state) {
      try { 
         return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(state, "state")));
      } catch (IllegalArgumentException e) {
         return UNRECOGNIZED;
      } 
   } 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:to
 
   UNRECOGNIZED;
 
   @Override 
   public String toString() {
      return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name()).toLowerCase();
   } 
 
   public static SystemVmType fromValue(String type) {
      try { 
         return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(type, "type")));
      } catch (IllegalArgumentException e) {
         return UNRECOGNIZED;
      } 
   } 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:to
	 * 好玩的CaseFormat转换,在spaceSize->space_size之间转换,比如数据库表名与Java类名,变量名之间的转换。 
	 */ 
	@Test
	public void caseFormatByGuava() { 
		String name = "SPACE_SIZE";
		assertThat(CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name)).isEqualTo("SpaceSize");
		assertThat(CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name)).isEqualTo("spaceSize");
		assertThat(CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_UNDERSCORE, name)).isEqualTo("space_size");
		assertThat(CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name)).isEqualTo("space-size");
	} 
 
	@Test
	public void otherUtils() { 
		// 直接getBytes, 无需catch UnsupportedEncodingException, JDK7 有相应的StandardCharsets 
		byte[] bytes = "foobarbaz".getBytes(Charsets.UTF_8);
	} 
} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:to
 
   UNRECOGNIZED;
 
   @Override 
   public String toString() {
      return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name());
   } 
 
   public static NetworkType fromValue(String type) {
      try { 
         return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(type, "type")));
      } catch (IllegalArgumentException e) {
         return UNRECOGNIZED;
      } 
   } 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:to
   PARAVIRTUAL,
 
   HVM, UNRECOGNIZED;
 
   public String value() {
      return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name());
   } 
 
   public String toString() {
      return value(); 
   } 
 
   public static VirtualizationType fromValue(String v) {
      try { 
         return valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, v));
      } catch (IllegalArgumentException e) {
         return UNRECOGNIZED;
      } 
   } 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Guava CaseFormat Methods: