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

io.legaldocml.akn.element.Result Maven / Gradle / Ivy

package io.legaldocml.akn.element;

import com.google.common.collect.ImmutableMap;
import io.legaldocml.akn.AknAttributes;
import io.legaldocml.akn.type.ResultType;
import io.legaldocml.io.CharArray;
import io.legaldocml.io.Externalizable;
import io.legaldocml.io.XmlWriter;
import io.legaldocml.io.impl.Buffers;

import java.io.IOException;
import java.util.function.BiConsumer;

import static io.legaldocml.akn.AknElements.RESULT;
import static io.legaldocml.akn.element.Attributes.biConsumerEnum;
import static io.legaldocml.akn.util.XmlWriterHelper.writeResultType;
import static io.legaldocml.unsafe.UnsafeHelper.getFieldOffset;

/**
 * The element result is a metadata element specifying the overall result of the judgment.
 *
 * 
 *   
 * 	   
 *       
 *         
 *           
 *         
 *       
 *     
 *   
 * 
 *
 * @author Jacques Militello
 */
public final class Result extends AnyOtherType implements io.legaldocml.akn.attribute.ResultType {

    /**
     * Memory address.
     */
    private static final long ADDRESS_RESULT = Buffers.address(RESULT);

    private static final ImmutableMap> ATTRIBUTES;

    static {
        ATTRIBUTES = ImmutableMap.>builder()
                .putAll(AnyOtherType.ATTRIBUTES)
                .put(AknAttributes.TYPE, biConsumerEnum(getFieldOffset(Result.class, "type"), ResultType.class))
                .build();
    }

    private ResultType type;

    /**
     * {@inheritDoc}
     */
    @Override
    public void setType(ResultType type) {
        this.type = type;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public ResultType getType() {
        return this.type;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void write(XmlWriter writer) throws IOException {
        writer.writeStart(ADDRESS_RESULT, 6);
        writeResultType(writer, this);
        super.write(writer);
        writer.writeEnd(ADDRESS_RESULT, 6);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public String name() {
        return RESULT;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public ImmutableMap> attributes() {
        return ATTRIBUTES;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy