Skip to main content

Class DocumentNoteUtilities example code

Comments

5 comments

  • Amy Wilson

    Hi there.  It sounds like this documentation is incorrect, but I'm having trouble tracking it down. Whereabouts is this documentation?  Is this the latest version (6.0.5) of the plugin development kit?

    0
  • Jerry Cooper

    I get the same result with plugin SDK 6.05 or 6.03.

    The example code is at ...

    /geneious-devkit/geneious-6.0.5-devkit/api-javadoc/com/biomatters/geneious/publicapi/documents/DocumentNoteUtilities.html

    0
  • Amy Wilson

    There's code that looks similar to what you've got up there in DocumentNoteUtilities.html, but the first 3 lines are different.  They read:

    java.util.List noteFields = new ArrayList();
        String fieldCode = "Field1";
        noteFields.add(DocumentNoteField.createTextNoteField("Field no.1", "The first field", fieldCode, Collections.emptyList(), false));

    Are the first 3 lines an adaptation of the code you have made yourself?  If so, you can make it compile by adding the <Constraint> back in on line 2.

    0
  • Jerry Cooper

    OK. It works if I make the cast ...

        String fieldCode = "Field1";
        noteFields.add(DocumentNoteField.createTextNoteField("Field no.1", "The first field", fieldCode, (List) Collections.emptyList(), false));

            

    0
  • Amy Wilson

    The method takes a list of constraints.  When it just said Collections.emptyList(), it was creating a list of Objects.  With Collections.<Constraint>emptyList() as in the example, it creates a list of Constraints.  With (List)Collections.emptyList(), it creates a list of unknown type.

    Although using (List)Collections.emptyList() won't cause problems in this case, I suggest you get into the habit of using the form Collections.<Constraint>emptyList() because in other similar situations this will avoid bugs.

    0

Please sign in to leave a comment.