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

io.permazen.encoding.Tuple4Encoding Maven / Gradle / Ivy

The newest version!

/*
 * Copyright (C) 2015 Archie L. Cobbs. All rights reserved.
 */

package io.permazen.encoding;

import com.google.common.reflect.TypeParameter;
import com.google.common.reflect.TypeToken;

import io.permazen.tuple.Tuple4;

/**
 * Non-null {@link Encoding} for a {@link Tuple4} created by concatenating the component {@link Encoding}s.
 *
 * 

* Null values are not supported by this class and there is no default value. */ public class Tuple4Encoding extends TupleEncoding> { private static final long serialVersionUID = 7251327021306850353L; /** * Constructor. * * @param value1Encoding component value encoding * @param value2Encoding component value encoding * @param value3Encoding component value encoding * @param value4Encoding component value encoding * @throws IllegalArgumentException if any component value encoding is null */ @SuppressWarnings("serial") public Tuple4Encoding(Encoding value1Encoding, Encoding value2Encoding, Encoding value3Encoding, Encoding value4Encoding) { super(new TypeToken>() { } .where(new TypeParameter() { }, value1Encoding.getTypeToken().wrap()) .where(new TypeParameter() { }, value2Encoding.getTypeToken().wrap()) .where(new TypeParameter() { }, value3Encoding.getTypeToken().wrap()) .where(new TypeParameter() { }, value4Encoding.getTypeToken().wrap()), value1Encoding, value2Encoding, value3Encoding, value4Encoding); } @SuppressWarnings("unchecked") public Encoding getEncoding1() { return (Encoding)this.encodings.get(0); } @SuppressWarnings("unchecked") public Encoding getEncoding2() { return (Encoding)this.encodings.get(1); } @SuppressWarnings("unchecked") public Encoding getEncoding3() { return (Encoding)this.encodings.get(2); } @SuppressWarnings("unchecked") public Encoding getEncoding4() { return (Encoding)this.encodings.get(3); } @Override @SuppressWarnings("unchecked") protected Tuple4 createTuple(Object[] values) { assert values.length == 4; return new Tuple4<>((V1)values[0], (V2)values[1], (V3)values[2], (V4)values[3]); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy