Uploaded image for project: 'Spring Roo'
  1. Spring Roo
  2. ROO-37

Use ...valueOf factory method instead of new if applicable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Trivial
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.0.0.M1
    • Component/s: @ CORE, TESTING, WEB MVC
    • Labels:
      None

      Description

      The DataOnDemandMetadata class (and possibly others) creates code using new WrapperClass(...), e.g.:

      } else if (field.getFieldType().equals(new JavaType(Boolean.class.getName()))) {
      initializer = "new Boolean(true)";
      } else if (field.getFieldType().equals(new JavaType(Integer.class.getName()))) {
      initializer = "new Integer(index)";
      }

      This may cause space and time overhead by creating multiple objects for the same value. Java 1.5 features a valueOf factory method for all primitive wrapper types and encourages developers to use this method instead of the constructors.

        Attachments

          Activity

            People

            • Assignee:
              balex Ben Alex
              Reporter:
              nd Andreas Hartl
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: