@FunctionalInterface public interface ObjectFactory
Obfuscators
and
CharacterRepresentationProviders
from annotations.<T> T instance(Class<T> type)
T
- The type to return an instance of.type
- A class representing the type to return an instance of.NullPointerException
- If the given type is null
.RuntimeException
- If no instance could be returned.
This is often an exception like IllegalStateException
or IllegalArgumentException
, but other
exceptions are also possible.default Obfuscator obfuscator(ObfuscateAll annotation)
Obfuscator
based on an ObfuscateAll
annotation.annotation
- The annotation to base the returned Obfuscator
on.Obfuscator
based on the given annotation.NullPointerException
- If the given annotation is null.default Obfuscator obfuscator(ObfuscateNone annotation)
Obfuscator
based on an ObfuscateNone
annotation.annotation
- The annotation to base the returned Obfuscator
on.Obfuscator
based on the given annotation.NullPointerException
- If the given annotation is null.default Obfuscator obfuscator(ObfuscateFixedLength annotation)
Obfuscator
based on an ObfuscateFixedLength
annotation.annotation
- The annotation to base the returned Obfuscator
on.Obfuscator
based on the given annotation.NullPointerException
- If the given annotation is null.default Obfuscator obfuscator(ObfuscateFixedValue annotation)
Obfuscator
based on an ObfuscateFixedValue
annotation.annotation
- The annotation to base the returned Obfuscator
on.Obfuscator
based on the given annotation.NullPointerException
- If the given annotation is null.default Obfuscator obfuscator(ObfuscatePortion annotation)
Obfuscator
based on an ObfuscatePortion
annotation.annotation
- The annotation to base the returned Obfuscator
on.Obfuscator
based on the given annotation.NullPointerException
- If the given annotation is null.default Obfuscator obfuscator(ObfuscateUsing annotation)
Obfuscator
based on an ObfuscateUsing
annotation.annotation
- The annotation to base the returned Obfuscator
on.Obfuscator
based on the given annotation.NullPointerException
- If the given annotation is null.IllegalStateException
- If the annotation's provider type
cannot be instantiated
.default Optional<Obfuscator> obfuscator(AnnotatedElement annotatedElement)
Obfuscator
based on the used annotations in this package.annotatedElement
- The annotated object for which to check the annotations.Optional
describing the single found Obfuscator
based on the used annotations,
or Optional.empty()
if none of the object's annotations describes an Obfuscator
.IllegalStateException
- If more than one annotation that describes an Obfuscator
is used,
or if ObfuscateUsing
is used but its provider type
cannot be
instantiated
.ObfuscateAll
,
ObfuscateNone
,
ObfuscateFixedLength
,
ObfuscateFixedValue
,
ObfuscatePortion
,
ObfuscateUsing
default Optional<Obfuscator> obfuscator(Function<Class<? extends Annotation>,Annotation> annotationLookup)
Obfuscator
based on the used annotations in this package.
This method provides a generic way of checking annotations, in case a lookup other than reflection is used.annotationLookup
- The function that maps an annotation type to the used annotation of that type,
or null
if the annotation is not used.Optional
describing the single found Obfuscator
based on the used annotations,
or Optional.empty()
if the function does not return any non-null
value for any of the annotations in this package.IllegalStateException
- If more than one annotation that describes an Obfuscator
is used,
or if ObfuscateUsing
is used but its provider type
cannot be
instantiated
.ObfuscateAll
,
ObfuscateNone
,
ObfuscateFixedLength
,
ObfuscateFixedValue
,
ObfuscatePortion
,
ObfuscateUsing
default Optional<Obfuscator> obfuscator(Annotation... annotations)
Obfuscator
based on multiple annotations.annotations
- The annotations to base the returned Obfuscator
on.Optional
describing the single found Obfuscator
based on the given annotations,
or Optional.empty()
if none of the annotations describes an Obfuscator
.NullPointerException
- If any of the annotations is null
.IllegalStateException
- If the given annotations contain more than one annotation that describes an Obfuscator
,
or if the given annotations contain an ObfuscateUsing
annotation but its
provider type
cannot be instantiated
.ObfuscateAll
,
ObfuscateNone
,
ObfuscateFixedLength
,
ObfuscateFixedValue
,
ObfuscatePortion
,
ObfuscateUsing
default Optional<Obfuscator> obfuscator(Collection<? extends Annotation> annotations)
Obfuscator
based on multiple annotations.annotations
- The annotations to base the returned Obfuscator
on.Optional
describing the single found Obfuscator
based on the given annotations,
or Optional.empty()
if none of the annotations describes an Obfuscator
.NullPointerException
- If any of the annotations is null
.IllegalStateException
- If the given annotations contain more than one annotation that describes an Obfuscator
,
or if the given annotations contain an ObfuscateUsing
annotation but its
provider type
cannot be instantiated
.ObfuscateAll
,
ObfuscateNone
,
ObfuscateFixedLength
,
ObfuscateFixedValue
,
ObfuscatePortion
,
ObfuscateUsing
default ObfuscatorProvider obfuscatorProvider(ObfuscateUsing annotation)
ObfuscatorProvider
based on an ObfuscateUsing
annotation.annotation
- The annotation to base the returned ObfuscatorProvider
on.ObfuscatorProvider
based on the given annotation.NullPointerException
- If the given annotation is null.IllegalStateException
- If the annotation's provider type
cannot be instantiated
.default ObfuscatorProvider obfuscatorProvider(Class<? extends ObfuscatorProvider> providerClass)
ObfuscatorProvider
type.providerClass
- The class representing the ObfuscatorProvider
type.ObfuscatorProvider
type.NullPointerException
- If the given class is null
.RuntimeException
- If no instance could be returned.instance(Class)
default Optional<CharacterRepresentationProvider> characterRepresentationProvider(AnnotatedElement annotatedElement)
CharacterRepresentationProvider
based on the used annotations in this package.annotatedElement
- The annotated object for which to check the annotations.Optional
describing the CharacterRepresentationProvider
based on the used annotations,
or Optional.empty()
if the element is not annotated with RepresentedBy
.IllegalStateException
- If the element is annotated with RepresentedBy
, but its provider type
cannot be instantiated
.default Optional<CharacterRepresentationProvider> characterRepresentationProvider(Function<Class<? extends Annotation>,Annotation> annotationLookup)
CharacterRepresentationProvider
based on the used annotations in this package.
This method provides a generic way of checking annotations, in case a lookup other than reflection is used.annotationLookup
- The function that maps an annotation type to the used annotation of that type,
or null
if the annotation is not used.Optional
describing the CharacterRepresentationProvider
based on the used annotations,
or Optional.empty()
if the function does not return any non-null
value for RepresentedBy
.IllegalStateException
- If RepresentedBy
is used but its provider type
cannot be
instantiated
.default Optional<CharacterRepresentationProvider> characterRepresentationProvider(Annotation... annotations)
CharacterRepresentationProvider
based on multiple annotations.annotations
- The annotations to base the returned CharacterRepresentationProvider
on.Optional
describing the single found CharacterRepresentationProvider
based on the given annotations,
or Optional.empty()
if none of the annotations is a RepresentedBy
annotation.NullPointerException
- If any of the annotations is null
.IllegalStateException
- If the given annotations contain more than one RepresentedBy
annotation,
or if the given annotations contain a RepresentedBy
annotation but its
provider type
cannot be instantiated
.default Optional<CharacterRepresentationProvider> characterRepresentationProvider(Collection<? extends Annotation> annotations)
CharacterRepresentationProvider
based on multiple annotations.annotations
- The annotations to base the returned CharacterRepresentationProvider
on.Optional
describing the single found CharacterRepresentationProvider
based on the given annotations,
or Optional.empty()
if none of the annotations is a RepresentedBy
annotation.NullPointerException
- If any of the annotations is null
.IllegalStateException
- If the given annotations contain more than one RepresentedBy
annotation,
or if the given annotations contain a RepresentedBy
annotation but its
provider type
cannot be instantiated
.default CharacterRepresentationProvider characterRepresentationProvider(RepresentedBy annotation)
CharacterRepresentationProvider
based on a RepresentedBy
annotation.annotation
- The annotation to base the returned CharacterRepresentationProvider
on.CharacterRepresentationProvider
based on the given annotation.NullPointerException
- If the given annotation is null.IllegalStateException
- If the annotation's provider type
cannot be instantiated
.characterRepresentationProvider(Class)
default CharacterRepresentationProvider characterRepresentationProvider(Class<? extends CharacterRepresentationProvider> providerClass)
CharacterRepresentationProvider
type.providerClass
- The class representing the CharacterRepresentationProvider
type.CharacterRepresentationProvider
type.NullPointerException
- If the given class is null
.RuntimeException
- If no instance could be returned.instance(Class)
static ObjectFactory usingReflection()
IllegalStateException
.Copyright © 2020. All rights reserved.