java.lang.Object
org.evomaster.client.java.controller.mongo.utils.BsonHelper

public class BsonHelper extends Object
  • Field Details

  • Constructor Details

    • BsonHelper

      public BsonHelper()
  • Method Details

    • newDocument

      public static Object newDocument(Object bsonDocument)
    • appendToDocument

      public static void appendToDocument(Object bsonDocument, String fieldName, Object value)
    • getValue

      public static Object getValue(Object bsonDocument, String fieldName)
    • documentContainsField

      public static Boolean documentContainsField(Object bsonDocument, String fieldName)
    • documentKeys

      public static Set<String> documentKeys(Object bsonDocument)
    • isBsonDocument

      public static Boolean isBsonDocument(Object value)
      Checks if the given object represents a BSON document.
      Parameters:
      value - the object to check; should be non-null to determine if it is a BSON document
      Returns:
      true if the object is a BSON document, false otherwise
    • isObjectId

      public static boolean isObjectId(Object obj)
      Determines whether the given object is a BSON ObjectId.
      Parameters:
      obj - the object to check; should be non-null to determine if it is a BSON ObjectId
      Returns:
      true if the object is a BSON ObjectId, false otherwise
    • isBsonTimestamp

      public static boolean isBsonTimestamp(Object obj)
      Determines whether the given object is a BSON BsonTimestamp.
      Parameters:
      obj - the object to check; should be non-null to determine if it is a BSON BsonTimestamp
      Returns:
      true if the object is a BSON BsonTimestamp, false otherwise
    • getBsonTimestampValue

      public static long getBsonTimestampValue(Object bsonTimestamp)
      Retrieves the value of a BSON BsonTimestamp as a long value.
      Parameters:
      bsonTimestamp - the BSON BsonTimestamp object; should be non-null
      Returns:
      the value of the BSON BsonTimestamp
      Throws:
      IllegalArgumentException - if the argument is not a BSON BsonTimestamp
    • getType

      public static String getType(Object bsonType)
    • getTypeFromNumber

      public static Object getTypeFromNumber(Integer number)
      Retrieves the BSON type corresponding to the given integer value.
      Parameters:
      number - the integer value representing the BSON type
      Returns:
      the BSON type object, or null if not found
    • getTypeFromAlias

      public static Object getTypeFromAlias(String alias)
      Retrieves the BSON type corresponding to the given alias string.
      Parameters:
      alias - the alias string representing the BSON type
      Returns:
      the BSON type object, or null if not found
    • isBsonRegularExpression

      public static boolean isBsonRegularExpression(Object object)
      Checks if the given object is a BSON regular expression.
      Parameters:
      object - the object to check; should be non-null to determine if it is a BSON regular expression
      Returns:
      true if the object is a BSON regular expression, false otherwise
    • bsonRegexGetPattern

      public static String bsonRegexGetPattern(Object value)
      Retrieves the pattern from a BSON regular expression object.
      Parameters:
      value - the object representing a BSON regular expression. Must not be null and must be a valid BSON regular expression.
      Returns:
      a String representing the pattern of the BSON regular expression.
      Throws:
      NullPointerException - if the provided value is null.
      IllegalArgumentException - if the provided value is not a BSON regular expression.
      RuntimeException - if an error occurs while invoking the method to retrieve the pattern.
    • bsonRegexGetOptions

      public static String bsonRegexGetOptions(Object value)
      Retrieves the options associated with a BSON regular expression.
      Parameters:
      value - the object representing a BSON regular expression. Must not be null and must be a valid BSON regular expression.
      Returns:
      a String representing the options associated with the BSON regular expression.
      Throws:
      NullPointerException - if the provided value is null.
      IllegalArgumentException - if the provided value is not a BSON regular expression.