public MethodSignature getSignature() { return new MethodSignature(owner, name, desc); }
private void insertNLinkMethod(String className, String methodName, String returnType, MetamodelUtilAttribute pluralAttribute) { MethodSignature methodSig = new MethodSignature( className, methodName, returnType); nLinkMethods.put(methodSig, pluralAttribute); }
private void insertFieldMethod(String className, String methodName, String altMethodName, String returnType, MetamodelUtilAttribute fieldAttribute) { MethodSignature methodSig = new MethodSignature( className, methodName, returnType); fieldMethods.put(methodSig, fieldAttribute); if (altMethodName != null) { MethodSignature altMethodSig = new MethodSignature( className, altMethodName, returnType); fieldMethods.put(altMethodSig, fieldAttribute); } }
protected void registerEnum(Class<?> fieldJavaType) { // Record the enum, and mark equals() using the enum as safe String enumTypeName = Type.getInternalName(fieldJavaType); enums.put(enumTypeName, Arrays.asList(((Class<Enum<?>>)fieldJavaType).getEnumConstants())); MethodSignature eqMethod = new MethodSignature(enumTypeName, "equals", "(Ljava/lang/Object;)Z"); comparisonMethods.put(eqMethod, TypedValue.ComparisonValue.ComparisonOp.eq); comparisonMethodsWithObjectEquals.put(eqMethod, TypedValue.ComparisonValue.ComparisonOp.eq); safeMethods.add(eqMethod); }
public boolean equals(String owner, String name, String desc) { return equals(new MethodSignature(owner, name, desc)); }
public static MethodSignature fromMethod(Method m) { return new MethodSignature( Type.getInternalName(m.getDeclaringClass()), m.getName(), Type.getMethodDescriptor(m)); }
public static MethodSignature fromConstructor(Constructor<?> m) { return new MethodSignature( Type.getInternalName(m.getDeclaringClass()), "<init>", Type.getConstructorDescriptor(m)); } }
private void insertCustomTupleIndexGetters(Method...tupleIndexReaders) { if (tupleIndexReaders != null) { int idx = 1; for (Method tupleIndex: tupleIndexReaders) { if (Modifier.isStatic(tupleIndex.getModifiers())) throw new IllegalArgumentException("Method for reading a value from a custom tuple must be a virtual method declared on the custom tuple class"); if (tupleIndex.getParameterCount() != 0) throw new IllegalArgumentException("Method for reading a value from a custom tuple must not take any arguments"); MethodSignature sig = new MethodSignature( org.jinq.rebased.org.objectweb.asm.Type.getInternalName(tupleIndex.getDeclaringClass()), tupleIndex.getName(), org.jinq.rebased.org.objectweb.asm.Type.getMethodDescriptor(tupleIndex)); customTupleAccessorMethods.put(sig, idx); safeMethods.add(sig); idx++; } } }
/** * The Hibernate metamodel seems to hold incorrect information about * composite keys or entities that use other entities as keys or something. * This method provides a way for programmers to specify correct * information for those types of mappings. Note: this method does not handle * inherited methods properly (the method will always be attached to class that * the method was declared in). Use the alternate form of this method if you * want to register a method declared in a superclass. * @param m entity method that Jinq should rewrite into a field access for queries * @param fieldName name of the field that Jinq should use in queries when it encounters the method call * @param isPlural whether the method returns a single entity or a collection of them */ public void registerAssociationAttribute(Method m, String fieldName, boolean isPlural) { MetamodelUtilAttribute attrib = new MetamodelUtilAttribute(fieldName, true); metamodel.insertAssociationAttribute( new MethodSignature( org.jinq.rebased.org.objectweb.asm.Type.getInternalName(m.getDeclaringClass()), m.getName(), org.jinq.rebased.org.objectweb.asm.Type.getMethodDescriptor(m)), attrib, isPlural); }
/** * The Hibernate metamodel seems to hold incorrect information about * composite keys or entities that use other entities as keys or something. * This method provides a way for programmers to specify correct * information for those types of mappings. Note: this method does not handle * inherited methods properly (the method will always be attached to class that * the method was declared in). Use the alternate form of this method if you * want to register a method declared in a superclass. * @param m entity method that Jinq should rewrite into a field access for queries * @param fieldName name of the field that Jinq should use in queries when it encounters the method call * @param isPlural whether the method returns a single entity or a collection of them */ public void registerAssociationAttribute(Method m, String fieldName, boolean isPlural) { MetamodelUtilAttribute attrib = new MetamodelUtilAttribute(fieldName, true); metamodel.insertAssociationAttribute( new MethodSignature( Type.getInternalName(m.getDeclaringClass()), m.getName(), Type.getMethodDescriptor(m)), attrib, isPlural); }
private void findMetamodelGetters(Schema schema) { for (Table<?> table: schema.getTables()) { String recordClassName = Type.getInternalName(table.getRecordType()); for (Field<?> field: table.fields()) { String name = field.getName(); String getterName = "get" + name.substring(0, 1).toUpperCase() + name.substring(1).toLowerCase(); MethodSignature methodSig = new MethodSignature( recordClassName, getterName, Type.getMethodDescriptor(Type.getType(field.getType()))); fieldMethods.put(methodSig, field); } } }
/** * This is an alternate version of registerAssociationAttribute() that * allows you to manually register a method of a class that is declared in * a superclass. * @param m entity method that Jinq should rewrite into a field access for queries * @param methodClass the class that the method will be called against * @param fieldName name of the field that Jinq should use in queries when it encounters the method call * @param isPlural whether the method returns a single entity or a collection of them */ public void registerAssociationAttribute(Method m, Class<?> methodClass, String fieldName, boolean isPlural) { MetamodelUtilAttribute attrib = new MetamodelUtilAttribute(fieldName, true); metamodel.insertAssociationAttribute( new MethodSignature( Type.getInternalName(methodClass), m.getName(), Type.getMethodDescriptor(m)), attrib, isPlural); }
/** * This is an alternate version of registerAssociationAttribute() that * allows you to manually register a method of a class that is declared in * a superclass. * @param m entity method that Jinq should rewrite into a field access for queries * @param methodClass the class that the method will be called against * @param fieldName name of the field that Jinq should use in queries when it encounters the method call * @param isPlural whether the method returns a single entity or a collection of them */ public void registerAssociationAttribute(Method m, Class<?> methodClass, String fieldName, boolean isPlural) { MetamodelUtilAttribute attrib = new MetamodelUtilAttribute(fieldName, true); metamodel.insertAssociationAttribute( new MethodSignature( org.jinq.rebased.org.objectweb.asm.Type.getInternalName(methodClass), m.getName(), org.jinq.rebased.org.objectweb.asm.Type.getMethodDescriptor(m)), attrib, isPlural); }
MethodSignature sig = new MethodSignature(methodClass, methodName, methodSignature); Type [] argTypes = Type.getMethodType(sig.desc).getArgumentTypes(); MethodChecker checker = metamodel.getMethodChecker(isObjectEqualsSafe, isAllEqualsSafe, isCollectionContainsSafe);
for (int n = (isVirtualCall? 1:0); n < values.size(); n++) args.add((TypedValue)values.get(n)); MethodSignature sig = new MethodSignature(methodInsn.owner, methodInsn.name, methodInsn.desc); if (isVirtualCall)
MethodSignature sig = new MethodSignature( org.jinq.rebased.org.objectweb.asm.Type.getInternalName(entityClass), m.getName(),
private void findMetamodelGetters(Schema schema) { for (Table<?> table: schema.getTables()) { String recordClassName = Type.getInternalName(table.getRecordType()); for (Field<?> field: table.fields()) { String name = field.getName(); String getterName = "get" + name.substring(0, 1).toUpperCase() + name.substring(1).toLowerCase(); MethodSignature methodSig = new MethodSignature( recordClassName, getterName, Type.getMethodDescriptor(Type.getType(field.getType()))); fieldMethods.put(methodSig, field); } } }