Exemplo n.º 1
0
  protected void _addFactoryMixIns(Class<?> mixin) {
    MemberKey[] methodKeys = null;
    int methodCount = _creatorMethods.size();

    for (Method m : mixin.getDeclaredMethods()) {
      if (!Modifier.isStatic(m.getModifiers())) {
        continue;
      }
      if (m.getParameterTypes().length == 0) {
        continue;
      }
      if (methodKeys == null) {
        methodKeys = new MemberKey[methodCount];
        for (int i = 0; i < methodCount; ++i) {
          methodKeys[i] = new MemberKey(_creatorMethods.get(i).getAnnotated());
        }
      }
      MemberKey key = new MemberKey(m);
      for (int i = 0; i < methodCount; ++i) {
        if (!key.equals(methodKeys[i])) {
          continue;
        }
        _addMixOvers(m, _creatorMethods.get(i), true);
        break;
      }
    }
  }
Exemplo n.º 2
0
  protected void _addConstructorMixIns(Class<?> mixin) {
    MemberKey[] ctorKeys = null;
    int ctorCount = (_constructors == null) ? 0 : _constructors.size();
    for (Constructor<?> ctor : mixin.getDeclaredConstructors()) {
      switch (ctor.getParameterTypes().length) {
        case 0:
          if (_defaultConstructor != null) {
            _addMixOvers(ctor, _defaultConstructor, false);
          }
          break;
        default:
          if (ctorKeys == null) {
            ctorKeys = new MemberKey[ctorCount];
            for (int i = 0; i < ctorCount; ++i) {
              ctorKeys[i] = new MemberKey(_constructors.get(i).getAnnotated());
            }
          }
          MemberKey key = new MemberKey(ctor);

          for (int i = 0; i < ctorCount; ++i) {
            if (!key.equals(ctorKeys[i])) {
              continue;
            }
            _addMixOvers(ctor, _constructors.get(i), true);
            break;
          }
      }
    }
  }