protected Method[] getMethods(Class type) { List methods = new ArrayList(Arrays.asList(type.getMethods())); CollectionUtils.filter(methods, new RejectModifierPredicate(Modifier.FINAL | Modifier.STATIC)); return (Method[])methods.toArray(new Method[methods.size()]); } }
private static void stringSwitchHelper(final CodeEmitter e, List strings, final ObjectSwitchCallback callback, final Label def, final Label end, final int index) throws Exception { final int len = ((String)strings.get(0)).length(); final Map buckets = CollectionUtils.bucket(strings, new Transformer() { public Object transform(Object value) { return new Integer(((String)value).charAt(index)); } }); e.dup(); e.push(index); e.invoke_virtual(Constants.TYPE_STRING, STRING_CHAR_AT); e.process_switch(getSwitchKeys(buckets), new ProcessSwitchCallback() { public void processCase(int key, Label ignore_end) throws Exception { List bucket = (List)buckets.get(new Integer(key)); if (index + 1 == len) { e.pop(); callback.processCase(bucket.get(0), end); } else { stringSwitchHelper(e, bucket, callback, def, end, index + 1); } } public void processDefault() { e.goTo(def); } }); }
final Map indexes = new HashMap(); final Map originalModifiers = new HashMap(); final Map positions = CollectionUtils.getIndexMap(methods); final Map declToBridge = new HashMap();
CollectionUtils.filter(methods, vp); CollectionUtils.filter(methods, new DuplicatesPredicate()); List constructors = new ArrayList(Arrays.asList(type.getDeclaredConstructors())); CollectionUtils.filter(constructors, vp); List info = CollectionUtils.transform(constructors, MethodInfoTransformer.getInstance()); EmitUtils.constructor_switch(e, info, new GetIndexCallback(e, info)); e.end_method();
private void emitIndexBySignature(List methods) { CodeEmitter e = begin_method(Constants.ACC_PUBLIC, SIGNATURE_GET_INDEX, null); List signatures = CollectionUtils.transform(methods, new Transformer() { public Object transform(Object obj) { return ReflectUtils.getSignature((Method)obj).toString(); } }); e.load_arg(0); e.invoke_virtual(Constants.TYPE_OBJECT, TO_STRING); signatureSwitchHelper(e, signatures); e.end_method(); }
CollectionUtils.filter(methods, vp); CollectionUtils.filter(methods, new DuplicatesPredicate()); List constructors = new ArrayList(Arrays.asList(type.getDeclaredConstructors())); CollectionUtils.filter(constructors, vp); List info = CollectionUtils.transform(constructors, MethodInfoTransformer.getInstance()); EmitUtils.constructor_switch(e, info, new GetIndexCallback(e, info)); e.end_method();
private void emitIndexByClassArray(List methods) { CodeEmitter e = begin_method(Constants.ACC_PUBLIC, METHOD_GET_INDEX, null); if (methods.size() > TOO_MANY_METHODS) { // hack for big classes List signatures = CollectionUtils.transform(methods, new Transformer() { public Object transform(Object obj) { String s = ReflectUtils.getSignature((Method)obj).toString(); return s.substring(0, s.lastIndexOf(')') + 1); } }); e.load_args(); e.invoke_static(FAST_CLASS, GET_SIGNATURE_WITHOUT_RETURN_TYPE); signatureSwitchHelper(e, signatures); } else { e.load_args(); List info = CollectionUtils.transform(methods, MethodInfoTransformer.getInstance()); EmitUtils.method_switch(e, info, new GetIndexCallback(e, info)); } e.end_method(); }
protected Method[] getMethods(Class type) { List methods = new ArrayList(Arrays.asList(type.getMethods())); CollectionUtils.filter(methods, new RejectModifierPredicate(Modifier.FINAL | Modifier.STATIC)); return (Method[])methods.toArray(new Method[methods.size()]); } }
private static void stringSwitchHelper(final CodeEmitter e, List strings, final ObjectSwitchCallback callback, final Label def, final Label end, final int index) throws Exception { final int len = ((String)strings.get(0)).length(); final Map buckets = CollectionUtils.bucket(strings, new Transformer() { public Object transform(Object value) { return new Integer(((String)value).charAt(index)); } }); e.dup(); e.push(index); e.invoke_virtual(Constants.TYPE_STRING, STRING_CHAR_AT); e.process_switch(getSwitchKeys(buckets), new ProcessSwitchCallback() { public void processCase(int key, Label ignore_end) throws Exception { List bucket = (List)buckets.get(new Integer(key)); if (index + 1 == len) { e.pop(); callback.processCase(bucket.get(0), end); } else { stringSwitchHelper(e, bucket, callback, def, end, index + 1); } } public void processDefault() { e.goTo(def); } }); }
CollectionUtils.filter(methods, vp); CollectionUtils.filter(methods, new DuplicatesPredicate()); List constructors = new ArrayList(Arrays.asList(type.getDeclaredConstructors())); CollectionUtils.filter(constructors, vp); List info = CollectionUtils.transform(constructors, MethodInfoTransformer.getInstance()); EmitUtils.constructor_switch(e, info, new GetIndexCallback(e, info)); e.end_method();
private void emitIndexBySignature(List methods) { CodeEmitter e = begin_method(Constants.ACC_PUBLIC, SIGNATURE_GET_INDEX, null); List signatures = CollectionUtils.transform(methods, new Transformer() { public Object transform(Object obj) { return ReflectUtils.getSignature((Method)obj).toString(); } }); e.load_arg(0); e.invoke_virtual(Constants.TYPE_OBJECT, TO_STRING); signatureSwitchHelper(e, signatures); e.end_method(); }
final Map indexes = new HashMap(); final Map originalModifiers = new HashMap(); final Map positions = CollectionUtils.getIndexMap(methods); final Map declToBridge = new HashMap();
/** * Filter the list of constructors from the superclass. The * constructors which remain will be included in the generated * class. The default implementation is to filter out all private * constructors, but subclasses may extend Enhancer to override this * behavior. * @param sc the superclass * @param constructors the list of all declared constructors from the superclass * @throws IllegalArgumentException if there are no non-private constructors */ protected void filterConstructors(Class sc, List constructors) { CollectionUtils.filter(constructors, new VisibilityPredicate(sc, true)); if (constructors.size() == 0) throw new IllegalArgumentException("No visible constructors in " + sc); }
private static void member_helper_size(final CodeEmitter e, List members, final ObjectSwitchCallback callback, final ParameterTyper typer, final Label def, final Label end) throws Exception { final Map buckets = CollectionUtils.bucket(members, new Transformer() { public Object transform(Object value) { return new Integer(typer.getParameterTypes((MethodInfo)value).length); } }); e.dup(); e.arraylength(); e.process_switch(EmitUtils.getSwitchKeys(buckets), new ProcessSwitchCallback() { public void processCase(int key, Label dontUseEnd) throws Exception { List bucket = (List)buckets.get(new Integer(key)); member_helper_type(e, bucket, callback, typer, def, end, new BitSet()); } public void processDefault() throws Exception { e.goTo(def); } }); }
CollectionUtils.filter(methods, vp); CollectionUtils.filter(methods, new DuplicatesPredicate()); List constructors = new ArrayList(Arrays.asList(type.getDeclaredConstructors())); CollectionUtils.filter(constructors, vp); List info = CollectionUtils.transform(constructors, MethodInfoTransformer.getInstance()); EmitUtils.constructor_switch(e, info, new GetIndexCallback(e, info)); e.end_method();
private void emitIndexByClassArray(List methods) { CodeEmitter e = begin_method(Constants.ACC_PUBLIC, METHOD_GET_INDEX, null); if (methods.size() > TOO_MANY_METHODS) { // hack for big classes List signatures = CollectionUtils.transform(methods, new Transformer() { public Object transform(Object obj) { String s = ReflectUtils.getSignature((Method)obj).toString(); return s.substring(0, s.lastIndexOf(')') + 1); } }); e.load_args(); e.invoke_static(FAST_CLASS, GET_SIGNATURE_WITHOUT_RETURN_TYPE); signatureSwitchHelper(e, signatures); } else { e.load_args(); List info = CollectionUtils.transform(methods, MethodInfoTransformer.getInstance()); EmitUtils.method_switch(e, info, new GetIndexCallback(e, info)); } e.end_method(); }
final Map indexes = new HashMap(); final Map originalModifiers = new HashMap(); final Map positions = CollectionUtils.getIndexMap(methods);
/** * Filter the list of constructors from the superclass. The * constructors which remain will be included in the generated * class. The default implementation is to filter out all private * constructors, but subclasses may extend Enhancer to override this * behavior. * @param sc the superclass * @param constructors the list of all declared constructors from the superclass * @throws IllegalArgumentException if there are no non-private constructors */ protected void filterConstructors(Class sc, List constructors) { CollectionUtils.filter(constructors, new VisibilityPredicate(sc, true)); if (constructors.size() == 0) throw new IllegalArgumentException("No visible constructors in " + sc); }
private static void member_helper_size(final CodeEmitter e, List members, final ObjectSwitchCallback callback, final ParameterTyper typer, final Label def, final Label end) throws Exception { final Map buckets = CollectionUtils.bucket(members, new Transformer() { public Object transform(Object value) { return new Integer(typer.getParameterTypes((MethodInfo)value).length); } }); e.dup(); e.arraylength(); e.process_switch(EmitUtils.getSwitchKeys(buckets), new ProcessSwitchCallback() { public void processCase(int key, Label dontUseEnd) throws Exception { List bucket = (List)buckets.get(new Integer(key)); member_helper_type(e, bucket, callback, typer, def, end, new BitSet()); } public void processDefault() throws Exception { e.goTo(def); } }); }
CollectionUtils.filter(methods, vp); CollectionUtils.filter(methods, new DuplicatesPredicate()); List constructors = new ArrayList(Arrays.asList(type.getDeclaredConstructors())); CollectionUtils.filter(constructors, vp); List info = CollectionUtils.transform(constructors, MethodInfoTransformer.getInstance()); EmitUtils.constructor_switch(e, info, new GetIndexCallback(e, info)); e.end_method();