Class FuzzyMethodContract

All Implemented Interfaces:
Comparable<AbstractFuzzyMatcher<MethodInfo>>

public class FuzzyMethodContract extends AbstractFuzzyMember<MethodInfo>
Represents a contract for matching methods or constructors.
Author:
Kristian
  • Method Details

    • newBuilder

      public static FuzzyMethodContract.Builder newBuilder()
      Return a method contract builder.
      Returns:
      Method contract builder.
    • getReturnMatcher

      public AbstractFuzzyMatcher<Class<?>> getReturnMatcher()
      Retrieve the class matcher for the return type.
      Returns:
      Class matcher for the return type.
    • getParamMatchers

      public com.google.common.collect.ImmutableList<com.comphenix.protocol.reflect.fuzzy.FuzzyMethodContract.ParameterClassMatcher> getParamMatchers()
      Retrieve an immutable list of every parameter matcher for this method.
      Returns:
      Immutable list of every parameter matcher.
    • getExceptionMatchers

      public List<com.comphenix.protocol.reflect.fuzzy.FuzzyMethodContract.ParameterClassMatcher> getExceptionMatchers()
      Retrieve an immutable list of every exception matcher for this method.
      Returns:
      Immutable list of every exception matcher.
    • getParamCount

      public Integer getParamCount()
      Retrieve the expected parameter count for this method.
      Returns:
      Expected parameter count, or NULL if anyting goes.
    • prepareBuild

      protected void prepareBuild()
      Description copied from class: AbstractFuzzyMember
      Called before a builder is building a member and copying its state.

      Use this to prepare any special values.

      Overrides:
      prepareBuild in class AbstractFuzzyMember<MethodInfo>
    • isMatch

      public boolean isMatch(MethodInfo value, Object parent)
      Description copied from class: AbstractFuzzyMatcher
      Determine if the given value is a match.
      Overrides:
      isMatch in class AbstractFuzzyMember<MethodInfo>
      Parameters:
      value - - the value to match.
      parent - - the parent container, or NULL if this value is the root.
      Returns:
      TRUE if it is a match, FALSE otherwise.
    • calculateRoundNumber

      protected int calculateRoundNumber()
      Description copied from class: AbstractFuzzyMatcher
      Calculate the round number indicating when this matcher should be applied.

      Matchers with a lower round number are applied before matchers with a higher round number.

      By convention, this round number should be negative, except for zero in the case of a matcher that accepts any value. A good implementation should return the inverted tree depth (class hierachy) of the least specified type used in the matching. Thus Integer will have a lower round number than Number.

      Overrides:
      calculateRoundNumber in class AbstractFuzzyMember<MethodInfo>
      Returns:
      A number (positive or negative) that is used to order matchers.
    • getKeyValueView

      protected Map<String,​Object> getKeyValueView()
      Description copied from class: AbstractFuzzyMember
      Generate a view of this matcher as a key-value map.

      Used by AbstractFuzzyMember.toString() to print a representation of this object.

      Overrides:
      getKeyValueView in class AbstractFuzzyMember<MethodInfo>
      Returns:
      A modifiable key-value view.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class AbstractFuzzyMember<MethodInfo>
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class AbstractFuzzyMember<MethodInfo>