Package org.apache.commons.io.serialization

# Class ObjectStreamClassPredicate

java.lang.Object
org.apache.commons.io.serialization.ObjectStreamClassPredicate

All Implemented Interfaces:
  `Predicate<ObjectStreamClass>`

public class ObjectStreamClassPredicate extends Object implements Predicate<ObjectStreamClass>
A predicate (boolean-valued function) of one argument to accept and reject classes.

The reject list takes precedence over the accept list.

Since:
  2.18.0

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ObjectStreamClassPredicate()`
  Constructs a new instance.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `ObjectStreamClassPredicate`
  `accept(Class<?>... classes)`
  Accepts the specified classes for deserialization, unless they are otherwise rejected.
  `ObjectStreamClassPredicate`
  `accept(String... patterns)`
  Accepts the wildcard specified classes for deserialization, unless they are otherwise rejected.
  `ObjectStreamClassPredicate`
  `accept(Pattern pattern)`
  Accepts class names that match the supplied pattern for deserialization, unless they are otherwise rejected.
  `ObjectStreamClassPredicate`
  `accept(ClassNameMatcher matcher)`
  Accepts class names where the supplied ClassNameMatcher matches for deserialization, unless they are otherwise rejected.
  `ObjectStreamClassPredicate`
  `reject(Class<?>... classes)`
  Rejects the specified classes for deserialization, even if they are otherwise accepted.
  `ObjectStreamClassPredicate`
  `reject(String... patterns)`
  Rejects the wildcard specified classes for deserialization, even if they are otherwise accepted.
  `ObjectStreamClassPredicate`
  `reject(Pattern pattern)`
  Rejects class names that match the supplied pattern for deserialization, even if they are otherwise accepted.
  `ObjectStreamClassPredicate`
  `reject(ClassNameMatcher m)`
  Rejects class names where the supplied ClassNameMatcher matches for deserialization, even if they are otherwise accepted.
  `boolean`
  `test(ObjectStreamClass objectStreamClass)`
  Tests that the ObjectStreamClass conforms to requirements.
  `boolean`
  `test(String name)`
  Tests that the class name conforms to requirements.

  ### Methods inherited from class java.lang.Object

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

  ### Methods inherited from interface java.util.function.Predicate

  `and, negate, or`

- ## Constructor Details

  - ### ObjectStreamClassPredicate

    public ObjectStreamClassPredicate()
    Constructs a new instance.

- ## Method Details

  - ### accept

    public ObjectStreamClassPredicate accept(Class<?>... classes)
    Accepts the specified classes for deserialization, unless they are otherwise rejected.

    The reject list takes precedence over the accept list.

    Parameters:
      `classes` - Classes to accept.
    Returns:
      this object.

  - ### accept

    public ObjectStreamClassPredicate accept(ClassNameMatcher matcher)
    Accepts class names where the supplied ClassNameMatcher matches for deserialization, unless they are otherwise rejected.

    The reject list takes precedence over the accept list.

    Parameters:
      `matcher` - a class name matcher to accept objects.
    Returns:
      `this` instance.

  - ### accept

    public ObjectStreamClassPredicate accept(Pattern pattern)
    Accepts class names that match the supplied pattern for deserialization, unless they are otherwise rejected.

    The reject list takes precedence over the accept list.

    Parameters:
      `pattern` - a Pattern for compiled regular expression.
    Returns:
      `this` instance.

  - ### accept

    public ObjectStreamClassPredicate accept(String... patterns)
    Accepts the wildcard specified classes for deserialization, unless they are otherwise rejected.

    The reject list takes precedence over the accept list.

    Parameters:
      `patterns` - Wildcard file name patterns as defined by `FilenameUtils.wildcardMatch`
    Returns:
      `this` instance.

  - ### reject

    public ObjectStreamClassPredicate reject(Class<?>... classes)
    Rejects the specified classes for deserialization, even if they are otherwise accepted.

    The reject list takes precedence over the accept list.

    Parameters:
      `classes` - Classes to reject.
    Returns:
      `this` instance.

  - ### reject

    public ObjectStreamClassPredicate reject(ClassNameMatcher m)
    Rejects class names where the supplied ClassNameMatcher matches for deserialization, even if they are otherwise accepted.

    The reject list takes precedence over the accept list.

    Parameters:
      `m` - the matcher to use.
    Returns:
      `this` instance.

  - ### reject

    public ObjectStreamClassPredicate reject(Pattern pattern)
    Rejects class names that match the supplied pattern for deserialization, even if they are otherwise accepted.

    The reject list takes precedence over the accept list.

    Parameters:
      `pattern` - standard Java regexp.
    Returns:
      `this` instance.

  - ### reject

    public ObjectStreamClassPredicate reject(String... patterns)
    Rejects the wildcard specified classes for deserialization, even if they are otherwise accepted.

    The reject list takes precedence over the accept list.

    Parameters:
      `patterns` - Wildcard file name patterns as defined by `FilenameUtils.wildcardMatch`
    Returns:
      `this` instance.

  - ### test

    public boolean test(ObjectStreamClass objectStreamClass)
    Tests that the ObjectStreamClass conforms to requirements.

    The reject list takes precedence over the accept list.

    Specified by:
      `test` in interface `Predicate<ObjectStreamClass>`
    Parameters:
      `objectStreamClass` - The ObjectStreamClass to test.
    Returns:
      true if the input is accepted, false if rejected, false if neither.

  - ### test

    public boolean test(String name)
    Tests that the class name conforms to requirements.

    The reject list takes precedence over the accept list.

    Parameters:
      `name` - The class name to test.
    Returns:
      true if the input is accepted, false if rejected, false if neither.