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

io.permazen.encoding.Concat3Encoding 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.Tuple3;

import java.util.function.Function;

/**
 * Support superclass for non-null {@link Encoding}s of values that can be decomposed into three 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 */ public abstract class Concat3Encoding extends ConvertedEncoding> { private static final long serialVersionUID = -7395218884659436174L; /** * 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 splitter1 first value splitter * @param splitter2 second value splitter * @param splitter3 third value splitter * @param joiner value joiner from tuple * @throws IllegalArgumentException if any parameter is null */ protected Concat3Encoding(Class type, Encoding encoding1, Encoding encoding2, Encoding encoding3, Function splitter1, Function splitter2, Function splitter3, Function, ? extends T> joiner) { super(null, type, new Tuple3Encoding<>(encoding1, encoding2, encoding3), Converter.from( value -> new Tuple3<>(splitter1.apply(value), splitter2.apply(value), splitter3.apply(value)), joiner::apply)); Preconditions.checkArgument(splitter1 != null, "null splitter1"); Preconditions.checkArgument(splitter2 != null, "null splitter2"); Preconditions.checkArgument(splitter3 != null, "null splitter3"); Preconditions.checkArgument(joiner != null, "null joiner"); } @SuppressWarnings("unchecked") public Tuple3Encoding getTuple3Encoding() { return (Tuple3Encoding)this.delegate; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy