All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hedera.node.app.statedumpers.legacy.JKeyList Maven / Gradle / Ivy

There is a newer version: 0.57.3
Show newest version
/*
 * Copyright (C) 2020-2024 Hedera Hashgraph, LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.hedera.node.app.statedumpers.legacy;

import com.hederahashgraph.api.proto.java.Key;
import com.hederahashgraph.api.proto.java.KeyList;
import java.util.LinkedList;
import java.util.List;

/** Maps to proto Key of type KeyList. */
public class JKeyList extends JKey {
    private List keys;

    public JKeyList() {
        this.keys = new LinkedList<>();
    }

    public JKeyList(List keys) {
        if (keys == null) {
            throw new IllegalArgumentException("JKeyList cannot be constructed with a null 'keys' argument!");
        }
        this.keys = keys;
    }

    @Override
    public String toString() {
        return "";
    }

    @Override
    public boolean isEmpty() {
        if (keys != null) {
            for (var key : keys) {
                if ((null != key) && !key.isEmpty()) {
                    return false;
                }
            }
        }
        return true;
    }

    @Override
    public boolean isValid() {
        if (isEmpty()) {
            return false;
        } else {
            for (var key : keys) {
                // if any key is null or invalid then this key list is invalid
                if ((null == key) || !key.isValid()) {
                    return false;
                }
            }
            return true;
        }
    }

    @Override
    public boolean hasKeyList() {
        return true;
    }

    public List getKeysList() {
        return keys;
    }

    @Override
    public JKeyList getKeyList() {
        return this;
    }

    @Override
    public void setForScheduledTxn(boolean flag) {
        if (keys != null) {
            for (JKey key : keys) {
                key.setForScheduledTxn(flag);
            }
        }
    }

    @Override
    public boolean isForScheduledTxn() {
        if (keys != null) {
            for (JKey key : keys) {
                if (key.isForScheduledTxn()) {
                    return true;
                }
            }
        }
        return false;
    }

    @Override
    protected Key convertJKeyEmpty() {
        return Key.newBuilder().setKeyList(KeyList.newBuilder().build()).build();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy