Menu

Instance Providers

Romain Delamare

Instance providers

Instance providers are used to generate instances on which verifications are performed by checkers. The IInstanceProvider interface has two methods, getInstance and canProvide. getInstance returns an instance of the specified class, and canProvide checks if the instance provider is able to return an instance of as given class.

Implemented providers

  • DefaultInstanceProvider
    This default provider tries to generate instances with the public constructor with the least number of parameters and default values (null for objects).
  • CopyConstructorInstanceProvider
    This provider tries to generate a copy of an instance using the copy constructor pattern. To generate an instance of a class, a reference instance need to be provided.
  • MultipleInstanceProvider
    This provider is used to chain several providers. It has a list of provider and successively tries to generate an instance with each of them.

Writing an instance provider

To write your own instance provider, you only need to implement the IInstanceProvider class and its two methods, getInstance and canProvide.


Related

Wiki: Home
Wiki: Quick Start

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.