Class ConstructorExtension
java.lang.Object
tools.mdsd.jamopp.model.java.extensions.members.ConstructorExtension
Extension providing utility methods for the the Constructor meta model class.
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
isBetterConstructorForCall
(Constructor constructor, Constructor other, NewConstructorCall call) Returnstrue
if the givenConstructor
co
is a better match for the given constructor call thanConstructor
other
.static boolean
isConstructorForCall
(Constructor constructor, NewConstructorCall call, boolean needsPerfectMatch) Check if a constructor element is valid for a constructor call.
-
Method Details
-
isBetterConstructorForCall
public static boolean isBetterConstructorForCall(Constructor constructor, Constructor other, NewConstructorCall call) Returnstrue
if the givenConstructor
co
is a better match for the given constructor call thanConstructor
other
. Possible Result:other
is perfect match:co
can not be betterother
is weak match: true only ifco
is perfect matchother
does not match: True only ifco
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 generalisConstructorForCall(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.
-