private void implementSetter(
      TreeLogger logger,
      MethodBuffer mb,
      JMethod method,
      ModelMagic manifest,
      HasModelFields models,
      Annotation[] annos) {

    JPrimitiveType primitive = method.getReturnType().isPrimitive();
    boolean isVoid = primitive == JPrimitiveType.VOID;
    boolean isFluent = ModelGeneratorGwt.isFluent(method);
    String name = ModelGeneratorGwt.fieldName(method, manifest);
    ModelField field = models.getOrMakeField(name);
    field.addSetter(
                X_Source.binaryToSource(method.getReturnType().getQualifiedBinaryName()),
                name,
                ModelGeneratorGwt.toTypes(method.getParameterTypes()))
            .fluent =
        isFluent;
    if (!isFluent && !isVoid) {
      mb.println("var value = getProperty(\"" + name + "\");");
    }
    JParameter[] params = method.getParameters();
    if (params.length != 1)
      throw new NotConfiguredCorrectly(
          "A setter method, " + method.getJsniSignature() + " must have exactly one parameter");
    mb.println("setProperty(\"" + name + "\", A);");
    if (!isVoid) mb.println("return " + (isFluent ? "this;" : "value;"));
  }
  private void grabAnnotations(
      TreeLogger logger,
      ModelMagic models,
      HasModelFields fields,
      JMethod method,
      Annotation[] annos,
      JClassType type) {

    GetterFor getter = method.getAnnotation(GetterFor.class);
    ClientToServer c2s = method.getAnnotation(ClientToServer.class);
    ServerToClient s2c = method.getAnnotation(ServerToClient.class);
    Persistent persist = method.getAnnotation(Persistent.class);
    Serializable serial = method.getAnnotation(Serializable.class);
    Named name = method.getAnnotation(Named.class);

    for (Annotation annotation : annos) {
      if (getter == null && annotation.annotationType() == GetterFor.class)
        getter = (GetterFor) annotation;
      else if (serial == null && annotation.annotationType() == Serializable.class)
        serial = (Serializable) annotation;
      else if (persist == null && annotation.annotationType() == Persistent.class)
        persist = (Persistent) annotation;
      else if (c2s == null && annotation.annotationType() == ClientToServer.class)
        c2s = (ClientToServer) annotation;
      else if (s2c == null && annotation.annotationType() == ServerToClient.class)
        s2c = (ServerToClient) annotation;
      else if (name == null && annotation.annotationType() == Named.class)
        name = (Named) annotation;
    }

    String fieldName;
    if (name == null) {
      fieldName = ModelGeneratorGwt.fieldName(method, models);
    } else {
      fieldName = name.value();
      if (X_Runtime.isDebug()) {
        logger.log(
            Type.TRACE,
            "Named method "
                + method.getJsniSignature()
                + " "
                + fieldName
                + ", from @Named attribute.  Heuristic name: "
                + ModelGeneratorGwt.fieldName(method, models));
      }
    }
    if ("".equals(fieldName)) fieldName = method.getName();
    ModelField field = fields.getOrMakeField(fieldName);

    if (field.getPersistent() == null) {
      field.setPersistent(persist);
    } else {
      assert persist == null || (persist.patchable() == field.getPersistent().patchable())
          : "Model annotation mismatch! Field "
              + field.getName()
              + " of type "
              + type.getQualifiedSourceName()
              + " contained multiple @Persistent annotations which did not match.  "
              + "You may have to override an annotated supertype method with the correct "
              + "@Persistent annotation.";
    }

    if (field.getSerializable() == null) {
      field.setSerializable(serial);
    } else {
      //      assert serial == null ||
      //        ( // this block is all assert, so it will compile out of production.
      //          serial.clientToServer() == field.getSerializable().clientToServer() &&
      //          serial.serverToClient() == field.getSerializable().serverToClient() &&
      //          serial.obfuscated() == field.getSerializable().obfuscated()
      //          ) : "Model annotation mismatch! Field "+field.getName()+" contained " +
      //          		"multiple @Serializable annotations which did not match.  You may " +
      //          		"have to override an annotated supertype method with the correct " +
      //          		"@Serializable annotation.";
    }
    if (field.getServerToClient() == null) {
      field.setServerToClient(s2c);
    } else {
      assert s2c == null || s2c.enabled() == field.getServerToClient().enabled()
          : "Model annotation mismatch! Field "
              + field.getName()
              + " was marked as "
              + "both "
              + "serverToClient"
              + " enabled and disabled.  Please correct this ambiguity;"
              + " your model is now undeterministic and may break unexpectedly.";
    }
    if (field.getClientToServer() == null) {
      field.setClientToServer(c2s);
    } else {
      assert c2s == null || c2s.enabled() == field.getClientToServer().enabled()
          : "Model annotation mismatch! Field "
              + field.getName()
              + " was marked as "
              + "both "
              + "clientToServer"
              + " enabled and disabled.  Please correct this ambiguity;"
              + " your model is now undeterministic and may break unexpectedly.";
    }
  }