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

com.github.developframework.resource.spring.mongo.DOC Maven / Gradle / Ivy

The newest version!
package com.github.developframework.resource.spring.mongo;

import com.github.developframework.resource.Entity;
import org.bson.types.ObjectId;

import java.io.Serializable;

/**
 * @author qiushui on 2019-08-21.
 */
public interface DOC extends Entity {

    default ObjectId getObjectId() {
        final ID id = getId();
        if (id == null) {
            return null;
        } else if (id instanceof String) {
            return new ObjectId((String) id);
        } else if (id instanceof ObjectId) {
            return (ObjectId) id;
        } else {
            throw new IllegalArgumentException("Can not convert to ObjectId");
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy