Package tenapull.data.entity.template
Interface HashLookupPojo<POJO extends HashLookupPojo<POJO>>
- Type Parameters:
POJO
- The POJO class implementing HashLookupPojo
- All Superinterfaces:
java.lang.Comparable<POJO>
,DbPojo
- All Known Implementing Classes:
Acl
,Cpe
,ExtraJson
,HashLookupTemplate
,OperatingSystem
,PluginAttributes
,PluginDescription
,PluginInformation
,PluginRefInformation
,PluginRiskInformation
,PluginScriptCopyright
,PluginSolution
,PluginSynopsis
,PluginVulnInformation
,Remediation
,ScanTargets
,StringHashLookupPojo
@MappedSuperclass public interface HashLookupPojo<POJO extends HashLookupPojo<POJO>> extends DbPojo, java.lang.Comparable<POJO>
Interface for "complex lookup" (or "object lookup") pojos, which use a hash of their
serialized JSON for indexing and ensuring uniqueness. Most implementations
of this interface will inherit from the abstract HashLookupTemplate, but a
handful do not include ExtraJson so implement this interface on their own.
-
Method Summary
Modifier and Type Method Description boolean
_isHashCalculated()
Shortcut for the StringHashLookupDao to determine what approach to most efficiently use to find a matching value for this lookup.boolean
_match(POJO other)
Determine if this pojo represents the same DB record as another POJO of the same type.void
_set(POJO other)
Synchronize the values of two matching POJOs which represent the same DB recorddefault int
compareTo(POJO other)
Default implementation of the Comparable interface.Hash
get_hash()
Get the _hash of the "object lookup" pojo used for indexing it.void
set_hash(Hash hash)
Set the _hash of the pojo used for indexing itMethods inherited from interface tenapull.data.entity.template.DbPojo
_prepare, getId, setId, toJsonNode, toJsonString
-
Method Details
-
get_hash
Hash get_hash()Get the _hash of the "object lookup" pojo used for indexing it.- Returns:
- the Hash of the object lookup
-
set_hash
Set the _hash of the pojo used for indexing it- Parameters:
hash
- the hash to set- Throws:
java.lang.IllegalStateException
- if the hash is being changed to a value different than previously set. All values including the hash are intended to be immutable once a lookup record is created
-
_isHashCalculated
boolean _isHashCalculated()Shortcut for the StringHashLookupDao to determine what approach to most efficiently use to find a matching value for this lookup. If the hash is already calculated, it is most efficient to use the hash. If it is not, it may be more efficient to use the _match method- Returns:
- true if the hash has already been calculated, false if not
-
_match
Determine if this pojo represents the same DB record as another POJO of the same type. Note that this is NOT the same as the equals() method (though it may be in certain cases). Equals may be used to determine if two pojos of the same type contain all of the same values, regardless of whether they represent the same DB record (depending on implementation) while _match determines only if they represent the same DB record even if some of the values may not be equivalent. In many cases the two methods may be the same, but their purpose is different.- Parameters:
other
- other pojo to match- Returns:
- true if the two pojos represent the same DB record, false if not
-
_set
Synchronize the values of two matching POJOs which represent the same DB record- Parameters:
other
- the other pojo representing the same DB record, which the values should be taken from
-
compareTo
Default implementation of the Comparable interface. Compares two HashLookupPojos based on a comparison of their hash- Specified by:
compareTo
in interfacejava.lang.Comparable<POJO extends HashLookupPojo<POJO>>
- Parameters:
other
- the other HashLookupPojo of the same type- Returns:
- the result of the hash comparison
-