Class ConstructorExtension

java.lang.Object
tools.mdsd.jamopp.model.java.extensions.members.ConstructorExtension

public final class ConstructorExtension extends Object
Extension providing utility methods for the the Constructor meta model class.
  • Method Details

    • isBetterConstructorForCall

      public static boolean isBetterConstructorForCall(Constructor constructor, Constructor other, NewConstructorCall call)
      Returns true if the given Constructor co is a better match for the given constructor call than Constructor other. Possible Result:
      1. other is perfect match: co can not be better
      2. other is weak match: true only if co is perfect match
      3. other does not match: True only if co is at least weak match
      Parameters:
      constructor - The constructor to check if it is better.
      other - The existing constructor to compare with.
      call - The call to check for.
      Returns:
      True only if the new Constructor co is better than the other one.
    • isConstructorForCall

      public static boolean isConstructorForCall(Constructor constructor, NewConstructorCall call, boolean needsPerfectMatch)
      Check if a constructor element is valid for a constructor call. Note, this method has been originally copied from the MethodExtension class as the behavior is nearly the same, but Constructor and Method have no common super type. The only difference in the implementation is the check of the return type. Constructors must return the exact type of the classifier they are member of. General methods can have an arbitrary return type. The latter is checked by the MethodExtension class as part of the "weak match" check in the isBetterMethodForCall check. For the constructor, the return type is a hard criteria and thus checked as part of the general isConstructorForCall(Constructor, NewConstructorCall, boolean).
      Parameters:
      constructor - The constructor to check.
      call - The call to check for.
      needsPerfectMatch - Flag how to handle parameters with variable argument (array) length
      Returns:
      True if the constructor is valid for the call.