Top Description Fields Constructors Methods
net.bytebuddy.matcher

public Class FailSafeMatcher<T>

extends ElementMatcher.Junction.AbstractBase<T>
Class Inheritance
Annotations
@Enhance
Type Parameters
<T>
The type of the matched entity.
Imports
net.bytebuddy.build.HashCodeAndEqualsPlugin, net.bytebuddy.utility.nullability.MaybeNull

A fail-safe matcher catches exceptions that are thrown by a delegate matcher and returns an alternative value.

Field Summary

Modifier and TypeField and Description
private final boolean
fallback

The fallback value in case of an exception.

private final ElementMatcher<? super T>
matcher

The delegate matcher that might throw an exception.

Constructor Summary

AccessConstructor and Description
public
FailSafeMatcher(ElementMatcher<? super T>
The delegate matcher that might throw an exception.
matcher
,
boolean
The fallback value in case of an exception.
fallback
)

Creates a new fail-safe element matcher.

Method Summary

Modifier and TypeMethod and Description
public boolean
matches(T
The instance to be matched or null.
target
)

Implements net.bytebuddy.matcher.ElementMatcher.matches.

Matches a target against this element matcher.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from net.bytebuddy.matcher.ElementMatcher.Junction.AbstractBase:
andor

Field Detail

fallbackback to summary
private final boolean fallback

The fallback value in case of an exception.

matcherback to summary
private final ElementMatcher<? super T> matcher

The delegate matcher that might throw an exception.

Constructor Detail

FailSafeMatcherback to summary
public FailSafeMatcher(ElementMatcher<? super T> matcher, boolean fallback)

Creates a new fail-safe element matcher.

Parameters
matcher:ElementMatcher<? super T>

The delegate matcher that might throw an exception.

fallback:boolean

The fallback value in case of an exception.

Method Detail

matchesback to summary
public boolean matches(T target)

Implements net.bytebuddy.matcher.ElementMatcher.matches.

Doc from net.bytebuddy.matcher.ElementMatcher.matches.

Matches a target against this element matcher.

Parameters
target:T

The instance to be matched or null.

Returns:boolean

true if the given element is matched by this matcher or false otherwise.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override