Class SimpleClassNameDiscriminatorStrategy
- java.lang.Object
-
- org.soulwing.prospecto.api.discriminator.SimpleClassNameDiscriminatorStrategy
-
- All Implemented Interfaces:
DiscriminatorStrategy
public class SimpleClassNameDiscriminatorStrategy extends Object implements DiscriminatorStrategy
ADiscriminatorStrategythat utilizes the simple (unqualified) class name.This strategy provides options for stripping a prefix and/or suffix from the simple class name and for de-capitalizing the (stripped) name (according to the unusual rules of
Introspector.decapitalize(String).In oder for this strategy to successfully recover the
Classobject for a subtype from the simple names produced bytoDiscriminator(Class, Class), the subtype classes must be in the same package as the base type and loaded by the same class loader as the base type.- Author:
- Carl Harris
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSimpleClassNameDiscriminatorStrategy.BuilderA builder that produces aSimpleClassNameDiscriminatorStrategyinstance.
-
Constructor Summary
Constructors Constructor Description SimpleClassNameDiscriminatorStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetName()Gets thenameproperty.StringgetPrefix()Gets theprefixproperty.StringgetSuffix()Gets thesuffixproperty.booleanisDecapitalize()Gets thedecapitalizeproperty.voidsetDecapitalize(boolean decapitalize)Sets thedecapitalizeproperty.voidsetName(String name)Sets thenameproperty.voidsetPrefix(String prefix)Sets theprefixproperty.voidsetSuffix(String suffix)Sets thesuffixproperty.DiscriminatortoDiscriminator(Class<?> base, Class<?> subtype)Produces a discriminator for the given subtype of a base type.<T> Class<T>toSubtype(Class<T> base, Discriminator discriminator)Determines the subtype that corresponds to a given discriminator.
-
-
-
Method Detail
-
toDiscriminator
public Discriminator toDiscriminator(Class<?> base, Class<?> subtype)
Description copied from interface:DiscriminatorStrategyProduces a discriminator for the given subtype of a base type.- Specified by:
toDiscriminatorin interfaceDiscriminatorStrategy- Parameters:
base- the base typesubtype- a subtype of base- Returns:
- discriminator
-
toSubtype
public <T> Class<T> toSubtype(Class<T> base, Discriminator discriminator) throws ClassNotFoundException
Description copied from interface:DiscriminatorStrategyDetermines the subtype that corresponds to a given discriminator.- Specified by:
toSubtypein interfaceDiscriminatorStrategy- Type Parameters:
T- base type- Parameters:
base- base typediscriminator- discriminator- Returns:
- type that corresponds to
discriminator - Throws:
ClassNotFoundException
-
getName
public String getName()
Gets thenameproperty.- Returns:
- property value
-
setName
public void setName(String name)
Sets thenameproperty.- Parameters:
name- the property value to set
-
getPrefix
public String getPrefix()
Gets theprefixproperty.- Returns:
- property value
-
setPrefix
public void setPrefix(String prefix)
Sets theprefixproperty.- Parameters:
prefix- the property value to set
-
getSuffix
public String getSuffix()
Gets thesuffixproperty.- Returns:
- property value
-
setSuffix
public void setSuffix(String suffix)
Sets thesuffixproperty.- Parameters:
suffix- the property value to set
-
isDecapitalize
public boolean isDecapitalize()
Gets thedecapitalizeproperty.- Returns:
- property value
-
setDecapitalize
public void setDecapitalize(boolean decapitalize)
Sets thedecapitalizeproperty.- Parameters:
decapitalize- the property value to set
-
-