Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-5233

Component.getBehaviors() can be implemented slightly more efficiently

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Trivial
    • Resolution: Fixed
    • 6.8.0
    • 6.9.0, 7.0.0-M1
    • wicket

    Description

      Component.getBehaviors() is implemented as
      "return getBehaviors(Behavior.class);"
      but can be
      "return getBehaviors(null);"

      As mentioned in getBehaviors(Class type) documentation: "The type or null for all". The handling code in Behaviors.getBehaviors method is following:

      if (obj != null && obj instanceof Behavior)
      {
      if (type == null || type.isAssignableFrom(obj.getClass()))

      { subset.add((M)obj); }

      }

      When called with "null" parameter, only the first condition of inner "if" is tested. If called with Behavior.class, all conditions has to be evaluated and you call "obj instanceof Behavior" twice in fact (because "Behavior.class.isAssignableFrom(obj.getClass())" is equivalent to "obj instanceof Behavior").

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            mgrigorov Martin Tzvetanov Grigorov
            otah Ota Hauptmann
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment