Groovy/Grails Contains with Lowercase











up vote
6
down vote

favorite
1












I want to check a list contains a specific string .



before checking all entries in list as well as sting should be in. lowercase



I tried like this



 def venueName = params.name
def venueNameLists = Venue.executeQuery("select name from Venue")
if(venueNameLists.toLowerCase().contains(venueName.toLowerCase())){
error = true;
log.debug("save :: duplicate name")
flash.message = "Venue name already exist";
render(view: "create", model: [venueInstance: new Venue(params)])
return
}


gives error



  No signature of method: java.util.ArrayList.toLowerCase() is applicable for argument types: () values: . Stacktrace follows:

groovy.lang.MissingMethodException: No signature of method: java.util.ArrayList.toLowerCase() is applicable for argument types: () values:









share|improve this question




























    up vote
    6
    down vote

    favorite
    1












    I want to check a list contains a specific string .



    before checking all entries in list as well as sting should be in. lowercase



    I tried like this



     def venueName = params.name
    def venueNameLists = Venue.executeQuery("select name from Venue")
    if(venueNameLists.toLowerCase().contains(venueName.toLowerCase())){
    error = true;
    log.debug("save :: duplicate name")
    flash.message = "Venue name already exist";
    render(view: "create", model: [venueInstance: new Venue(params)])
    return
    }


    gives error



      No signature of method: java.util.ArrayList.toLowerCase() is applicable for argument types: () values: . Stacktrace follows:

    groovy.lang.MissingMethodException: No signature of method: java.util.ArrayList.toLowerCase() is applicable for argument types: () values:









    share|improve this question


























      up vote
      6
      down vote

      favorite
      1









      up vote
      6
      down vote

      favorite
      1






      1





      I want to check a list contains a specific string .



      before checking all entries in list as well as sting should be in. lowercase



      I tried like this



       def venueName = params.name
      def venueNameLists = Venue.executeQuery("select name from Venue")
      if(venueNameLists.toLowerCase().contains(venueName.toLowerCase())){
      error = true;
      log.debug("save :: duplicate name")
      flash.message = "Venue name already exist";
      render(view: "create", model: [venueInstance: new Venue(params)])
      return
      }


      gives error



        No signature of method: java.util.ArrayList.toLowerCase() is applicable for argument types: () values: . Stacktrace follows:

      groovy.lang.MissingMethodException: No signature of method: java.util.ArrayList.toLowerCase() is applicable for argument types: () values:









      share|improve this question















      I want to check a list contains a specific string .



      before checking all entries in list as well as sting should be in. lowercase



      I tried like this



       def venueName = params.name
      def venueNameLists = Venue.executeQuery("select name from Venue")
      if(venueNameLists.toLowerCase().contains(venueName.toLowerCase())){
      error = true;
      log.debug("save :: duplicate name")
      flash.message = "Venue name already exist";
      render(view: "create", model: [venueInstance: new Venue(params)])
      return
      }


      gives error



        No signature of method: java.util.ArrayList.toLowerCase() is applicable for argument types: () values: . Stacktrace follows:

      groovy.lang.MissingMethodException: No signature of method: java.util.ArrayList.toLowerCase() is applicable for argument types: () values:






      java list grails groovy






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 9 '13 at 8:17

























      asked Jan 9 '13 at 8:11









      maaz

      1,349153980




      1,349153980
























          3 Answers
          3






          active

          oldest

          votes

















          up vote
          15
          down vote



          accepted










          I agree with aiolos: use constraints or try to find instance by name ignore case. But to fix this your way try *.(star-dot) operator:



          venueNameLists*.toLowerCase().contains(venueName.toLowerCase()) 





          share|improve this answer




























            up vote
            6
            down vote













            If you would like to check a duplicate entry before saving an element, use constraints on your domain class. Here you could use unique constraint or implement your own if you need it case insensitive.



            If you need to check it manually, try this:



            def venueWithNameFromParams = Venue.findByNameIlike(params.name) // ignore case
            if(venueWithNameFromParams){
            // venueName is in venueNameList
            }





            share|improve this answer






























              up vote
              0
              down vote













              If you were looking how to check if multiple strings contains a word, while ignoring case-sensitive, use (?i) on a regex of words.



              For example, the following will be positive condition:



              word = "YES"
              word.matches(/(?i)yes|ok|true/)





              share|improve this answer

















              • 1




                See how it works in this snippet: tpcg.io/tSzWFd
                – Noam Manos
                Nov 21 at 10:41











              Your Answer






              StackExchange.ifUsing("editor", function () {
              StackExchange.using("externalEditor", function () {
              StackExchange.using("snippets", function () {
              StackExchange.snippets.init();
              });
              });
              }, "code-snippets");

              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "1"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f14230789%2fgroovy-grails-contains-with-lowercase%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              15
              down vote



              accepted










              I agree with aiolos: use constraints or try to find instance by name ignore case. But to fix this your way try *.(star-dot) operator:



              venueNameLists*.toLowerCase().contains(venueName.toLowerCase()) 





              share|improve this answer

























                up vote
                15
                down vote



                accepted










                I agree with aiolos: use constraints or try to find instance by name ignore case. But to fix this your way try *.(star-dot) operator:



                venueNameLists*.toLowerCase().contains(venueName.toLowerCase()) 





                share|improve this answer























                  up vote
                  15
                  down vote



                  accepted







                  up vote
                  15
                  down vote



                  accepted






                  I agree with aiolos: use constraints or try to find instance by name ignore case. But to fix this your way try *.(star-dot) operator:



                  venueNameLists*.toLowerCase().contains(venueName.toLowerCase()) 





                  share|improve this answer












                  I agree with aiolos: use constraints or try to find instance by name ignore case. But to fix this your way try *.(star-dot) operator:



                  venueNameLists*.toLowerCase().contains(venueName.toLowerCase()) 






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jan 9 '13 at 9:01









                  Mr. Cat

                  2,91821224




                  2,91821224
























                      up vote
                      6
                      down vote













                      If you would like to check a duplicate entry before saving an element, use constraints on your domain class. Here you could use unique constraint or implement your own if you need it case insensitive.



                      If you need to check it manually, try this:



                      def venueWithNameFromParams = Venue.findByNameIlike(params.name) // ignore case
                      if(venueWithNameFromParams){
                      // venueName is in venueNameList
                      }





                      share|improve this answer



























                        up vote
                        6
                        down vote













                        If you would like to check a duplicate entry before saving an element, use constraints on your domain class. Here you could use unique constraint or implement your own if you need it case insensitive.



                        If you need to check it manually, try this:



                        def venueWithNameFromParams = Venue.findByNameIlike(params.name) // ignore case
                        if(venueWithNameFromParams){
                        // venueName is in venueNameList
                        }





                        share|improve this answer

























                          up vote
                          6
                          down vote










                          up vote
                          6
                          down vote









                          If you would like to check a duplicate entry before saving an element, use constraints on your domain class. Here you could use unique constraint or implement your own if you need it case insensitive.



                          If you need to check it manually, try this:



                          def venueWithNameFromParams = Venue.findByNameIlike(params.name) // ignore case
                          if(venueWithNameFromParams){
                          // venueName is in venueNameList
                          }





                          share|improve this answer














                          If you would like to check a duplicate entry before saving an element, use constraints on your domain class. Here you could use unique constraint or implement your own if you need it case insensitive.



                          If you need to check it manually, try this:



                          def venueWithNameFromParams = Venue.findByNameIlike(params.name) // ignore case
                          if(venueWithNameFromParams){
                          // venueName is in venueNameList
                          }






                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited May 23 '17 at 12:32









                          Community

                          11




                          11










                          answered Jan 9 '13 at 8:41









                          aiolos

                          3,6301525




                          3,6301525






















                              up vote
                              0
                              down vote













                              If you were looking how to check if multiple strings contains a word, while ignoring case-sensitive, use (?i) on a regex of words.



                              For example, the following will be positive condition:



                              word = "YES"
                              word.matches(/(?i)yes|ok|true/)





                              share|improve this answer

















                              • 1




                                See how it works in this snippet: tpcg.io/tSzWFd
                                – Noam Manos
                                Nov 21 at 10:41















                              up vote
                              0
                              down vote













                              If you were looking how to check if multiple strings contains a word, while ignoring case-sensitive, use (?i) on a regex of words.



                              For example, the following will be positive condition:



                              word = "YES"
                              word.matches(/(?i)yes|ok|true/)





                              share|improve this answer

















                              • 1




                                See how it works in this snippet: tpcg.io/tSzWFd
                                – Noam Manos
                                Nov 21 at 10:41













                              up vote
                              0
                              down vote










                              up vote
                              0
                              down vote









                              If you were looking how to check if multiple strings contains a word, while ignoring case-sensitive, use (?i) on a regex of words.



                              For example, the following will be positive condition:



                              word = "YES"
                              word.matches(/(?i)yes|ok|true/)





                              share|improve this answer












                              If you were looking how to check if multiple strings contains a word, while ignoring case-sensitive, use (?i) on a regex of words.



                              For example, the following will be positive condition:



                              word = "YES"
                              word.matches(/(?i)yes|ok|true/)






                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Nov 19 at 11:56









                              Noam Manos

                              5,56713040




                              5,56713040








                              • 1




                                See how it works in this snippet: tpcg.io/tSzWFd
                                – Noam Manos
                                Nov 21 at 10:41














                              • 1




                                See how it works in this snippet: tpcg.io/tSzWFd
                                – Noam Manos
                                Nov 21 at 10:41








                              1




                              1




                              See how it works in this snippet: tpcg.io/tSzWFd
                              – Noam Manos
                              Nov 21 at 10:41




                              See how it works in this snippet: tpcg.io/tSzWFd
                              – Noam Manos
                              Nov 21 at 10:41


















                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.





                              Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                              Please pay close attention to the following guidance:


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f14230789%2fgroovy-grails-contains-with-lowercase%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Costa Masnaga

                              Fotorealismo

                              Sidney Franklin