Package com.mattinsler.guiceymongo.data.generator.type

Examples of com.mattinsler.guiceymongo.data.generator.type.ListType


    builder.append(template.toString());
  }
 
  @Override
  public void createWrapperMethod(Appendable builder, ListProperty property, int indentCount) throws IOException {
    ListType type = property.getType();

    String s =
        "/**\n" +
        " * $p.comment$\n" +
        " */\n" +
        "protected $p.listType$ $p.memberVariableName$ = null;\n" +
        "/**\n" +
        " * $p.comment$\n" +
        " */\n" +
        "@Override\n" +
        "public int get$p.camelCaseName$Count() {\n" +
          "$p.listType$ list = get$p.camelCaseName$List();\n" +
          "return list == null ? 0 : list.size();\n" +
        "}\n" +
        "/**\n" +
        " * $p.comment$\n" +
        " */\n" +
        "@SuppressWarnings(\"unchecked\")\n" +
        "@Override\n" +
        "public $p.listType$ get$p.camelCaseName$List() {\n" +
          "if ($p.memberVariableName$ == null) {\n" +
            "Object value = _backing.get($p.keyName$);\n" +
            "if (value != null && value instanceof java.util.List<?>) {\n";

    if (type.getItemType() instanceof UserEnumType) {
      s +=
              "$p.listType$ list = new $p.newListType$();\n" +
              "for (String item : (java.util.List<String>)value) {\n" +
                "try {\n" +
                  "list.add($p.listItemType$.valueOf(item));\n" +
                "} catch (Exception e) {\n" +
                "}\n" +
              "}\n" +
              "$p.memberVariableName$ = java.util.Collections.unmodifiableList(list);\n";
    } else if (type.getItemType() instanceof UserDataType) {
      s +=
              "$p.listType$ list = new $p.newListType$();\n" +
              "for (com.mongodb.DBObject o : (java.util.List<com.mongodb.DBObject>)value)\n" +
                "list.add($p.listItemType$.wrap(o));\n" +
              "$p.memberVariableName$ = java.util.Collections.unmodifiableList(list);\n";
View Full Code Here


//    return this;
//  }
 
  @Override
  public void createUpdaterMethod(Appendable builder, ListProperty property, int indentCount) throws IOException {
    ListType type = property.getType();
    Type itemType = type.getItemType();
   
    // member variable
    if (itemType instanceof UserDataType)
      appendIndent(builder, indentCount).append("protected java.util.List<").append(itemType.getJavaType()).append(".Updater> ").append(property.getMemberVariableName()).append("Added = null;\n");
    else
      appendIndent(builder, indentCount).append("protected ").append(type.getJavaType()).append(" ").append(property.getMemberVariableName()).append("Added = null;\n");
   
    // getCount
    appendIndent(builder, indentCount).append("@Override public int get").append(property.getCamelCaseName()).append("Count() {\n");
    appendIndent(builder, indentCount + 1).append("return _wrapper.").append(property.getMemberVariableName()).append(" != nullgetCount() || _builder.getCount();\n");
    appendIndent(builder, indentCount).append("}\n");
   
    // getList
    if (itemType instanceof UserDataType)
      appendIndent(builder, indentCount).append("@Override public java.util.List<").append(itemType.getJavaType()).append(".Builder> get").append(property.getCamelCaseName()).append("List() {\n");
    else
      appendIndent(builder, indentCount).append("@Override public ").append(type.getJavaType()).append(" get").append(property.getCamelCaseName()).append("List() {\n");
    appendIndent(builder, indentCount + 1).append("return ").append(property.getMemberVariableName()).append(";\n");
    appendIndent(builder, indentCount).append("}\n");
   
    // get
    if (itemType instanceof UserDataType)
      appendIndent(builder, indentCount).append("@Override public ").append(type.getItemType().getJavaType()).append(".Builder get").append(property.getCamelCaseName()).append("(int index) {\n");
    else
      appendIndent(builder, indentCount).append("@Override public ").append(type.getItemType().getJavaType()).append(" get").append(property.getCamelCaseName()).append("(int index) {\n");
    appendIndent(builder, indentCount + 1).append("return ").append(property.getMemberVariableName()).append(" == null ? null : ").append(property.getMemberVariableName()).append(".get(index);\n");
    appendIndent(builder, indentCount).append("}\n");
   
    // add
    if (itemType instanceof UserDataType)
View Full Code Here

TOP

Related Classes of com.mattinsler.guiceymongo.data.generator.type.ListType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.