Kotlinized PwNode

This commit is contained in:
J-Jamet
2019-06-01 15:01:02 +02:00
parent 0b53e84761
commit 575e967627
14 changed files with 270 additions and 348 deletions

View File

@@ -569,7 +569,7 @@ class Database {
*/
fun copyEntryTo(entryToCopy: EntryVersioned, newParent: GroupVersioned): EntryVersioned? {
val entryCopied = EntryVersioned(entryToCopy)
entryCopied.nodeId = pwDatabaseV3?.newEntryId() ?: pwDatabaseV4?.newEntryId()
entryCopied.nodeId = pwDatabaseV3?.newEntryId() ?: pwDatabaseV4?.newEntryId() ?: PwNodeIdUUID()
entryCopied.parent = newParent
entryCopied.title += " (~)"
addEntryTo(entryCopied, newParent)

View File

@@ -56,8 +56,8 @@ class EntryVersioned : NodeVersioned, PwEntryInterface<GroupVersioned> {
dest.writeParcelable(pwEntryV4, flags)
}
var nodeId: PwNodeId<UUID>?
get() = pwEntryV4?.nodeId ?: pwEntryV3?.nodeId
var nodeId: PwNodeId<UUID>
get() = pwEntryV4?.nodeId ?: pwEntryV3?.nodeId ?: PwNodeIdUUID()
set(value) {
pwEntryV3?.nodeId = value
pwEntryV4?.nodeId = value
@@ -111,49 +111,39 @@ class EntryVersioned : NodeVersioned, PwEntryInterface<GroupVersioned> {
override val isSearchingEnabled: Boolean
get() = pwEntryV3?.isSearchingEnabled ?: pwEntryV4?.isSearchingEnabled ?: false
override fun getLastModificationTime(): PwDate? {
return pwEntryV3?.lastModificationTime ?: pwEntryV4?.lastModificationTime
override var creationTime: PwDate
get() = pwEntryV3?.creationTime ?: pwEntryV4?.creationTime ?: PwDate()
set(value) {
pwEntryV3?.creationTime = value
pwEntryV4?.creationTime = value
}
override fun setLastModificationTime(date: PwDate) {
pwEntryV3?.lastModificationTime = date
pwEntryV4?.lastModificationTime = date
override var lastModificationTime: PwDate
get() = pwEntryV3?.lastModificationTime ?: pwEntryV4?.lastModificationTime ?: PwDate()
set(value) {
pwEntryV3?.lastModificationTime = value
pwEntryV4?.lastModificationTime = value
}
override fun getCreationTime(): PwDate? {
return pwEntryV3?.creationTime ?: pwEntryV4?.creationTime
override var lastAccessTime: PwDate
get() = pwEntryV3?.lastAccessTime ?: pwEntryV4?.lastAccessTime ?: PwDate()
set(value) {
pwEntryV3?.lastAccessTime = value
pwEntryV4?.lastAccessTime = value
}
override fun setCreationTime(date: PwDate) {
pwEntryV3?.creationTime = date
pwEntryV4?.creationTime = date
override var expiryTime: PwDate
get() = pwEntryV3?.expiryTime ?: pwEntryV4?.expiryTime ?: PwDate()
set(value) {
pwEntryV3?.expiryTime = value
pwEntryV4?.expiryTime = value
}
override fun getLastAccessTime(): PwDate? {
return pwEntryV3?.lastAccessTime ?: pwEntryV4?.lastAccessTime
}
override fun setLastAccessTime(date: PwDate) {
pwEntryV3?.lastAccessTime = date
pwEntryV4?.lastAccessTime = date
}
override fun getExpiryTime(): PwDate? {
return pwEntryV3?.expiryTime ?: pwEntryV4?.expiryTime
}
override fun setExpiryTime(date: PwDate) {
pwEntryV3?.expiryTime = date
pwEntryV4?.expiryTime = date
}
override fun isExpires(): Boolean {
return pwEntryV3?.isExpires ?: pwEntryV4?.isExpires ?: false
}
override fun setExpires(exp: Boolean) {
pwEntryV3?.isExpires = exp
pwEntryV4?.isExpires = exp
override var isExpires: Boolean
get() =pwEntryV3?.isExpires ?: pwEntryV4?.isExpires ?: false
set(value) {
pwEntryV3?.isExpires = value
pwEntryV4?.isExpires = value
}
override var username: String
@@ -189,7 +179,7 @@ class EntryVersioned : NodeVersioned, PwEntryInterface<GroupVersioned> {
pwEntryV4?.touchLocation()
}
fun isTan(): Boolean {
private fun isTan(): Boolean {
return title == PMS_TAN_ENTRY && username.isNotEmpty()
}

View File

@@ -117,49 +117,39 @@ class GroupVersioned : NodeVersioned, PwGroupInterface<GroupVersioned, EntryVers
override val isSearchingEnabled: Boolean
get() = pwGroupV3?.isSearchingEnabled ?: pwGroupV4?.isSearchingEnabled ?: false
override fun getLastModificationTime(): PwDate? {
return pwGroupV3?.lastModificationTime ?: pwGroupV4?.lastModificationTime
override var creationTime: PwDate
get() = pwGroupV3?.creationTime ?: pwGroupV4?.creationTime ?: PwDate()
set(value) {
pwGroupV3?.creationTime = value
pwGroupV4?.creationTime = value
}
override fun setLastModificationTime(date: PwDate) {
pwGroupV3?.lastModificationTime = date
pwGroupV4?.lastModificationTime = date
override var lastModificationTime: PwDate
get() = pwGroupV3?.lastModificationTime ?: pwGroupV4?.lastModificationTime ?: PwDate()
set(value) {
pwGroupV3?.lastModificationTime = value
pwGroupV4?.lastModificationTime = value
}
override fun getCreationTime(): PwDate? {
return pwGroupV3?.creationTime ?: pwGroupV4?.creationTime
override var lastAccessTime: PwDate
get() = pwGroupV3?.lastAccessTime ?: pwGroupV4?.lastAccessTime ?: PwDate()
set(value) {
pwGroupV3?.lastAccessTime = value
pwGroupV4?.lastAccessTime = value
}
override fun setCreationTime(date: PwDate) {
pwGroupV3?.creationTime = date
pwGroupV4?.creationTime = date
override var expiryTime: PwDate
get() = pwGroupV3?.expiryTime ?: pwGroupV4?.expiryTime ?: PwDate()
set(value) {
pwGroupV3?.expiryTime = value
pwGroupV4?.expiryTime = value
}
override fun getLastAccessTime(): PwDate? {
return pwGroupV3?.lastAccessTime ?: pwGroupV4?.lastAccessTime
}
override fun setLastAccessTime(date: PwDate) {
pwGroupV3?.lastAccessTime = date
pwGroupV4?.lastAccessTime = date
}
override fun getExpiryTime(): PwDate? {
return pwGroupV3?.expiryTime ?: pwGroupV4?.expiryTime
}
override fun setExpiryTime(date: PwDate) {
pwGroupV3?.expiryTime = date
pwGroupV4?.expiryTime = date
}
override fun isExpires(): Boolean {
return pwGroupV3?.isExpires ?: pwGroupV4?.isExpires ?: false
}
override fun setExpires(exp: Boolean) {
pwGroupV3?.isExpires = exp
pwGroupV4?.isExpires = exp
override var isExpires: Boolean
get() = pwGroupV3?.isExpires ?: pwGroupV4?.isExpires ?: false
set(value) {
pwGroupV3?.isExpires = value
pwGroupV4?.isExpires = value
}
override fun getChildGroups(): MutableList<GroupVersioned> {
@@ -248,8 +238,8 @@ class GroupVersioned : NodeVersioned, PwGroupInterface<GroupVersioned, EntryVers
------------
*/
var nodeIdV3: PwNodeId<Int>?
get() = pwGroupV3?.nodeId
var nodeIdV3: PwNodeId<Int>
get() = pwGroupV3?.nodeId ?: PwNodeIdInt()
set(value) { pwGroupV3?.nodeId = value }
fun setNodeId(id: PwNodeIdInt) {
@@ -270,8 +260,8 @@ class GroupVersioned : NodeVersioned, PwGroupInterface<GroupVersioned, EntryVers
------------
*/
var nodeIdV4: PwNodeId<UUID>?
get() = pwGroupV4?.nodeId
var nodeIdV4: PwNodeId<UUID>
get() = pwGroupV4?.nodeId ?: PwNodeIdUUID()
set(value) { pwGroupV4?.nodeId = value }
fun setNodeId(id: PwNodeIdUUID) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2018 Jeremy Jamet / Kunzisoft.
* Copyright 2019 Jeremy Jamet / Kunzisoft.
*
* This file is part of KeePass DX.
*
@@ -17,24 +17,17 @@
* along with KeePass DX. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.kunzisoft.keepass.database;
package com.kunzisoft.keepass.database.element
import com.kunzisoft.keepass.database.element.PwDate;
interface NodeTimeInterface {
public interface SmallTimeInterface {
var creationTime: PwDate
PwDate getLastModificationTime();
void setLastModificationTime(PwDate date);
var lastModificationTime: PwDate
PwDate getCreationTime();
void setCreationTime(PwDate date);
var lastAccessTime: PwDate
PwDate getLastAccessTime();
void setLastAccessTime(PwDate date);
var expiryTime: PwDate
PwDate getExpiryTime();
void setExpiryTime(PwDate date);
boolean isExpires();
void setExpires(boolean exp);
var isExpires: Boolean
}

View File

@@ -17,16 +17,12 @@
* along with KeePass DX. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.kunzisoft.keepass.database;
package com.kunzisoft.keepass.database.element
import com.kunzisoft.keepass.database.element.PwDate;
interface NodeV4Interface : NodeTimeInterface {
public interface ITimeLogger extends SmallTimeInterface {
var usageCount: Long
long getUsageCount();
void setUsageCount(long count);
PwDate getLocationChanged();
void setLocationChanged(PwDate date);
var locationChanged: PwDate
}

View File

@@ -43,6 +43,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
package com.kunzisoft.keepass.database.element;
import android.os.Parcel;
import android.support.annotation.NonNull;
import java.io.UnsupportedEncodingException;
import java.util.Arrays;
@@ -87,13 +88,15 @@ public class PwEntryV3 extends PwEntry<PwGroupV3, PwEntryV3> {
private String binaryDesc = "";
private byte[] binaryData = new byte[0];
@NonNull
@Override
PwNodeId<UUID> initNodeId() {
protected PwNodeId<UUID> initNodeId() {
return new PwNodeIdUUID();
}
@NonNull
@Override
PwNodeId<UUID> copyNodeId(PwNodeId<UUID> nodeId) {
protected PwNodeId<UUID> copyNodeId(@NonNull PwNodeId<UUID> nodeId) {
return new PwNodeIdUUID(nodeId.getId());
}

View File

@@ -24,7 +24,6 @@ import android.os.Parcel;
import android.support.annotation.NonNull;
import com.kunzisoft.keepass.database.AutoType;
import com.kunzisoft.keepass.database.ExtraFields;
import com.kunzisoft.keepass.database.ITimeLogger;
import com.kunzisoft.keepass.database.security.ProtectedBinary;
import com.kunzisoft.keepass.database.security.ProtectedString;
import com.kunzisoft.keepass.utils.MemUtil;
@@ -37,7 +36,7 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;
public class PwEntryV4 extends PwEntry<PwGroupV4, PwEntryV4> implements ITimeLogger {
public class PwEntryV4 extends PwEntry<PwGroupV4, PwEntryV4> implements NodeV4Interface {
public static final String STR_TITLE = "Title";
public static final String STR_USERNAME = "UserName";
@@ -64,13 +63,15 @@ public class PwEntryV4 extends PwEntry<PwGroupV4, PwEntryV4> implements ITimeLog
private String additional = "";
private String tags = "";
@NonNull
@Override
PwNodeId<UUID> initNodeId() {
protected PwNodeId<UUID> initNodeId() {
return new PwNodeIdUUID();
}
@NonNull
@Override
PwNodeId<UUID> copyNodeId(PwNodeId<UUID> nodeId) {
protected PwNodeId<UUID> copyNodeId(@NonNull PwNodeId<UUID> nodeId) {
return new PwNodeIdUUID(nodeId.getId());
}

View File

@@ -21,6 +21,7 @@
package com.kunzisoft.keepass.database.element;
import android.os.Parcel;
import android.support.annotation.NonNull;
public class PwGroupV3 extends PwGroup<Integer, PwGroupV3, PwEntryV3> {
@@ -28,13 +29,15 @@ public class PwGroupV3 extends PwGroup<Integer, PwGroupV3, PwEntryV3> {
/** Used by KeePass internally, don't use */
private int flags;
@NonNull
@Override
PwNodeId<Integer> initNodeId() {
protected PwNodeId<Integer> initNodeId() {
return new PwNodeIdInt();
}
@NonNull
@Override
PwNodeId<Integer> copyNodeId(PwNodeId<Integer> nodeId) {
protected PwNodeId<Integer> copyNodeId(@NonNull PwNodeId<Integer> nodeId) {
return new PwNodeIdInt(nodeId.getId());
}

View File

@@ -21,13 +21,12 @@ package com.kunzisoft.keepass.database.element;
import android.os.Parcel;
import android.support.annotation.NonNull;
import com.kunzisoft.keepass.database.ITimeLogger;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public class PwGroupV4 extends PwGroup<UUID, PwGroupV4, PwEntryV4> implements ITimeLogger {
public class PwGroupV4 extends PwGroup<UUID, PwGroupV4, PwEntryV4> implements NodeV4Interface {
private PwIconCustom customIcon = PwIconCustom.Companion.getZERO();
private long usageCount = 0;
@@ -41,13 +40,15 @@ public class PwGroupV4 extends PwGroup<UUID, PwGroupV4, PwEntryV4> implements IT
private Boolean enableSearching = null;
private UUID lastTopVisibleEntry = PwDatabase.UUID_ZERO;
@NonNull
@Override
PwNodeId<UUID> initNodeId() {
protected PwNodeId<UUID> initNodeId() {
return new PwNodeIdUUID();
}
@NonNull
@Override
PwNodeId<UUID> copyNodeId(PwNodeId<UUID> nodeId) {
protected PwNodeId<UUID> copyNodeId(@NonNull PwNodeId<UUID> nodeId) {
return new PwNodeIdUUID(nodeId.getId());
}

View File

@@ -1,216 +0,0 @@
/*
* Copyright 2018 Jeremy Jamet / Kunzisoft.
*
* This file is part of KeePass DX.
*
* KeePass DX is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* KeePass DX is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with KeePass DX. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
package com.kunzisoft.keepass.database.element;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.NonNull;
import org.joda.time.LocalDate;
/**
* Abstract class who manage Groups and Entries
*/
public abstract class PwNode
<
IdType,
Parent extends PwGroupInterface<Parent, Entry>,
Entry extends PwEntryInterface<Parent>
>
implements PwNodeInterface<Parent>, Parcelable {
private PwNodeId<IdType> nodeId = initNodeId();
private Parent parent = null;
private PwIcon icon = new PwIconStandard();
protected PwDate creation = new PwDate();
private PwDate lastMod = new PwDate();
private PwDate lastAccess = new PwDate();
private PwDate expireDate = PwDate.PW_NEVER_EXPIRE;
abstract PwNodeId<IdType> initNodeId();
abstract PwNodeId<IdType> copyNodeId(PwNodeId<IdType> nodeId);
protected PwNode() {}
protected PwNode(Parcel parcel) {
nodeId = parcel.readParcelable(PwNodeId.class.getClassLoader());
parent = readParentParcelable(parcel);
icon = parcel.readParcelable(PwIconStandard.class.getClassLoader());
creation = parcel.readParcelable(PwDate.class.getClassLoader());
lastMod = parcel.readParcelable(PwDate.class.getClassLoader());
lastAccess = parcel.readParcelable(PwDate.class.getClassLoader());
expireDate = parcel.readParcelable(PwDate.class.getClassLoader());
}
protected abstract Parent readParentParcelable(Parcel parcel);
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeParcelable(nodeId, flags);
dest.writeParcelable(parent, flags);
dest.writeParcelable(icon, flags);
dest.writeParcelable(creation, flags);
dest.writeParcelable(lastMod, flags);
dest.writeParcelable(lastAccess, flags);
dest.writeParcelable(expireDate, flags);
}
@Override
public int describeContents() {
return 0;
}
protected void updateWith(PwNode<IdType, Parent, Entry> source) {
this.nodeId = copyNodeId(source.nodeId);
this.parent = source.parent;
this.icon = source.icon;
this.creation = new PwDate(source.creation);
this.lastMod = new PwDate(source.lastMod);
this.lastAccess = new PwDate(source.lastAccess);
this.expireDate = new PwDate(source.expireDate);
}
public IdType getId() {
return getNodeId().getId();
}
public PwNodeId<IdType> getNodeId() {
return nodeId;
}
public void setNodeId(PwNodeId<IdType> id) {
this.nodeId = id;
}
/**
* @return Visual icon
*/
@NonNull
public PwIcon getIcon() {
return icon;
}
@Override
public void setIcon(@NonNull PwIcon icon) {
this.icon = icon;
}
@Override
public Parent getParent() {
return parent;
}
@Override
public void setParent(Parent parent) {
this.parent = parent;
}
/**
* @return true if parent is present (false if not present, can be a root or a detach element)
*/
public boolean containsParent() {
return getParent() != null;
}
public PwDate getCreationTime() {
return creation;
}
public void setCreationTime(PwDate date) {
creation = date;
}
public PwDate getLastModificationTime() {
return lastMod;
}
public void setLastModificationTime(PwDate date) {
lastMod = date;
}
public PwDate getLastAccessTime() {
return lastAccess;
}
public void setLastAccessTime(PwDate date) {
lastAccess = date;
}
public PwDate getExpiryTime() {
return expireDate;
}
public void setExpiryTime(PwDate date) {
expireDate = date;
}
public void setExpires(boolean expires) {
if (!expires) {
expireDate = PwDate.PW_NEVER_EXPIRE;
}
}
public boolean isExpires() {
// If expireDate is before NEVER_EXPIRE date less 1 month (to be sure)
return expireDate.getDate().before(LocalDate.fromDateFields(PwDate.NEVER_EXPIRE).minusMonths(1).toDate());
}
@Override
public boolean isContainedIn(Parent container) {
Parent cur = this.getParent();
while (cur != null) {
if (cur.equals(container)) {
return true;
}
cur = cur.getParent();
}
return false;
}
@Override
public void touch(boolean modified, boolean touchParents) {
PwDate now = new PwDate();
setLastAccessTime(now);
if (modified) {
setLastModificationTime(now);
}
Parent parent = getParent();
if (touchParents && parent != null) {
parent.touch(modified, true);
}
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
PwNode pwNode = (PwNode) o;
return getType().equals(pwNode.getType())
&& (getNodeId() != null ? getNodeId().equals(pwNode.getNodeId()) : pwNode.getNodeId() == null);
}
@Override
public int hashCode() {
return getNodeId() != null ? getNodeId().hashCode() : 0;
}
}

View File

@@ -0,0 +1,162 @@
/*
* Copyright 2019 Jeremy Jamet / Kunzisoft.
*
* This file is part of KeePass DX.
*
* KeePass DX is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* KeePass DX is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with KeePass DX. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
package com.kunzisoft.keepass.database.element
import android.os.Parcel
import android.os.Parcelable
import org.joda.time.LocalDate
/**
* Abstract class who manage Groups and Entries
*/
abstract class PwNode<IdType, Parent : PwGroupInterface<Parent, Entry>, Entry : PwEntryInterface<Parent>> : PwNodeInterface<Parent>, Parcelable {
var nodeId: PwNodeId<IdType> = this.initNodeId()
private var mParent: Parent? = null
private var mIcon: PwIcon = PwIconStandard()
private var mCreationDate = PwDate()
private var mLastModificationDate = PwDate()
private var mLastAccessDate = PwDate()
private var mExpireDate = PwDate.PW_NEVER_EXPIRE
protected abstract fun initNodeId(): PwNodeId<IdType>
protected abstract fun copyNodeId(nodeId: PwNodeId<IdType>): PwNodeId<IdType>
protected abstract fun readParentParcelable(parcel: Parcel): Parent
protected constructor()
protected constructor(parcel: Parcel) {
this.nodeId = parcel.readParcelable(PwNodeId::class.java.classLoader)
this.mParent = this.readParentParcelable(parcel)
this.mIcon = parcel.readParcelable(PwIconStandard::class.java.classLoader)
this.mCreationDate = parcel.readParcelable(PwDate::class.java.classLoader)
this.mLastModificationDate = parcel.readParcelable(PwDate::class.java.classLoader)
this.mLastAccessDate = parcel.readParcelable(PwDate::class.java.classLoader)
this.mExpireDate = parcel.readParcelable(PwDate::class.java.classLoader)
}
override fun writeToParcel(dest: Parcel, flags: Int) {
dest.writeParcelable(nodeId, flags)
dest.writeParcelable(mParent, flags)
dest.writeParcelable(mIcon, flags)
dest.writeParcelable(mCreationDate, flags)
dest.writeParcelable(mLastModificationDate, flags)
dest.writeParcelable(mLastAccessDate, flags)
dest.writeParcelable(mExpireDate, flags)
}
override fun describeContents(): Int {
return 0
}
protected fun updateWith(source: PwNode<IdType, Parent, Entry>) {
this.nodeId = copyNodeId(source.nodeId)
this.mParent = source.parent
this.mIcon = source.icon
this.mCreationDate = PwDate(source.mCreationDate)
this.mLastModificationDate = PwDate(source.mLastModificationDate)
this.mLastAccessDate = PwDate(source.mLastAccessDate)
this.mExpireDate = PwDate(source.mExpireDate)
}
val id: IdType
get() = nodeId.id
override var parent: Parent?
get() = mParent
set(value) { mParent = value }
override var icon: PwIcon
get() = mIcon
set(value) { mIcon = value }
override var creationTime: PwDate
get() = mCreationDate
set(value) { mCreationDate = value }
override var lastModificationTime: PwDate
get() = mLastModificationDate
set(value) { mLastModificationDate = value }
override var lastAccessTime: PwDate
get() = mLastAccessDate
set(value) { mLastAccessDate = value }
override var expiryTime: PwDate
get() = mExpireDate
set(value) { mExpireDate = value }
override var isExpires: Boolean
// If expireDate is before NEVER_EXPIRE date less 1 month (to be sure)
get() = mExpireDate.date.before(LocalDate.fromDateFields(PwDate.NEVER_EXPIRE).minusMonths(1).toDate())
set(value) {
if (!value) {
mExpireDate = PwDate.PW_NEVER_EXPIRE
}
}
/**
* @return true if parent is present (false if not present, can be a root or a detach element)
*/
override fun containsParent(): Boolean {
return parent != null
}
override fun isContainedIn(container: Parent): Boolean {
var cur = this.parent
while (cur != null) {
if (cur == container) {
return true
}
cur = cur.parent
}
return false
}
override fun touch(modified: Boolean, touchParents: Boolean) {
val now = PwDate()
lastAccessTime = now
if (modified) {
lastModificationTime = now
}
if (touchParents) {
parent?.touch(modified, true)
}
}
override fun equals(other: Any?): Boolean {
if (this === other)
return true
if (other == null)
return false
if (other !is PwNode<*, *, *>) {
return false
}
return type == other.type && nodeId == other.nodeId
}
override fun hashCode(): Int {
return nodeId.hashCode()
}
}

View File

@@ -1,9 +1,8 @@
package com.kunzisoft.keepass.database.element
import android.os.Parcelable
import com.kunzisoft.keepass.database.SmallTimeInterface
interface PwNodeInterface<ParentGroup> : SmallTimeInterface, Parcelable {
interface PwNodeInterface<ParentGroup> : NodeTimeInterface, Parcelable {
var title: String
@@ -26,7 +25,7 @@ interface PwNodeInterface<ParentGroup> : SmallTimeInterface, Parcelable {
fun containsParent(): Boolean
fun touch(modified: Boolean, touchParents: Boolean)
fun isContainedIn(container: ParentGroup): Boolean
fun touch(modified: Boolean, touchParents: Boolean)
}

View File

@@ -24,7 +24,7 @@ import com.kunzisoft.keepass.R;
import com.kunzisoft.keepass.crypto.CipherFactory;
import com.kunzisoft.keepass.crypto.PwStreamCipherFactory;
import com.kunzisoft.keepass.crypto.engine.CipherEngine;
import com.kunzisoft.keepass.database.ITimeLogger;
import com.kunzisoft.keepass.database.element.NodeV4Interface;
import com.kunzisoft.keepass.database.PwCompressionAlgorithm;
import com.kunzisoft.keepass.database.element.*;
import com.kunzisoft.keepass.database.exception.ArcFourException;
@@ -641,7 +641,7 @@ public class ImporterV4 extends Importer<PwDatabaseV4> {
case GroupTimes:
case EntryTimes:
ITimeLogger tl;
NodeV4Interface tl;
if ( ctx == KdbContext.GroupTimes ) {
tl = ctxGroup;
} else {

View File

@@ -675,7 +675,7 @@ public class PwDbV4Output extends PwDbOutput<PwDbHeaderV4> {
}
private void writeList(String name, ITimeLogger it) throws IllegalArgumentException, IllegalStateException, IOException {
private void writeList(String name, NodeV4Interface it) throws IllegalArgumentException, IllegalStateException, IOException {
assert(name != null && it != null);
xml.startTag(null, name);