All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.svws_nrw.db.converter.migration.MigrationStringToIntegerConverter Maven / Gradle / Ivy

Go to download

Diese Bibliothek regelt den Zugriff auf Datenbanken für die Schulverwaltungssoftware in NRW

The newest version!
package de.svws_nrw.db.converter.migration;

import de.svws_nrw.db.converter.DBAttributeConverter;
import jakarta.persistence.Converter;


/**
 * Diese Klasse dient dem Konvertieren eines String zu Integer.
 *
 */
@Converter
public final class MigrationStringToIntegerConverter extends DBAttributeConverter {

	/** Die Instanz des Konverters */
	public static final MigrationStringToIntegerConverter instance = new MigrationStringToIntegerConverter();

	@Override
	public String convertToDatabaseColumn(final Integer value) {
		if (value == null)
			return null;
		return value.toString();
	}

	@Override
	public Integer convertToEntityAttribute(final String dbData) {
		try {
			return Integer.parseInt(dbData);
		} catch (@SuppressWarnings("unused") final NumberFormatException e) {
			return null;
		}
	}

	@Override
	public Class getResultType() {
		return Integer.class;
	}

	@Override
	public Class getDBType() {
		return String.class;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy