# Class SmiObjectJsonMatcher

java.lang.Object
com.snmp4j.smi.util.json.SmiObjectJsonMatcher

All Implemented Interfaces:
  `SmiObjectFilter<SmiObject>`

public class SmiObjectJsonMatcher extends Object implements SmiObjectFilter<SmiObject>
Matcher class for comparing JSON generated by SmiObjectJsonConverter against a pattern JSON that contains regular expressions for field values.

Since:
  2.0
Version:
  2.0
Author:
  Frank Fock

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `SmiObjectJsonMatcher(String patternJsonString)`
  Creates a new matcher with the given pattern JSON string.
  `SmiObjectJsonMatcher(String patternJsonString, boolean strictMode)`
  Creates a new matcher with the given pattern JSON string.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `List<String>`
  `getMatchErrors()`
  Gets the list of match errors from the last match operation.
  `String`
  `getMatchErrorsAsString()`
  Gets a formatted string of all match errors.
  `boolean`
  `matches(SmiObject smiObject)`
  Matches a SmiObject against the pattern by first converting it to JSON.
  `boolean`
  `matches(String actualJsonString)`
  Matches a JSON string generated by SmiObjectJsonConverter against the pattern.
  `boolean`
  `passesFilter(SmiObject smiObject)`
  Determines if the supplied smiObject passes the filter or not.
  `boolean`
  `passesFilter(SmiType smiType)`
  Determines if the given `SmiType` generally passes this filter.
  `static boolean`
  `quickMatch(String patternJson, SmiObject smiObject)`
  Convenience method to create a matcher and match in one call.
  `static boolean`
  `quickMatch(String patternJson, String actualJson)`
  Convenience method to create a matcher and match JSON strings in one call.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### SmiObjectJsonMatcher

    public SmiObjectJsonMatcher(String patternJsonString)
    Creates a new matcher with the given pattern JSON string.
    Parameters:
      `patternJsonString` - JSON string containing regex patterns for matching
    Throws:
      `IllegalArgumentException` - if the pattern JSON is invalid

  - ### SmiObjectJsonMatcher

    public SmiObjectJsonMatcher(String patternJsonString, boolean strictMode)
    Creates a new matcher with the given pattern JSON string.
    Parameters:
      `patternJsonString` - JSON string containing regex patterns for matching
      `strictMode` - if true, all fields in actual JSON must be present in a pattern
    Throws:
      `IllegalArgumentException` - if the pattern JSON is invalid

- ## Method Details

  - ### matches

    public boolean matches(SmiObject smiObject)
    Matches a SmiObject against the pattern by first converting it to JSON.
    Parameters:
      `smiObject` - the SmiObject to match
    Returns:
      true if the object matches the pattern, false otherwise

  - ### matches

    public boolean matches(String actualJsonString)
    Matches a JSON string generated by SmiObjectJsonConverter against the pattern.
    Parameters:
      `actualJsonString` - the actual JSON string to match
    Returns:
      true if the JSON matches the pattern, false otherwise

  - ### getMatchErrors

    public List<String> getMatchErrors()
    Gets the list of match errors from the last match operation.
    Returns:
      list of error messages explaining why the match failed

  - ### getMatchErrorsAsString

    public String getMatchErrorsAsString()
    Gets a formatted string of all match errors.
    Returns:
      formatted error string

  - ### quickMatch

    public static boolean quickMatch(String patternJson, SmiObject smiObject)
    Convenience method to create a matcher and match in one call.
    Parameters:
      `patternJson` - JSON pattern string with regex values
      `smiObject` - SmiObject to match
    Returns:
      true if matches, false otherwise

  - ### quickMatch

    public static boolean quickMatch(String patternJson, String actualJson)
    Convenience method to create a matcher and match JSON strings in one call.
    Parameters:
      `patternJson` - JSON pattern string with regex values
      `actualJson` - actual JSON string to match
    Returns:
      true if matches, false otherwise

  - ### passesFilter

    public boolean passesFilter(SmiObject smiObject)
    Description copied from interface: `SmiObjectFilter`
    Determines if the supplied smiObject passes the filter or not.
    Specified by:
      `passesFilter` in interface `SmiObjectFilter<SmiObject>`
    Parameters:
      `smiObject` - the smiObject to check.
    Returns:
      `true` if smiObject passes the filter or `false` otherwise.

  - ### passesFilter

    public boolean passesFilter(SmiType smiType)
    Description copied from interface: `SmiObjectFilter`
    Determines if the given `SmiType` generally passes this filter. This method is called for performance optimization before `SmiObjectFilter.passesFilter(SmiObject)`.
    Specified by:
      `passesFilter` in interface `SmiObjectFilter<SmiObject>`
    Parameters:
      `smiType` - the SMI object type.
    Returns:
      `true` if smiObjects of smiType passes the filter or `false` otherwise.