Package org.jboss.errai.codegen.meta

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


    return _getMethod(getDeclaredMethods(), name, parmTypes);
  }

  @Override
  public MetaMethod getBestMatchingMethod(final String name, final Class... parameters) {
    MetaMethod meth = getMethod(name, parameters);
    if (meth == null || meth.isStatic()) {
      meth = null;
    }

    final MetaClass[] mcParms = new MetaClass[parameters.length];
    for (int i = 0; i < parameters.length; i++) {
View Full Code Here


    }, name, parameters);
  }

  @Override
  public MetaMethod getBestMatchingStaticMethod(final String name, final Class... parameters) {
    MetaMethod meth = getMethod(name, parameters);
    if (meth == null || !meth.isStatic()) {
      meth = null;
    }

    final MetaClass[] mcParms = new MetaClass[parameters.length];
    for (int i = 0; i < parameters.length; i++) {
View Full Code Here

    MetaMethod[] getMethods();
  }

  private MetaMethod getBestMatchingMethod(final GetMethodsCallback methodsCallback, final String name,
                                           final MetaClass... parameters) {
    MetaMethod meth = GenUtil.getBestCandidate(parameters, name, this, methodsCallback.getMethods(), false);
    if (meth == null) {
      meth = GenUtil.getBestCandidate(parameters, name, this, methodsCallback.getMethods(), false);
    }
    return meth;
  }
View Full Code Here

        return setterProperties.get(propertyName);
      }

      @Override
      public MetaClass getPropertyType(final String propertyName) {
        final MetaMethod readMethod = getReadMethodForProperty(propertyName);
        if (readMethod != null) {
          return readMethod.getReturnType();
        }

        return getWriteMethodForProperty(propertyName).getParameters()[0].getType();
      }
    };
View Full Code Here

  }

  @Override
  public List<? extends Statement> generateDecorator(InjectableInstance<Observes> instance) {
    final Context ctx = instance.getInjectionContext().getProcessingContext().getContext();
    final MetaMethod method = instance.getMethod();
    final MetaParameter parm = instance.getParm();

    if (!method.isPublic()) {
      instance.ensureMemberExposed(PrivateAccessType.Write);
    }

    final String parmClassName = parm.getType().getFullyQualifiedName();
    final Statement bus = instance.getInjectionContext().getInjector(MessageBus.class).getBeanInstance(instance);
View Full Code Here

            if (field.isPublic()) {
              builder.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")) {
View Full Code Here

  public Statement valueAccessorFor(final MetaClassMember member, ClassStructureBuilder<?> classStructureBuilder) {
    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, classStructureBuilder.getClassDefinition().getName())) {
            PrivateAccessUtil.addPrivateAccessStubs(gwtTarget ? "jsni" : "reflection", classStructureBuilder, field);
            context.markExposed(field, classStructureBuilder.getClassDefinition().getName());
          }

          return Stmt.invokeStatic(classStructureBuilder.getClassDefinition(), PrivateAccessUtil
              .getPrivateFieldInjectorName(field),
              loadVariable("a0"));
        }
      }
      else {
        return loadVariable("a0").loadField(field.getName());
      }
    }
    else {
      final MetaMethod method = (MetaMethod) member;
      if (!method.isPublic()) {
        if (!context.isExposed(method, classStructureBuilder.getClassDefinition().getName())) {
          PrivateAccessUtil.addPrivateAccessStubs(gwtTarget ? "jsni" : "reflection", classStructureBuilder, method);
          context.markExposed(method, classStructureBuilder.getClassDefinition().getName());
        }
View Full Code Here

  }

  private void generateGetter(ClassStructureBuilder<?> classBuilder, String property,
      BlockBuilder<?> getMethod) {

    MetaMethod getterMethod = bindable.getBeanDescriptor().getReadMethodForProperty(property);
    if (getterMethod != null && !getterMethod.isFinal()) {
      getMethod
          .append(
              If.objEquals(Stmt.loadVariable("property"), property)
                  .append(
                      Stmt.loadVariable("this").invoke(getterMethod.getName()).returnValue())
                  .finish()
          );

      classBuilder.publicMethod(getterMethod.getReturnType(), getterMethod.getName())
          .append(Stmt.loadClassMember("target").invoke(getterMethod.getName()).returnValue())
          .finish();
    }
  }
View Full Code Here

          .finish();
    }
  }

  private void generateSetter(ClassStructureBuilder<?> classBuilder, String property, BlockBuilder<?> setMethod) {
    MetaMethod getterMethod = bindable.getBeanDescriptor().getReadMethodForProperty(property);
    MetaMethod setterMethod = bindable.getBeanDescriptor().getWriteMethodForProperty(property);
    if (setterMethod != null && !setterMethod.isFinal()) {
      setMethod
          .append(
             If.cond(Stmt.loadVariable("property").invoke("equals", property))
                 .append(
                        Stmt.declareVariable("oldValue", setterMethod.getParameters()[0].getType().asBoxed(),
                            Stmt.loadVariable("this").invoke(getterMethod)))
                 .append(
                     Stmt.loadVariable("target").invoke(
                         setterMethod.getName(),
                         Cast.to(setterMethod.getParameters()[0].getType().asBoxed(),
                             Stmt.invokeStatic(Convert.class, "toModelValue",
                                 setterMethod.getParameters()[0].getType().asBoxed().asClass(),
                                 Stmt.loadVariable("value"),
                                 Stmt.loadVariable("converters").invoke("get", Variable.get("property"))))))
                 .append(
                     Stmt.loadVariable("propertyChangeHandlerSupport").invoke(
                         "notifyHandlers",
                         Stmt.newObject(PropertyChangeEvent.class, Stmt.loadVariable("property"), Stmt
                             .loadVariable("oldValue"), Stmt.loadVariable("value"))))
                 .append(Stmt.returnVoid())
                 .finish()
          );

      MetaClass paramType = setterMethod.getParameters()[0].getType();

      Statement callSetterOnTarget = Stmt.loadClassMember("target").invoke(setterMethod.getName(),
                Cast.to(paramType, Stmt.loadVariable(property)));

      // If the set method we are proxying returns a value, capture that value into a local variable
      Statement returnValueOfSetter = EmptyStatement.INSTANCE;
      if (!setterMethod.getReturnType().equals(MetaClassFactory.get(void.class))) {
        callSetterOnTarget = Stmt.declareFinalVariable("returnValueOfSetter", setterMethod.getReturnType(), callSetterOnTarget);
        returnValueOfSetter = Stmt.nestedCall(Refs.get("returnValueOfSetter")).returnValue();
      }

      classBuilder.publicMethod(setterMethod.getReturnType(), setterMethod.getName(),
          Parameter.of(paramType, property))
          .append(
              Stmt.declareVariable("oldValue", Object.class, Stmt.loadClassMember("target").invoke(
                  getterMethod.getName())))
          .append(callSetterOnTarget)
View Full Code Here

      }
    }
  }
 
  public static MetaMethod findGetterMethod(MetaClass cls, String key) {
    MetaMethod metaMethod = _findGetterMethod("get", cls, key);
    if (metaMethod != null) return metaMethod;
    metaMethod = _findGetterMethod("is", cls, key);
     return metaMethod;
  }
View Full Code Here

TOP

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

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.