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

fr.lirmm.boreal.util.object_analyzer.ObjectAnalizer Maven / Gradle / Ivy

package fr.lirmm.boreal.util.object_analyzer;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import fr.boreal.model.query.api.FOQuery;

public class ObjectAnalizer {

	static final Logger LOG = LoggerFactory.getLogger(ObjectAnalizer.class);

	/**
	 *
	 * @return information on the query structure
	 */
	public static String info(Object o) {

		return switch (o) {

		case FOQuery q -> FormulaAnalyzer.info(q.getFormula());

		default -> o.toString();

		};

	}

	/**
	 * 
	 * @return a short representation of the query
	 */
	public static String digest(Object o) {

		return switch (o) {

		case FOQuery f -> {

			String s = f.toString();

			int size = 50;

			yield s.length() <= size ? s : s.substring(0, size) + " [... rest of the expression cut]";

		}

		default -> {
			LOG.error("unsupported type");
			yield "";
		}
		};

	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy