// Path: processor/src/main/java/net/yslibrary/simplepreferences/processor/KeyAnnotatedField.java
// public class KeyAnnotatedField {
// 
//   public final VariableElement annotatedElement;
//   public final TypeName type;
//   public final String name;
//   public final String preferenceKey;
//   public final boolean omitGetterPrefix;
//   public final boolean needCommitMethod;
// 
//   public KeyAnnotatedField(VariableElement element) throws ProcessingException {
//     if (element.getModifiers().contains(Modifier.PRIVATE)) {
//       throw new ProcessingException(element,
//           "Field %s is private, must be accessible from inherited class", element.getSimpleName());
//     }
//     annotatedElement = element;
// 
//     type = TypeName.get(element.asType());
// 
//     Key annotation = element.getAnnotation(Key.class);
//     name = element.getSimpleName().toString();
//     preferenceKey = Strings.isNullOrEmpty(annotation.name()) ? Utils.lowerCamelToLowerSnake(name)
//         : annotation.name();
//     omitGetterPrefix = annotation.omitGetterPrefix();
//     needCommitMethod = annotation.needCommitMethod();
//   }
// }
// 
// Path: processor/src/main/java/net/yslibrary/simplepreferences/processor/Utils.java
// public class Utils {
// 
//   public static String lowerToUpperCamel(String name) {
//     return CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, name);
//   }
// 
//   public static String lowerCamelToLowerSnake(String name) {
//     return CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, name);
//   }
// }


import com.squareup.javapoet.FieldSpec;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.TypeName;
import net.yslibrary.simplepreferences.processor.KeyAnnotatedField;
import net.yslibrary.simplepreferences.processor.Utils;
import javax.lang.model.element.Modifier;
package net.yslibrary.simplepreferences.processor.writer;




/**
 * Created by yshrsmz on 2016/02/23.
 */
public class StringSetTypeWriter extends BaseTypeWriter {

  protected StringSetTypeWriter(TypeName enclosingClassName, KeyAnnotatedField keyAnnotatedField) {
    super(enclosingClassName, keyAnnotatedField);
  }

  @Override
  public MethodSpec writeGetter(FieldSpec prefs) {
    return getBaseGetterBuilder()
        .addStatement("return $N.getStringSet($S, $L)", prefs, annotatedField.preferenceKey, annotatedField.name)
        .build();
  }

  @Override
  public MethodSpec writeGetterWithDefaultValue(FieldSpec prefs) {
    return getBaseGetterBuilder()
        .addParameter(annotatedField.type, PARAM_DEFAULT_VALUE)
        .addStatement("return $N.getStringSet($S, $L)", prefs, annotatedField.preferenceKey, PARAM_DEFAULT_VALUE)
        .build();
  }

  @Override
  public MethodSpec writeSetter(FieldSpec prefs) {
    return MethodSpec
// Path: processor/src/main/java/net/yslibrary/simplepreferences/processor/KeyAnnotatedField.java
// public class KeyAnnotatedField {
// 
//   public final VariableElement annotatedElement;
//   public final TypeName type;
//   public final String name;
//   public final String preferenceKey;
//   public final boolean omitGetterPrefix;
//   public final boolean needCommitMethod;
// 
//   public KeyAnnotatedField(VariableElement element) throws ProcessingException {
//     if (element.getModifiers().contains(Modifier.PRIVATE)) {
//       throw new ProcessingException(element,
//           "Field %s is private, must be accessible from inherited class", element.getSimpleName());
//     }
//     annotatedElement = element;
// 
//     type = TypeName.get(element.asType());
// 
//     Key annotation = element.getAnnotation(Key.class);
//     name = element.getSimpleName().toString();
//     preferenceKey = Strings.isNullOrEmpty(annotation.name()) ? Utils.lowerCamelToLowerSnake(name)
//         : annotation.name();
//     omitGetterPrefix = annotation.omitGetterPrefix();
//     needCommitMethod = annotation.needCommitMethod();
//   }
// }
// 
// Path: processor/src/main/java/net/yslibrary/simplepreferences/processor/Utils.java
// public class Utils {
// 
//   public static String lowerToUpperCamel(String name) {
//     return CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, name);
//   }
// 
//   public static String lowerCamelToLowerSnake(String name) {
//     return CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, name);
//   }
// }


// Path: processor/src/main/java/net/yslibrary/simplepreferences/processor/writer/StringSetTypeWriter.java
import com.squareup.javapoet.FieldSpec;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.TypeName;
import net.yslibrary.simplepreferences.processor.KeyAnnotatedField;
import net.yslibrary.simplepreferences.processor.Utils;
import javax.lang.model.element.Modifier;

package net.yslibrary.simplepreferences.processor.writer;




/**
 * Created by yshrsmz on 2016/02/23.
 */
public class StringSetTypeWriter extends BaseTypeWriter {

  protected StringSetTypeWriter(TypeName enclosingClassName, KeyAnnotatedField keyAnnotatedField) {
    super(enclosingClassName, keyAnnotatedField);
  }

  @Override
  public MethodSpec writeGetter(FieldSpec prefs) {
    return getBaseGetterBuilder()
        .addStatement("return $N.getStringSet($S, $L)", prefs, annotatedField.preferenceKey, annotatedField.name)
        .build();
  }

  @Override
  public MethodSpec writeGetterWithDefaultValue(FieldSpec prefs) {
    return getBaseGetterBuilder()
        .addParameter(annotatedField.type, PARAM_DEFAULT_VALUE)
        .addStatement("return $N.getStringSet($S, $L)", prefs, annotatedField.preferenceKey, PARAM_DEFAULT_VALUE)
        .build();
  }

  @Override
  public MethodSpec writeSetter(FieldSpec prefs) {
    return MethodSpec
        .methodBuilder(BaseTypeWriter.SETTER_PREFIX + Utils.lowerToUpperCamel(annotatedField.name))