class DbObjectLock extends Lock {

    public static final RuntimeException LOCKED_EXCEPTION = new RuntimeException();

    private final DbObjectType type;
    private ArrayList<AsyncHandler<AsyncResult<Boolean>>> handlers;

    public DbObjectLock(DbObjectType type) {
        this.type = type;
    }

    @Override
    public String getLockType() {
        return type.name();
    }

    public boolean lock(ServerSession session, boolean exclusive) {
        if (exclusive)
            return tryExclusiveLock(session);
        else
            return trySharedLock(session);
    }

    public boolean trySharedLock(ServerSession session) {
        return true;
    }

    public boolean tryExclusiveLock(ServerSession session) {
        return tryLock(session.getTransaction(), this, null);
    }

    @Override
    public void unlock(Session oldSession, boolean succeeded, Session newSession) {<FILL_FUNCTION_BODY>}

    public void addHandler(AsyncHandler<AsyncResult<Boolean>> handler) {
        if (handlers == null)
            handlers = new ArrayList<>(1);
        handlers.add(handler);
    }
}

        if (handlers != null) {
            handlers.forEach(h -> {
                h.handle(new AsyncResult<>(succeeded));
            });
            handlers = null;
        }
        unlock(oldSession, newSession);
    
<methods>public non-sealed void <init>() ,public int addWaitingTransaction(java.lang.Object, com.lealone.transaction.Transaction, com.lealone.db.session.Session) ,public com.lealone.db.lock.LockOwner getLockOwner() ,public abstract java.lang.String getLockType() ,public java.lang.Object getOldValue() ,public com.lealone.transaction.Transaction getTransaction() ,public boolean isLockedExclusivelyBy(com.lealone.db.session.Session) ,public boolean tryLock(com.lealone.transaction.Transaction, java.lang.Object, java.lang.Object) ,public void unlock(com.lealone.db.session.Session, boolean, com.lealone.db.session.Session) ,public void unlock(com.lealone.db.session.Session, com.lealone.db.session.Session) <variables>static final com.lealone.db.lock.NullLockOwner NULL,private final AtomicReference<com.lealone.db.lock.LockOwner> ref