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

Component.getBehaviors() can be implemented slightly more efficiently

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Trivial
    • Resolution: Fixed
    • Affects Version/s: 6.8.0
    • Fix Version/s: 6.9.0, 7.0.0-M1
    • Component/s: wicket
    • Labels:

      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

            People

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

              Dates

              • Created:
                Updated:
                Resolved: