Class MongoNamespace


  • public final class MongoNamespace
    extends Object
    A MongoDB namespace, which includes a database name and collection name.
    • Method Detail

      • checkDatabaseNameValidity

        public static void checkDatabaseNameValidity​(String databaseName)
        Check the validity of the given database name. A valid database name is non-null, non-empty, and does not contain any of the following characters: '\0', '/', '\\', ' ', '"', '.'. The server may impose additional restrictions on database names.
        Parameters:
        databaseName - the database name
        Throws:
        IllegalArgumentException - if the database name is invalid
      • checkCollectionNameValidity

        public static void checkCollectionNameValidity​(String collectionName)
        Check the validity of the given collection name. A valid collection name is non-null and non-empty. The server may impose additional restrictions on collection names.
        Parameters:
        collectionName - the collection name
        Throws:
        IllegalArgumentException - if the collection name is invalid
      • getDatabaseName

        public String getDatabaseName()
        Gets the database name.
        Returns:
        the database name
      • getCollectionName

        public String getCollectionName()
        Gets the collection name.
        Returns:
        the collection name
      • getFullName

        public String getFullName()
        Gets the full name, which is the database name and the collection name, separated by a period.
        Returns:
        the full name
      • toString

        public String toString()
        Returns the standard MongoDB representation of a namespace, which is <database>.<collection>.
        Overrides:
        toString in class Object
        Returns:
        string representation of the namespace.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object