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

ch.openchvote.inspectionclient.writein.PublicData Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (C) 2024 Berner Fachhochschule https://e-voting.bfh.ch
 *
 *  - This program is free software: you can redistribute it and/or modify                           -
 *  - it under the terms of the GNU Affero General Public License as published by                    -
 *  - the Free Software Foundation, either version 3 of the License, or                              -
 *  - (at your option) any later version.                                                            -
 *  -                                                                                                -
 *  - This program 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 Affero General Public License                       -
 *  - along with this program. If not, see .                           -
 */
package ch.openchvote.inspectionclient.writein;

import ch.openchvote.algorithms.protocols.common.model.EventSetup;
import ch.openchvote.algorithms.protocols.common.model.VotingDescriptions;
import ch.openchvote.algorithms.protocols.writein.model.VotingParametersWriteIn;
import ch.openchvote.framework.party.EventData;
import ch.openchvote.protocol.protocols.writein.content.requestresponse.response.RAI1;
import ch.openchvote.protocol.protocols.writein.content.requestresponse.response.REI1;
import ch.openchvote.protocol.protocols.writein.content.userinterface.input.UVI1;
import ch.openchvote.utilities.sequence.ByteArray;
import ch.openchvote.utilities.tuples.Septuple;
import ch.openchvote.utilities.tuples.Tuple;

/**
 * Instances of this class represent the inspection client's public data. The class inherits from the generic
 * {@link Tuple} subclass, that matches with the number of {@link EventData.Data} and {@link EventData.DataMap} objects
 * to store. Convenience methods for accessing the fields with names as specified by the CHVote protocol are provided.
 */
@SuppressWarnings("MissingJavadoc")
public final class PublicData extends Septuple<
        // the administrator's id
        EventData.Data, // AD
        // voter index
        EventData.Data, // v
        // event definition
        EventData.Data, // ES
        EventData.Data, // VP_v
        EventData.Data, // VD_v
        // inspection code
        EventData.DataMap, // bold_i
        EventData.Data> // IC
        implements EventData {

    public PublicData() {
        this(new Data<>(), new Data<>(), new Data<>(), new Data<>(), new Data<>(), new DataMap<>(), new Data<>());
    }

    // private constructor for initializing all fields
    private PublicData(Data AD, Data v, Data ES, Data VP_v, Data VD_v, DataMap bold_i, Data IC) {
        super(AD, v, ES, VP_v, VD_v, bold_i, IC);
    }

    // private copy constructor
    @SuppressWarnings("unused")
    private PublicData(PublicData publicData) {
        this(publicData.get_AD(), publicData.get_v(), publicData.get_ES(), publicData.get_VP_v(), publicData.get_VD_v(), publicData.get_bold_i(), publicData.get_IC());
    }

    public Data get_AD() {
        return this.getFirst();
    }

    public Data get_v() {
        return this.getSecond();
    }

    public Data get_ES() {
        return this.getThird();
    }

    public Data get_VP_v() {
        return this.getFourth();
    }

    public Data get_VD_v() {
        return this.getFifth();
    }

    public DataMap get_bold_i() {
        return this.getSixth();
    }

    public Data get_IC() {
        return this.getSeventh();
    }

    /**
     * Calling this method stores the given content of type {@link RAI1} into the inspection client's public data.
     *
     * @param content The given content
     */
    public void setContent(RAI1 content) {
        this.get_ES().set(content.get_ES());
        this.get_VP_v().set(content.get_VP());
        this.get_VD_v().set(content.get_VD());
    }

    /**
     * Calling this method stores the given content of type {@link REI1} into the inspection client's public data.
     *
     * @param index   The index of the received content
     * @param content The given content
     */
    public void setContent(int index, REI1 content) {
        this.get_bold_i().set(index, content.get_I());
    }

    /**
     * Calling this method stores the given content of type {@link UVI1} into the inspection client's public data.
     *
     * @param content The given content
     */
    public void setContent(UVI1 content) {
        this.get_AD().set(content.get_AD());
        this.get_v().set(content.get_v());
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy