/** * INTERNAL: * Return whether a map key this container policy represents is an attribute * @return */ public boolean isMapKeyAttribute(){ if (elementDescriptor != null && keyName != null){ DatabaseMapping mapping = elementDescriptor.getMappingForAttributeName(Helper.getAttributeNameFromMethodName(keyName)); if (mapping != null){ return mapping.isDirectToFieldMapping(); } } initializeKey(); if (keyField != null){ if (keyField.getClass().isPrimitive()){ return true; } } else if (keyMethod != null){ if (keyMethod.getClass().isPrimitive()){ return true; } } return false; }
/** * INTERNAL: * Return whether a map key this container policy represents is an attribute. */ @Override public boolean isMapKeyAttribute() { if (elementDescriptor != null && keyName != null){ DatabaseMapping mapping = elementDescriptor.getMappingForAttributeName(Helper.getAttributeNameFromMethodName(keyName)); if (mapping != null) { return mapping.isDirectToFieldMapping(); } } initializeKey(); if (keyField != null){ if (keyField.getClass().isPrimitive()){ return true; } } else if (keyMethod != null) { if (keyMethod.getClass().isPrimitive()) { return true; } } return false; }
/** * INTERNAL: * Return whether a map key this container policy represents is an attribute. */ @Override public boolean isMapKeyAttribute() { if (elementDescriptor != null && keyName != null){ DatabaseMapping mapping = elementDescriptor.getMappingForAttributeName(Helper.getAttributeNameFromMethodName(keyName)); if (mapping != null) { return mapping.isDirectToFieldMapping(); } } initializeKey(); if (keyField != null){ if (keyField.getClass().isPrimitive()){ return true; } } else if (keyMethod != null) { if (keyMethod.getClass().isPrimitive()) { return true; } } return false; }
public MetadataMethodVisitor(MetadataClass classMetadata, int access, String name, String desc, String signature, String[] exceptions) { super(Opcodes.ASM5); this.method = new MetadataMethod(MetadataAsmFactory.this, classMetadata); this.method.setName(name); this.method.setAttributeName(Helper.getAttributeNameFromMethodName(name)); this.method.setModifiers(access); this.method.setGenericType(processDescription(desc, true)); List<String> argumentNames = processDescription(signature, false); if (argumentNames != null && !argumentNames.isEmpty()) { this.method.setReturnType(argumentNames.get(argumentNames.size() - 1)); argumentNames.remove(argumentNames.size() - 1); this.method.setParameters(argumentNames); } }
accessor = m_mappingAccessors.get(Helper.getAttributeNameFromMethodName(fieldOrPropertyName));
/** * INTERNAL: * Return the DatabaseField that represents the key in a DirectMapMapping. MapContainerPolicy gets it fields from the reference descriptor * of the provided mappings. It uses its keyName to lookup the appropriate mapping and returns the field from * that mapping. */ @Override public DatabaseField getDirectKeyField(CollectionMapping baseMapping){ if (baseMapping == null){ return null; } ClassDescriptor descriptor = baseMapping.getReferenceDescriptor(); DatabaseMapping mapping = descriptor.getMappingForAttributeName(Helper.getAttributeNameFromMethodName(keyName)); if (mapping.isAbstractDirectMapping()){ return ((AbstractDirectMapping)mapping).getField(); } return null; }
/** * INTERNAL: * Return the DatabaseField that represents the key in a DirectMapMapping. MapContainerPolicy gets it fields from the reference descriptor * of the provided mappings. It uses its keyName to lookup the appropriate mapping and returns the field from * that mapping * @return */ public DatabaseField getDirectKeyField(CollectionMapping baseMapping){ if (baseMapping == null){ return null; } ClassDescriptor descriptor = baseMapping.getReferenceDescriptor(); DatabaseMapping mapping = descriptor.getMappingForAttributeName(Helper.getAttributeNameFromMethodName(keyName)); if (mapping.isAbstractDirectMapping()){ return ((AbstractDirectMapping)mapping).getField(); } return null; }
/** * INTERNAL: * Return the DatabaseField that represents the key in a DirectMapMapping. MapContainerPolicy gets it fields from the reference descriptor * of the provided mappings. It uses its keyName to lookup the appropriate mapping and returns the field from * that mapping. */ @Override public DatabaseField getDirectKeyField(CollectionMapping baseMapping){ if (baseMapping == null){ return null; } ClassDescriptor descriptor = baseMapping.getReferenceDescriptor(); DatabaseMapping mapping = descriptor.getMappingForAttributeName(Helper.getAttributeNameFromMethodName(keyName)); if (mapping.isAbstractDirectMapping()){ return ((AbstractDirectMapping)mapping).getField(); } return null; }
/** * INTERNAL: * Return all the fields in the key. MapContainerPolicy gets it fields from the reference descriptor * of the provided mappings. It uses its keyName to lookup the appropriate mapping and returns the fields from * that mapping * @return */ public List<DatabaseField> getAllFieldsForMapKey(CollectionMapping baseMapping){ if (baseMapping == null){ return null; } ClassDescriptor descriptor = baseMapping.getReferenceDescriptor(); if (keyName != null){ DatabaseMapping mapping = descriptor.getMappingForAttributeName(Helper.getAttributeNameFromMethodName(keyName)); return mapping.getFields(); } else { return descriptor.getPrimaryKeyFields(); } }
/** * INTERNAL: * Visit an executable and create a MetadataMethod object. */ @Override public MetadataMethod visitExecutable(ExecutableElement executableElement, MetadataClass metadataClass) { MetadataMethod method = new MetadataMethod(metadataClass.getMetadataFactory(), metadataClass); // Set the name. method.setName(executableElement.getSimpleName().toString()); // Set the attribute name. method.setAttributeName(Helper.getAttributeNameFromMethodName(method.getName())); // Set the modifiers. method.setModifiers(getModifiers(executableElement.getModifiers())); // Visit executable element for the parameters, return type and generic type. executableElement.asType().accept(typeVisitor, method); // Set the annotations. buildMetadataAnnotations(method, executableElement.getAnnotationMirrors()); // Handle multiple methods with the same name. MetadataMethod existing = metadataClass.getMethods().get(method.getName()); if (existing == null) { metadataClass.addMethod(method); } else { while (existing.getNext() != null) { existing = existing.getNext(); } existing.setNext(method); } return method; }
method.setAttributeName(Helper.getAttributeNameFromMethodName(method.getName()));