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

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

The newest version!

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

package io.permazen.encoding;

import com.google.common.base.Converter;
import com.google.common.base.Preconditions;

import io.permazen.tuple.Tuple4;

import java.util.function.Function;

/**
 * Support superclass for non-null {@link Encoding}s of values that can be decomposed into four component values.
 *
 * 

* Null values are not supported by this class and there is no default value. * * @param this encoding's value type * @param first tuple value type * @param second tuple value type * @param third tuple value type * @param fourth tuple value type */ public abstract class Concat4Encoding extends ConvertedEncoding> { private static final long serialVersionUID = -7395218884659436175L; /** * Constructor. * * @param type Java type for this encoding's values * @param encoding1 first value encoding * @param encoding2 second value encoding * @param encoding3 third value encoding * @param encoding4 fourth value encoding * @param splitter1 first value splitter * @param splitter2 second value splitter * @param splitter3 third value splitter * @param splitter4 fourth value splitter * @param joiner value joiner from tuple * @throws IllegalArgumentException if any parameter is null */ protected Concat4Encoding(Class type, Encoding encoding1, Encoding encoding2, Encoding encoding3, Encoding encoding4, Function splitter1, Function splitter2, Function splitter3, Function splitter4, Function, ? extends T> joiner) { super(null, type, new Tuple4Encoding<>(encoding1, encoding2, encoding3, encoding4), Converter.from( value -> new Tuple4<>(splitter1.apply(value), splitter2.apply(value), splitter3.apply(value), splitter4.apply(value)), joiner::apply)); Preconditions.checkArgument(splitter1 != null, "null splitter1"); Preconditions.checkArgument(splitter2 != null, "null splitter2"); Preconditions.checkArgument(splitter3 != null, "null splitter3"); Preconditions.checkArgument(splitter4 != null, "null splitter4"); Preconditions.checkArgument(joiner != null, "null joiner"); } @SuppressWarnings("unchecked") public Tuple4Encoding getTuple4Encoding() { return (Tuple4Encoding)this.delegate; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy