public class

ListedClassNormalizer

extends ClassNormalizer
java.lang.Object
   ↳ org.apache.commons.betwixt.strategy.ClassNormalizer
     ↳ org.apache.commons.betwixt.strategy.ListedClassNormalizer

Class Overview

ClassNormalizer that uses a list of substitutions.

This ClassNormalizer checks a list (in order) to find a matching Class. This match can be performed either strictly (using equality) or taking into account inheritance and implementation. If a match is found then the first substituted class is returned as the normalization.

Summary

Public Constructors
ListedClassNormalizer()
Public Methods
void addSubstitution(Class substitute)
Adds the given substitute to the list.
void addSubstitution(Class match, Class substitute)
Adds this given substitution to the list.
boolean isStrickCheck()
Is strict checking of substitutions on?
Class normalize(Class clazz)
Normalize given class.
void setStrickCheck(boolean strickCheck)
Sets strict checking of substitutions?
[Expand]
Inherited Methods
From class org.apache.commons.betwixt.strategy.ClassNormalizer
From class java.lang.Object

Public Constructors

public ListedClassNormalizer ()

Public Methods

public void addSubstitution (Class substitute)

Adds the given substitute to the list. This is a convenience method useful when isStrickCheck() is false. In this case, any subclasses (if this is a class) or implementating classes if this is an interface) will be subsituted with this value.

Parameters
substitute sustitude this Class

public void addSubstitution (Class match, Class substitute)

Adds this given substitution to the list. No warning is given if the match has already been added to the list.

Parameters
match if any classes matching this then the normal class will be substituted
substitute the normalized Class if the primary class is matched

public boolean isStrickCheck ()

Is strict checking of substitutions on?

Returns
  • true is equality is used to compare classes when considering substition, otherwise isAssignableFrom will be used so that super classes and super interfaces will be matched.

public Class normalize (Class clazz)

Normalize given class. The normalized Class is the Class that Betwixt should introspect. This strategy class allows the introspected Class to be varied.

Parameters
clazz the class to normalize, not null
Returns
  • this implementation check it's list of substitutations in order and returns the first that matchs. If isStrickCheck() then equality is used otherwise isAssignableFrom is used (so that super class and interfaces are matched).

public void setStrickCheck (boolean strickCheck)

Sets strict checking of substitutions?

Parameters
strickCheck if true then equality will be used to compare classes when considering substition, otherwise isAssignableFrom will be used so that super classes and super interfaces will be matched.