Package com.google.gwt.autobean.shared.AutoBean

Examples of com.google.gwt.autobean.shared.AutoBean.PropertyName


      JEnumType enumType = method.getReturnType().isEnum();
      if (enumType != null) {
        Map<JEnumConstant, String> map = new LinkedHashMap<JEnumConstant, String>();
        for (JEnumConstant e : enumType.getEnumConstants()) {
          String name;
          PropertyName annotation = e.getAnnotation(PropertyName.class);
          if (annotation == null) {
            name = e.getName();
          } else {
            name = annotation.value();
          }
          map.put(e, name);
        }
        toReturn.enumMap = map;
      }
View Full Code Here


   */
  private Object getEnum(Class<?> clazz, String token)
      throws IllegalAccessException {
    for (Field f : clazz.getFields()) {
      String fieldName;
      PropertyName annotation = f.getAnnotation(PropertyName.class);
      if (annotation != null) {
        fieldName = annotation.value();
      } else {
        fieldName = f.getName();
      }
      if (token.equals(fieldName)) {
        f.setAccessible(true);
View Full Code Here

  /**
   * EnumMap support.
   */
  private Object getToken(Enum<?> e) throws NoSuchFieldException {
    // Remember enum constants are fields
    PropertyName annotation = e.getDeclaringClass().getField(e.name()).getAnnotation(
        PropertyName.class);
    if (annotation != null) {
      return annotation.value();
    } else {
      return e.name();
    }
  }
View Full Code Here

    private AutoBeanMethod toReturn = new AutoBeanMethod();

    public AutoBeanMethod build() {
      if (toReturn.action.equals(Action.GET)
          || toReturn.action.equals(Action.SET)) {
        PropertyName annotation = toReturn.method.getAnnotation(PropertyName.class);
        if (annotation != null) {
          toReturn.propertyName = annotation.value();
        } else {
          toReturn.propertyName = toReturn.action.inferName(toReturn.method);
        }
      }
View Full Code Here

   */
  private Object getEnum(Class<?> clazz, String token)
      throws IllegalAccessException {
    for (Field f : clazz.getFields()) {
      String fieldName;
      PropertyName annotation = f.getAnnotation(PropertyName.class);
      if (annotation != null) {
        fieldName = annotation.value();
      } else {
        fieldName = f.getName();
      }
      if (token.equals(fieldName)) {
        f.setAccessible(true);
View Full Code Here

  /**
   * EnumMap support.
   */
  private Object getToken(Enum<?> e) throws NoSuchFieldException {
    // Remember enum constants are fields
    PropertyName annotation = e.getDeclaringClass().getField(e.name()).getAnnotation(
        PropertyName.class);
    if (annotation != null) {
      return annotation.value();
    } else {
      return e.name();
    }
  }
View Full Code Here

         * Only support extra properties in JSON-RPC payloads. Could add this to
         * standard requests to provide out-of-band data.
         */
        if (method.getDialect().equals(Dialect.JSON_RPC)) {
          for (JMethod setter : request.getExtraSetters()) {
            PropertyName propertyNameAnnotation = setter.getAnnotation(PropertyName.class);
            String propertyName = propertyNameAnnotation == null
                ? JBeanMethod.SET.inferName(setter)
                : propertyNameAnnotation.value();
            String maybeReturn = JBeanMethod.SET_BUILDER.matches(setter)
                ? "return this;" : "";
            sw.println(
                "%s { getRequestData().setNamedParameter(\"%s\", %s); %s}",
                setter.getReadableDeclaration(false, false, false, false, true),
                propertyName, setter.getParameters()[0].getName(), maybeReturn);
          }
        }

        // end class X{}
        sw.outdent();
        sw.println("}");

        // Instantiate, enqueue, and return
        sw.println("X x = new X();");

        if (request.getApiVersion() != null) {
          sw.println("x.getRequestData().setApiVersion(\"%s\");",
              Generator.escape(request.getApiVersion()));
        }

        // JSON-RPC payloads send their parameters in a by-name fashion
        if (method.getDialect().equals(Dialect.JSON_RPC)) {
          for (JParameter param : jmethod.getParameters()) {
            PropertyName annotation = param.getAnnotation(PropertyName.class);
            String propertyName = annotation == null ? param.getName()
                : annotation.value();
            boolean isContent = param.isAnnotationPresent(JsonRpcContent.class);
            if (isContent) {
              sw.println("x.getRequestData().setRequestContent(%s);",
                  param.getName());
            } else {
View Full Code Here

    }
  }

  static String getEnumName(JEnumConstant e) {
    String name;
    PropertyName annotation = e.getAnnotation(PropertyName.class);
    if (annotation == null) {
      name = e.getName();
    } else {
      name = annotation.value();
    }
    return name;
  }
View Full Code Here

    public AutoBeanMethod build() {
      if (toReturn.action.equals(JBeanMethod.GET)
          || toReturn.action.equals(JBeanMethod.SET)
          || toReturn.action.equals(JBeanMethod.SET_BUILDER)) {
        PropertyName annotation = toReturn.method.getAnnotation(PropertyName.class);
        if (annotation != null) {
          toReturn.propertyName = annotation.value();
        } else {
          toReturn.propertyName = toReturn.action.inferName(toReturn.method);
        }
      }
View Full Code Here

TOP

Related Classes of com.google.gwt.autobean.shared.AutoBean.PropertyName

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.