Class MongoMapper
java.lang.Object
com.barden.library.database.mongo.utils.MongoMapper
Mongo mapper class.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TGets destination/path from the map.static <T> TGets destination/path from the map.static <T> TGets destination/path from the map.static <T> TgetNonNull(Map<String, Object> map, String path) Gets destination/path from the map.static <T> TGets destination/path from the map.Removes declared destination/path from the map.Sets/Adds declared destination/path in the map.
-
Constructor Details
-
MongoMapper
public MongoMapper()
-
-
Method Details
-
get
@Nonnull public static <T> T get(@Nonnull Map<String, Object> map, @Nonnull String path, Class<T> type, @Nonnull T default_value) Gets destination/path from the map.- Type Parameters:
T- Excepted class type for return value.- Parameters:
map- Map.path- Path or dot notation.type- Class type for expected result.default_value- Default value.- Returns:
- Map value.
-
getNonNull
@Nonnull public static <T> T getNonNull(@Nonnull Map<String, Object> map, @Nonnull String path, @Nonnull Class<T> type) Gets destination/path from the map.- Type Parameters:
T- Excepted class type for return value.- Parameters:
map- Map.path- Path or dot notation.type- Class type for expected result.- Returns:
- Map value.
-
get
Gets destination/path from the map.- Type Parameters:
T- Excepted class type for return value.- Parameters:
map- Map.path- Path or dot notation.- Returns:
- Map value.
-
getNonNull
Gets destination/path from the map.- Type Parameters:
T- Excepted class type for return value.- Parameters:
map- Map.path- Path or dot notation.- Returns:
- Map value.
-
get
@Nullable public static <T> T get(@Nonnull Map<String, Object> map, @Nonnull String path, @Nonnull Class<T> type) Gets destination/path from the map.- Type Parameters:
T- Excepted class type for return value.- Parameters:
map- Map.path- Path or dot notation.type- Class type for expected result.- Returns:
- Map value.
-
set
@Nonnull public static <T extends Map<String,Object>> T set(@Nonnull Map<String, Object> map, @Nonnull String path, @Nonnull Object value) Sets/Adds declared destination/path in the map.- Type Parameters:
T- Excepted class type for value.- Parameters:
map- Map.path- Path or dot notation.value- Value.- Returns:
- Map.
-
remove
@Nonnull public static <T extends Map<String,Object>> T remove(@Nonnull Map<String, Object> map, @Nonnull String path) Removes declared destination/path from the map.- Type Parameters:
T- Excepted class type for value.- Parameters:
map- Map.path- Path or dot notation.- Returns:
- Map.
-