private String resolveTypeDiscriminatorForBackReference(Member m) { Method me = ReflectionUtils.findMethod( m.getDeclaringClass(), "get" + firstCharToUpperCase(m.getName())); if (me != null) { return resolveTypeDiscriminator(resolveReturnType(me)); } return ""; }
private void generateSetBasedDocRefView( Map<String, org.ektorp.support.DesignDocument.View> views, Member me, DocumentReferences referenceMetaData) { String fieldName = firstCharToLowerCase(me.getName()); String orderBy = referenceMetaData.orderBy(); String backRef = referenceMetaData.backReference(); if (backRef.length() == 0) { throw new ViewGenerationException( String.format( "The DocumentReferences annotation in %s must specify a backReference", me.getDeclaringClass())); } String viewName = NameConventions.backReferenceViewName(fieldName); String typeDiscriminator = resolveTypeDiscriminatorForBackReference(me); if (orderBy.length() > 0) { views.put( viewName, generateDocRefsAsSetWithOrderByView(backRef, fieldName, orderBy, typeDiscriminator)); } else { views.put(viewName, generateDocRefsAsSetView(backRef, fieldName, typeDiscriminator)); } }