Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • Trac Trac
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Issues 246
    • Issues 246
    • List
    • Boards
    • Service Desk
    • Milestones
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value stream
  • Wiki
    • Wiki
  • Activity
  • Create a new issue
  • Issue Boards
Collapse sidebar
  • Legacy
  • TracTrac
  • Issues
  • #17824

Closed (moved)
(moved)
Open
Created Dec 11, 2015 by iwakeh iwakeh@iwakeh

switch on string instead of many if-else with String comparison

example from BridgeNetworkStatusImpl (there are many more and longer ones):

  switch(keyword){
      case "published":
        this.parsePublishedLine(line, parts);
      case "flag-thresholds":
        this.parseFlagThresholdsLine(line, parts);
   } 
   if (this.failUnrecognizedDescriptorLines) {
      throw new DescriptorParseException("Unrecognized line '" + line
            + "' in bridge network status.");
   } else {
      if (this.unrecognizedLines == null) {
         this.unrecognizedLines = new ArrayList<String>();
     }
...

instead of

  if (keyword.equals("published")) {
        this.parsePublishedLine(line, parts);
      } else if (keyword.equals("flag-thresholds")) {
        this.parseFlagThresholdsLine(line, parts);
      } else if (this.failUnrecognizedDescriptorLines) {
        throw new DescriptorParseException("Unrecognized line '" + line
            + "' in bridge network status.");
      } else {
        if (this.unrecognizedLines == null) {
          this.unrecognizedLines = new ArrayList<String>();
        }
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking