Class TypeManagerImpl
- All Implemented Interfaces:
- TypeManager
- 
Nested Class SummaryNested classes/interfaces inherited from interface ch.tocco.nice2.types.api.TypeManagerTypeManager.ParseFlags
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescription<T> T<T> TAttempts to convert any object to the desired target type.voidensureType(@Nullable String name) Makes sure the required type exists in the nice system.@Nullable Type<?> findBaseType(Class<?> representationClass) Finds theTypefor the given java class for one of its ancestors, if any.<T> @Nullable Type<T> getBaseType(Class<T> representationClass) Returns theTypefor the given java class, if any.Collection<Type<?>> Returns all available base types (the real ones, without virtual ones).@Nullable Type<?> Returns the Type (base or virtual) for the name specified.Collection<Type<?>> getTypes()Returns all available types (including virtual ones).booleanTells if such a type or virtual type exists.Type<?> matchTypes(Type<?> one, Type<?> two) TypedValue<?> parse(String str, TypeManager.ParseFlags... flags) TypedValue<?> parse(String typeName, String value, TypeManager.ParseFlags... flags) TypedValue<?> parse(String typeName, String value, TypeManager.ParseFlags[] flags, String fullValue) <T> Type<T> requireBaseType(Class<T> representationClass) Same asTypeManager.getBaseType(java.lang.Class<T>)but throws if missing.Type<?> requireType(String name) Same asTypeManager.getType(java.lang.String)but throws if missing.voidsetAdaptersConfig(List<AdapterContribution> contribs) This is where type adapters from contributions come in.voidsetBaseTypesConfig(List<BaseTypeContribution> contribs) The contributions are merged in, existing ones are kept.voidsetConversionsConfig(List<ConversionContribution> contribs) The contributions are merged in, existing ones are kept.voidsetTypeConfig(List<BaseTypeContribution> baseTypes, List<VirtualTypeContribution> virtualTypes, List<ConversionContribution> conversions, List<AdapterContribution> adapters) voidsetVirtualTypesConfig(List<VirtualTypeContribution> contribs) The contributions are merged in, existing ones are kept.@Nullable StringsuggestType(String name) Suggests the correct type name when the one looked for does not exist.
- 
Constructor Details- 
TypeManagerImplpublic TypeManagerImpl(org.slf4j.Logger log) 
 
- 
- 
Method Details- 
setTypeConfig@Autowired public void setTypeConfig(List<BaseTypeContribution> baseTypes, List<VirtualTypeContribution> virtualTypes, List<ConversionContribution> conversions, List<AdapterContribution> adapters) 
- 
setBaseTypesConfigThe contributions are merged in, existing ones are kept. Exceptions are thrown on duplicates. 
- 
setVirtualTypesConfigThe contributions are merged in, existing ones are kept. Exceptions are thrown on duplicates. 
- 
setConversionsConfigThe contributions are merged in, existing ones are kept. Exceptions are thrown on duplicates. 
- 
setAdaptersConfigThis is where type adapters from contributions come in.The contributions are merged in, existing ones are kept. Exceptions are thrown on duplicates. Type adapters may implement TypeReceivable (setType()) to receive a reference to their type. For example AbstractTypeAdapter does this. - Parameters:
- contribs- The contributions.
 
- 
getTypesDescription copied from interface:TypeManagerReturns all available types (including virtual ones).- Specified by:
- getTypesin interface- TypeManager
 
- 
hasTypeDescription copied from interface:TypeManagerTells if such a type or virtual type exists.- Specified by:
- hasTypein interface- TypeManager
- Parameters:
- name- The type's name, eg 'string'.
 
- 
getTypeDescription copied from interface:TypeManagerReturns the Type (base or virtual) for the name specified. See https://wiki.tocco.ch/wiki/index.php/Nice2-types- Specified by:
- getTypein interface- TypeManager
- Parameters:
- name- The type's name, eg 'string'.
- Returns:
- Null if no such type.
- See Also:
 
- 
getBaseTypesDescription copied from interface:TypeManagerReturns all available base types (the real ones, without virtual ones).- Specified by:
- getBaseTypesin interface- TypeManager
 
- 
getBaseTypeDescription copied from interface:TypeManagerReturns theTypefor the given java class, if any. For the java to type mappings see https://wiki.tocco.ch/wiki/index.php/Nice2-types- Specified by:
- getBaseTypein interface- TypeManager
- Parameters:
- representationClass- The class.
- Returns:
- The type. Null if none. Never a virtual type.
- See Also:
 
- 
findBaseTypeDescription copied from interface:TypeManagerFinds theTypefor the given java class for one of its ancestors, if any. For the java to type mappings see https://wiki.tocco.ch/wiki/index.php/Nice2-types- Specified by:
- findBaseTypein interface- TypeManager
- Parameters:
- representationClass- The class.
- Returns:
- The type. Null if none. Never a virtual type.
 
- 
requireTypeDescription copied from interface:TypeManagerSame asTypeManager.getType(java.lang.String)but throws if missing.- Specified by:
- requireTypein interface- TypeManager
- Throws:
- NoSuchTypeException
- See Also:
 
- 
requireBaseTypeDescription copied from interface:TypeManagerSame asTypeManager.getBaseType(java.lang.Class<T>)but throws if missing.- Specified by:
- requireBaseTypein interface- TypeManager
- Throws:
- NoSuchTypeException
- See Also:
 
- 
parsepublic TypedValue<?> parse(String str, TypeManager.ParseFlags... flags) throws StringConversionException - Specified by:
- parsein interface- TypeManager
- Throws:
- StringConversionException
 
- 
parsepublic TypedValue<?> parse(String typeName, String value, TypeManager.ParseFlags... flags) throws StringConversionException - Specified by:
- parsein interface- TypeManager
- Throws:
- StringConversionException
 
- 
convert@Nullable public <T> T convert(@Nullable @Nullable Object o, Type<T> targetType) throws TypeConversionException Description copied from interface:TypeManagerAttempts to convert any object to the desired target type.- Specified by:
- convertin interface- TypeManager
- Parameters:
- o- The object to convert.
- Returns:
- Object as the converted type, null if input was null (null-in-null-out).
- Throws:
- TypeConversionException- If there is no such type converter, or the conversion fails.
 
- 
convert@Nullable public <T> T convert(@Nullable @Nullable Object o, Type<?> sourceType, Type<T> targetType) throws TypeConversionException - Specified by:
- convertin interface- TypeManager
- Throws:
- TypeConversionException
 
- 
parsepublic TypedValue<?> parse(String typeName, String value, TypeManager.ParseFlags[] flags, String fullValue) throws StringConversionException - Throws:
- StringConversionException
 
- 
matchTypes- Specified by:
- matchTypesin interface- TypeManager
 
- 
getStringType- Specified by:
- getStringTypein interface- TypeManager
 
- 
getIntegerType- Specified by:
- getIntegerTypein interface- TypeManager
 
- 
getLongType- Specified by:
- getLongTypein interface- TypeManager
 
- 
getDoubleType- Specified by:
- getDoubleTypein interface- TypeManager
 
- 
getBooleanType- Specified by:
- getBooleanTypein interface- TypeManager
 
- 
getGlobType- Specified by:
- getGlobTypein interface- TypeManager
 
- 
getNullType- Specified by:
- getNullTypein interface- TypeManager
 
- 
suggestTypeDescription copied from interface:TypeManagerSuggests the correct type name when the one looked for does not exist.Examples are "String" → "string" and "int" → "integer". If the requested type really exists then the same string is returned, though that's not what this method is meant for. If the requested type does not look familiar in any way then null is returned. This method is meant for checking (configuration) input, and telling the implementor quickly what the correct type name is. - Specified by:
- suggestTypein interface- TypeManager
- Returns:
- The correct type name, or null.
- See Also:
 
- 
ensureTypeDescription copied from interface:TypeManagerMakes sure the required type exists in the nice system.If missing then the desired exception is thrown, along with meaningful text info. This is useful for config readers etc. - Specified by:
- ensureTypein interface- TypeManager
- Parameters:
- name- The type's name, eg 'string'.
 
 
-