Module org.tquadrat.foundation.util
Class ClassStringConverter
java.lang.Object
org.tquadrat.foundation.util.stringconverter.ClassStringConverter
- All Implemented Interfaces:
Serializable,StringConverter<Class<?>>
@ClassVersion(sourceVersion="$Id: ClassStringConverter.java 1060 2023-09-24 19:21:40Z tquadrat $")
@API(status=STABLE,
since="0.0.6")
public final class ClassStringConverter
extends Object
implements StringConverter<Class<?>>
An implementation of
The method
It uses the
StringConverter
for
Class
values.The method
fromString(CharSequence)
will use
Class.forName(String, boolean, ClassLoader)
to load the class with the given name. This means that the conversion may
fail even for an otherwise valid class name when the respective class is
not on the CLASSPATH or otherwise loadable.It uses the
ClassLoader that was used to load the caller for this method,
and the boolean argument will be set to false, meaning that
the class will not be initialised if not loaded previously.- Author:
- Thomas Thrien (thomas.thrien@tquadrat.org)
- Version:
- $Id: ClassStringConverter.java 1060 2023-09-24 19:21:40Z tquadrat $
- Since:
- 0.0.6
- See Also:
- UML Diagram
-
UML Diagram for "org.tquadrat.foundation.util.stringconverter.ClassStringConverter"
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ClassStringConverterAn instance of this class.static final StringThe error message for the name of an unknown class on the command line: "\'%s\' cannot be parsed to the name of a known Java class".Fields inherited from interface org.tquadrat.foundation.lang.StringConverter
METHOD_NAME_GetSubjectClass, METHOD_NAME_Provider -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal Class<?> fromString(CharSequence source) static final ClassStringConverterprovider()This method is used by theServiceLoaderto obtain the instance for thisStringConverterimplementation.final String
-
Field Details
-
MSG_UnknownClass
The error message for the name of an unknown class on the command line: "\'%s\' cannot be parsed to the name of a known Java class".- See Also:
-
INSTANCE
An instance of this class.
-
-
Constructor Details
-
ClassStringConverter
public ClassStringConverter()Creates a new instance ofClassStringConverter.
-
-
Method Details
-
fromString
- Specified by:
fromStringin interfaceStringConverter<Class<?>>- Throws:
IllegalArgumentException
-
provider
This method is used by theServiceLoaderto obtain the instance for thisStringConverterimplementation.- Returns:
- The instance for this
StringConverterimplementation.
-
toString
- Specified by:
toStringin interfaceStringConverter<Class<?>>
-
