Package org.jboss.errai.codegen.meta

Examples of org.jboss.errai.codegen.meta.MetaField


                           final IOCProcessingContext context) {

    final Annotation annotation = field.getAnnotation(annotationClass);
    final MetaClass type = MetaClassFactory.get(field.getDeclaringClass());

    final MetaField metaField = MetaClassFactory.get(field);

    dependencyControl.masqueradeAs(type);

    final ProcessingDelegate del = new ProcessingDelegate() {
      @SuppressWarnings("unchecked")
View Full Code Here


    this.fieldName = fieldName;
  }

  @Override
  public void handleCall(final CallWriter writer, final Context context, Statement statement) {
    final MetaField field;
    if (fieldName.equals("this")) {
      // TODO this is a workaround to access the enclosing instance of a type
      field = new BuildMetaField(null, null, Scope.Private, statement.getType(), "this");
    }
    else {
      field = statement.getType().getInheritedField(fieldName);
    }

    if (field == null) {
      UndefinedFieldException ufe = new UndefinedFieldException(fieldName, statement.getType());
      blameAndRethrow(ufe);
    }

    final String currCallString = writer.getCallString();
    writer.reset();

    statement = new VariableReference() {

      @Override
      public String getName() {
        return field.getName();
      }

      @Override
      public Statement getValue() {
        return null;
      }

      @Override
      public String generate(Context context) {
        StringBuilder buf = new StringBuilder(currCallString);
        if (!currCallString.isEmpty()) {
          buf.append(".");
        }
        buf.append(getName());
        return buf.toString();
      }

      @Override
      public MetaClass getType() {
        return field.getType();
      }
    };

    nextOrReturn(writer, context, statement);
  }
View Full Code Here

    return _getConstructor(getDeclaredConstructors(), classToMeta(parameters));
  }

  @Override
  public MetaField getInheritedField(String name) {
    MetaField f = getDeclaredField(name);
    if (f != null) return f;
    for (MetaClass iface : getInterfaces()) {
      f = iface.getInheritedField(name);
      if (f != null) return f;
    }
View Full Code Here

          else {
            val = fieldDemarshall(memberMapping, MetaClassFactory.get(EJObject.class));
          }

          if (memberMapping.getBindingMember() instanceof MetaField) {
            final MetaField field = (MetaField) memberMapping.getBindingMember();

            // handle long case -- GWT does not support long in JSNI
            if (field.isPublic()) {
              tryBuilder.append(loadVariable("entity").loadField(field.getName()).assignValue(val));
              continue;
            }
            else {
              final MetaMethod setterMeth = GenUtil.findCaseInsensitiveMatch(null,
                      field.getDeclaringClass(), "set" + field.getName(),
                      field.getType());

              if (setterMeth != null && !setterMeth.isPrivate()) {
                // Bind via setter
                bindingStatement =
                    loadVariable("entity").invoke(setterMeth, Cast.to(memberMapping.getTargetType(), val));
              }
              else if (field.getType().getCanonicalName().equals("long")) {
                throw new RuntimeException("cannot support private field marshalling of long type" +
                        " (not supported by JSNI) for field: "
                        + field.getDeclaringClass().getFullyQualifiedName() + "#" + field.getName());
              }
              else {
                if (!context.isExposed(field)) {
                  PrivateAccessUtil.addPrivateAccessStubs(gwtTarget ? "jsni" : "reflection", context.getClassStructureBuilder(), field);
                  context.markExposed(field);
View Full Code Here

    return "\"" + value + "\"";
  }

  public Statement valueAccessorFor(final MetaClassMember member) {
    if (member instanceof MetaField) {
      final MetaField field = (MetaField) member;
      if (!field.isPublic()) {
        final MetaMethod getterMethod = GenUtil.findCaseInsensitiveMatch(field.getType(),
                field.getDeclaringClass(), "get" + field.getName());

        if (getterMethod != null) {
          return loadVariable("a0").invoke(getterMethod);
        }
        else {
          if (!context.isExposed(field)) {
            PrivateAccessUtil.addPrivateAccessStubs(gwtTarget ? "jsni" : "reflection", context.getClassStructureBuilder(), field);
            context.markExposed(field);
          }

          return Stmt.invokeStatic(context.getGeneratedBootstrapClass(), PrivateAccessUtil
              .getPrivateFieldInjectorName(field),
                  loadVariable("a0"));
        }
      }
      else {
        return loadVariable("a0").loadField(field.getName());
      }
    }
    else {
      final MetaMethod method = (MetaMethod) member;
      return loadVariable("a0").invoke(method);
View Full Code Here

    this.fieldName = fieldName;
  }

  @Override
  public void handleCall(final CallWriter writer, final Context context, Statement statement) {
    final MetaField field;
    if (fieldName.equals("this")) {
      // TODO this is a workaround to access the enclosing instance of a type
      field = new BuildMetaField(null, null, Scope.Private, statement.getType(), "this");
    }
    else {
      field = statement.getType().getInheritedField(fieldName);
    }

    if (field == null) {
      final UndefinedFieldException ufe = new UndefinedFieldException(fieldName, statement.getType());
      if (context.isPermissiveMode()) {
         ufe.printStackTrace();
      }
      else {
        blameAndRethrow(ufe);
      }
    }

    final String currCallString = writer.getCallString();
    writer.reset();

    statement = new VariableReference() {

      @Override
      public String getName() {
        return fieldName;
      }

      @Override
      public Statement getValue() {
        return null;
      }

      @Override
      public String generate(final Context context) {
        final StringBuilder buf = new StringBuilder(currCallString);
        if (!currCallString.isEmpty()) {
          buf.append(".");
        }
        return buf.append(getName()).toString();
      }

      @Override
      public MetaClass getType() {
        return field == null ? MetaClassFactory.get(Object.class) : field.getType();
      }
    };

    nextOrReturn(writer, context, statement);
  }
View Full Code Here

          assertTypeIsBindable(dataModelType);
          dataBinderRef = inst.getTransientValue(TRANSIENT_BINDER_VALUE, DataBinder.class);
          inst.ensureMemberExposed();
        }
        else {
          final MetaField field = (MetaField) allInjectors.iterator().next();

          dataModelType = field.getType();
          assertTypeIsBindable(dataModelType);

          dataBinderRef = inst.getTransientValue(TRANSIENT_BINDER_VALUE, DataBinder.class);
          inst.getInjectionContext().addExposedField(field, PrivateAccessType.Both);
        }
View Full Code Here

        dataModelType = (MetaClass) mp.getType().getParameterizedType().getTypeParameters()[0];
        dataBinderRef = inst.getInjectionContext().getInlineBeanReference(mp);
        inst.ensureMemberExposed();
      }
      else {
        final MetaField field = (MetaField) allInjectors.iterator().next();

        assertTypeIsDataBinder(field.getType());
        dataModelType = (MetaClass) field.getType().getParameterizedType().getTypeParameters()[0];
        dataBinderRef = Stmt.invokeStatic(inst.getInjectionContext().getProcessingContext().getBootstrapClass(),
            PrivateAccessUtil.getPrivateFieldInjectorName(field),
            Variable.get(inst.getInjector().getInstanceVarName()));
        inst.getInjectionContext().addExposedField(field, PrivateAccessType.Both);
      }
    }
    else {
      final MetaClass declaringClass = inst.getInjector().getInjectedType();
      for (final MetaField field : declaringClass.getFields()) {
        if (field.isAnnotationPresent(AutoBound.class)) {
          assertTypeIsDataBinder(field.getType());
          dataModelType = (MetaClass) field.getType().getParameterizedType().getTypeParameters()[0];
          dataBinderRef = Stmt.invokeStatic(inst.getInjectionContext().getProcessingContext().getBootstrapClass(),
              PrivateAccessUtil.getPrivateFieldInjectorName(field),
              Variable.get(inst.getInjector().getInstanceVarName()));
          inst.getInjectionContext().addExposedField(field, PrivateAccessType.Both);
          break;
View Full Code Here

    switch (injectableInstance.getTaskType()) {
      case Type:
        return null;
      case PrivateField:
      case Field:
        final MetaField field = injectableInstance.getField();
        type = field.getType();

        pType = type.getParameterizedType();
        break;

      case Parameter:
View Full Code Here

    }

    /*
     * Search for data binder fields annotated with @AutoBound
     */
    MetaField dataBinderField = null;
    for (MetaField field : ctx.getInjector().getInjectedType().getFields()) {
      if (field.getType().getErased().equals(MetaClassFactory.get(DataBinder.class))
          && field.isAnnotationPresent(AutoBound.class)) {
        if (dataBinderField != null) {
          throw new GenerationException("Multiple @AutoBound data binder fields found in class "
View Full Code Here

TOP

Related Classes of org.jboss.errai.codegen.meta.MetaField

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.