/*
 * Copyright (c) 2014-2021, by Alex Leigh.
 * All rights reserved.
 *
 * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE
 * The copyright notice above does not evidence any
 * actual or intended publication of such source code.
 */

package leigh.esp.goryu.sdk.schema.v1;

import leigh.eo.EO;
import leigh.eo.EOLoop;

/**
 * This is a dynamically generated DAO class for accessing objects within an ESP graph. This class
 * has been generated by <code>DAOGenerator</code> and should not be modified.
 *
 * @author DAOGenerator (synthetically generated class)
 */
public final class DataElementDAO {
    public static final String API_TYPE = "leigh.esp.goryu.v1.Data";

    public static EO create() {
        EO eo = new EO(API_TYPE);
        return eo;
    }

    public static boolean assertType(final EO eo) {
        return eo.getApiType().equals(API_TYPE);
    }

    public static final String KEY_VALUES = "values";

    public static String apiType(final EO eo) {
        return eo.getApiType();
    }


    /* EO{typeName='org.a6v.esp.eo.schema.Loop', data={acceptTypes=EOLoop{array=null} , apiName=values, label=Values}, meta=null} */

    public static void appendValues(EO eo, EO label) {
        EOLoop loop = eo.getValueLoop(KEY_VALUES);
        loop.add(label);
    }


    public static EOLoop getValues(EO eo) {
        EOLoop o = eo.getValueLoop(KEY_VALUES);
        if (o == null) {
            o = new EOLoop();
            eo.setValue(KEY_VALUES, o);
        }
        return o;
    }

    public static void setValues(final EO eo, EOLoop value) {
        if (!assertType(eo))
            throw new IllegalArgumentException("Mismatched EO type: [found: " + eo.getApiType() + "] [expected: " + API_TYPE + "]");
        eo.setValue(KEY_VALUES, value);
    }

    public static void setValuesLabel(final EO eo, final String label) {
        if (!assertType(eo))
            throw new IllegalArgumentException("Mismatched EO type: [found: " + eo.getApiType() + "] [expected: " + API_TYPE + "]");
        eo.setLabel(KEY_VALUES, label);
    }

    public static void getLabelOrValueValues(final EO eo, EOLoop value) {
        if (!assertType(eo))
            throw new IllegalArgumentException("Mismatched EO type: [found: " + eo.getApiType() + "] [expected: " + API_TYPE + "]");
        eo.getLabelOrValue(KEY_VALUES);
    }

    public static void setIfUnsetValues(final EO eo, EOLoop value) {
        if (!assertType(eo))
            throw new IllegalArgumentException("Mismatched EO type: [found: " + eo.getApiType() + "] [expected: " + API_TYPE + "]");
        eo.setValueIfUnset(KEY_VALUES, value);
}


}