Package org.nustaq.reallive.api
Interface Record
- All Superinterfaces:
EvalContext,Serializable
- All Known Implementing Classes:
MapRecord,PatchingRecord,RecordWrapper
Created by moelrue on 03.08.2015.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault booleancalled by the persistance layer after a record has been loaded from disk. can be used for type migration of an existing database.default doubletries to interpret the value as a double.default Listgets field and transforms Object[] to arraylist in casedefault longtries to interpret the value as a long.asMap()default Setgets field and transforms Object[] to HashSet in casedefault StringasString()booleandefault RecorddeepCopy()default Recordmerge all fields from given record to this including nested structures.default booleandefaultEquals(Object other) static Recordfrom(com.eclipsesource.json.JsonObject jsonObject) static Recordcreate new json'ish record from key value array.static Recordcreate a new record from given key and valuesdefault Object[]default <T> List<T>see asListdefault booleandefault doubleString[]default intgetKey()default Object[]longdefault longdefault Recordreturn sub-record in case presentdefault Recorddefault StringgetSafeString(String field) longdefault Stringdefault Valuedefault Recordcreates and sets an empty record in casevoidinternal_put(String key, Object value) voidinternal_setLastModified(long tim) default voiddefault Recorda simple tree merge (without any operators like deepMerge) copies all fields of given record to this.take care, kind of dangerousdefault Objectdefault Numberdefault StringmgetString(Object... path) default Recordputs a key value pair. type checking is applied to ensure data is json compatible.default RecordputTransforming(String field, Object value) default Recorddefault voidstripOps()remove special operators on this record attributesdefault com.eclipsesource.json.JsonObjecttoJson()default Stringstatic Objecttransform map/collections into Record, Object[] - Map is transformed to Record - a Collection is transformed to Object[]transformCopy(TransformFunction transform) copies recursively applying given function to each value.default booleanMethods inherited from interface org.nustaq.reallive.query.EvalContext
get
-
Field Details
-
_NULL_
- See Also:
-
-
Method Details
-
from
create new json'ish record from key value array. some value types are transformed / replaced automatically to ensure simple and easy-to-convert data structures - Map is transformed to Record - a Collection is transformed to Object[]- Parameters:
keyVals-- Returns:
-
transform
transform map/collections into Record, Object[] - Map is transformed to Record - a Collection is transformed to Object[]- Parameters:
val-- Returns:
-
from
-
from
create a new record from given key and values- Parameters:
map-- Returns:
-
getKey
String getKey() -
getLastModified
long getLastModified() -
internal_setLastModified
void internal_setLastModified(long tim) -
internal_incSequence
void internal_incSequence() -
getSequence
long getSequence() -
internal_put
-
internal_updateLastModified
default void internal_updateLastModified() -
key
take care, kind of dangerous- Parameters:
key-
-
getFields
String[] getFields() -
getFieldSet
-
put
puts a key value pair. type checking is applied to ensure data is json compatible. if value is null, the key is removed.- Parameters:
field-value-- Returns:
-
getValue
- Specified by:
getValuein interfaceEvalContext
-
mget
-
mgetNum
-
mgetString
-
getInt
-
getLong
-
asList
gets field and transforms Object[] to arraylist in case- Parameters:
field-- Returns:
-
asSet
gets field and transforms Object[] to HashSet in case- Parameters:
field-- Returns:
-
putTransforming
-
haveRec
creates and sets an empty record in case- Parameters:
field-- Returns:
-
getRec
return sub-record in case present- Parameters:
field-- Returns:
-
getAsList
see asList- Parameters:
field-- Returns:
-
getDouble
-
getString
-
getSafeString
-
asString
-
getBool
-
reduced
-
omit
-
shallowCopy
Record shallowCopy()- Returns:
- a shallow (!) copy of this record
-
deepCopy
-
transformCopy
copies recursively applying given function to each value. if the transform returns v, its an identity copy if the transform returns null, the given key is removed from outer record. (if outer container is array, its removed)- Parameters:
transform-- Returns:
-
getKeyVals
-
asMap
- Returns:
- this record as a map
-
getRecord
-
stripOps
default void stripOps()remove special operators on this record attributes -
join
a simple tree merge (without any operators like deepMerge) copies all fields of given record to this. if this contains a record for a field e.g. this = { test: { a: 1, b: 2 } } and that = { test: { c: 1, b: 3 }} merging will be recursively resulting in { test: { a: 1, b: 3, c: 1 } }. for arrays all elements are appended if they do not yet exist. e.g. this = { test: [1,2,3] } and that = { test: [2,4,5] } will result in { test: [1,2,3,4,5] }- Parameters:
that-- Returns:
-
deepMerge
merge all fields from given record to this including nested structures. Assumes pure json data types (String Number Boolean Object[] Record) attribute operators: '+' - insert into array '-' - remove from array '?+' - insert if not present into array- Parameters:
record-
-
toPrettyString
-
toJson
default com.eclipsesource.json.JsonObject toJson() -
validateForJsonability
default boolean validateForJsonability() -
defaultEquals
-
_afterLoad
default boolean _afterLoad()called by the persistance layer after a record has been loaded from disk. can be used for type migration of an existing database. return true if the record should be re-persisted -
asLong
tries to interpret the value as a long. In case its a string, its parsed.- Parameters:
key-- Returns:
-
asDouble
tries to interpret the value as a double. In case its a string, its parsed.- Parameters:
key-- Returns:
-
getArr
-
containsKey
-