CaseFormat.java 3.19 KB
package com.google.common.base;

import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import java.io.Serializable;
import javax.annotation.Nullable;

@GwtCompatible
public enum CaseFormat
{
  private final CharMatcher a;
  private final String b;
  
  private CaseFormat(CharMatcher paramCharMatcher, String paramString)
  {
    this.a = paramCharMatcher;
    this.b = paramString;
  }
  
  private String c(String paramString)
  {
    if (this == LOWER_CAMEL) {
      return Ascii.toLowerCase(paramString);
    }
    return a(paramString);
  }
  
  String a(CaseFormat paramCaseFormat, String paramString)
  {
    int i = 0;
    StringBuilder localStringBuilder = null;
    int j = -1;
    j = this.a.indexIn(paramString, j + 1);
    if (j != -1)
    {
      if (i == 0)
      {
        localStringBuilder = new StringBuilder(paramString.length() + this.b.length() * 4);
        localStringBuilder.append(paramCaseFormat.c(paramString.substring(i, j)));
      }
      for (;;)
      {
        localStringBuilder.append(paramCaseFormat.b);
        i = this.b.length() + j;
        break;
        localStringBuilder.append(paramCaseFormat.a(paramString.substring(i, j)));
      }
    }
    if (i == 0) {
      return paramCaseFormat.c(paramString);
    }
    return paramCaseFormat.a(paramString.substring(i));
  }
  
  abstract String a(String paramString);
  
  @Beta
  public Converter<String, String> converterTo(CaseFormat paramCaseFormat)
  {
    return new a(this, paramCaseFormat);
  }
  
  public final String to(CaseFormat paramCaseFormat, String paramString)
  {
    Preconditions.checkNotNull(paramCaseFormat);
    Preconditions.checkNotNull(paramString);
    if (paramCaseFormat == this) {
      return paramString;
    }
    return a(paramCaseFormat, paramString);
  }
  
  static final class a
    extends Converter<String, String>
    implements Serializable
  {
    private static final long serialVersionUID = 0L;
    private final CaseFormat a;
    private final CaseFormat b;
    
    a(CaseFormat paramCaseFormat1, CaseFormat paramCaseFormat2)
    {
      this.a = ((CaseFormat)Preconditions.checkNotNull(paramCaseFormat1));
      this.b = ((CaseFormat)Preconditions.checkNotNull(paramCaseFormat2));
    }
    
    public final boolean equals(@Nullable Object paramObject)
    {
      boolean bool2 = false;
      boolean bool1 = bool2;
      if ((paramObject instanceof a))
      {
        paramObject = (a)paramObject;
        bool1 = bool2;
        if (this.a.equals(((a)paramObject).a))
        {
          bool1 = bool2;
          if (this.b.equals(((a)paramObject).b)) {
            bool1 = true;
          }
        }
      }
      return bool1;
    }
    
    public final int hashCode()
    {
      return this.a.hashCode() ^ this.b.hashCode();
    }
    
    public final String toString()
    {
      String str1 = String.valueOf(String.valueOf(this.a));
      String str2 = String.valueOf(String.valueOf(this.b));
      return str1.length() + 14 + str2.length() + str1 + ".converterTo(" + str2 + ")";
    }
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/com/google/common/base/CaseFormat.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */