com.tuana9a.spring.data.mongodb.Utils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spring-data-mongodb Show documentation
Show all versions of spring-data-mongodb Show documentation
A wrapper around spring-data-mongodb
The newest version!
package com.tuana9a.spring.data.mongodb;
import org.bson.types.ObjectId;
public class Utils {
public static Object resolve(String input) {
try {
if (input == null) return null;
if (input.matches("^\\s$")) return null;
if (input.equals("undefined")) return null;
if (input.equals("null")) return null;
if (input.equals("true")) return true;
if (input.equals("false")) return false;
if (ObjectId.isValid(input)) return new ObjectId(input);
if (input.matches("^\\d{1,10}$")) return Integer.parseInt(input);
if (input.matches("^\\d{10,20}$")) return Long.parseLong(input);
} catch (Exception ignored) {
// do nothing
}
return input;
}
}