Uploaded image for project: 'Hibernate Search'
  1. HSEARCH-3295

Search 6 groundwork - Invert the syntax of accessors

    Details

    • Type: Task
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.0.0.Alpha3
    • Component/s: mapper-pojo
    • Labels:
      None

      Description

      Use a more intuitive syntax, where methods are called on the document element being modified instead of the accessors.

      The discussion originated from a concern that the syntax borrowalsObjectFieldAccessor.add( target ) was not very clear, especially not to new users. A few solutions were mentioned, one of which was renaming add() to addTo or create, and another was to invert the syntax of accessors, which may feel more "natural".

      See https://github.com/hibernate/hibernate-search-6-poc/commit/f07d3c2a5278c8c1baaa32ef803e57d4d6653b79:

      This:

      DocumentElement borrowalsObject = borrowalsObjectFieldAccessor.add( target );			
      shortTermBorrowalCountAccessor.write( borrowalsObject, shortTermBorrowalCount );
      

      Would become this:

      DocumentElement borrowalsObject = target.addNew( borrowalsObjectFieldReference );
      borrowalsObject.add( shortTermBorrowalCountReference, shortTermBorrowalCount );
      

      We may want to do the same for entity accessors, to be consistent.

      Note that in order for this to make sense, we would have to rename the "accessor" to a "reference" or some similar term expressing the fact that this object is "passive" by nature (on contrary to an "accessor").

        Attachments

          Issue links

            Activity

              People

              • Assignee:
                yrodiere Yoann Rodière
                Reporter:
                yrodiere Yoann Rodière
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: