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

com.bq.oss.lib.mongo.SafeKeys Maven / Gradle / Ivy

/*
 * Copyright (C) 2014 StarTIC
 */
package com.bq.oss.lib.mongo;

/**
 * @author Alexander De Leon
 * 
 */
public class SafeKeys {

	static final String ESCAPED_ID = "__id";
	static final String MONGO_ID = "_id";
	static final String ID = "id";

	public static String getSafeKey(String key) {
		switch (key) {
			case ID:
				return MONGO_ID;
			case MONGO_ID:
				return ESCAPED_ID;
			default:
				return key;
		}
	}

    public static String getOriginalKey(String key) {
        switch (key) {
            case ESCAPED_ID:
                return MONGO_ID;
            case MONGO_ID:
                return ID;
            default:
                return key;
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy