/** * Returns the right type converter based on the context. * * @param context context * @return type converter */ public ConnectorTypeConverter get(@Nullable final String context) { if (context == null) { return this.getDefaultConverter(); } final ConnectorTypeConverter result = this.registry.get(context); if (result == null) { throw new IllegalArgumentException("No handler for " + context); } return result; }
/** * The type converter factory to use. * * @param config The system configuration * @return The type converter factory */ @Bean public TypeConverterFactory typeConverterFactory(final Config config) { return new TypeConverterFactory(config); }
/** * {@inheritDoc} */ @Override public String convertTo(final Type source, final String destination) { final ConnectorTypeConverter typeConverter; try { typeConverter = this.typeConverterFactory.get(MetacatContextManager.getContext().getDataTypeContext()); } catch (final Exception e) { throw new IllegalStateException("Unable to get a type converter", e); } return typeConverter.fromMetacatType(source); }
/** * Installs the plugins. * * @param connectorPlugin service plugin */ private void installPlugin(final ConnectorPlugin connectorPlugin) { this.connectorManager.addPlugin(connectorPlugin); this.typeConverterFactory.register(connectorPlugin.getType(), connectorPlugin.getTypeConverter()); } }
/** * {@inheritDoc} */ @Override public Type convertFrom(final String source, final Type destination) { final ConnectorTypeConverter typeConverter; try { typeConverter = this.typeConverterFactory.get(MetacatContextManager.getContext().getDataTypeContext()); } catch (final Exception e) { throw new IllegalStateException("Unable to get a type converter", e); } return typeConverter.toMetacatType(source); } }
/** * {@inheritDoc} */ @Override public Type convertFrom(final String source, final Type destination) { final ConnectorTypeConverter typeConverter; try { typeConverter = this.typeConverterFactory.get(MetacatContextManager.getContext().getDataTypeContext()); } catch (final Exception e) { throw new IllegalStateException("Unable to get a type converter", e); } return typeConverter.toMetacatType(source); } }
/** * Returns the right type converter based on the context. * * @param context context * @return type converter */ public ConnectorTypeConverter get(@Nullable final String context) { if (context == null) { return this.getDefaultConverter(); } final ConnectorTypeConverter result = this.registry.get(context); if (result == null) { throw new IllegalArgumentException("No handler for " + context); } return result; }
/** * {@inheritDoc} */ @Override public String convertTo(final Type source, final String destination) { final ConnectorTypeConverter typeConverter; try { typeConverter = this.typeConverterFactory.get(MetacatContextManager.getContext().getDataTypeContext()); } catch (final Exception e) { throw new IllegalStateException("Unable to get a type converter", e); } return typeConverter.fromMetacatType(source); }