
com.linkedin.dagli.util.function.IntComposedFunction1 Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of util-function Show documentation
Show all versions of util-function Show documentation
DAG-oriented machine learning framework for bug-resistant, readable, efficient, maintainable and trivially deployable models in Java and other JVM languages
// AUTOGENERATED CODE. DO NOT MODIFY DIRECTLY! Instead, please modify the util/function/ComposedFunction.ftl file.
// See the README in the module's src/template directory for details.
package com.linkedin.dagli.util.function;
import java.util.Objects;
/**
* A function class implementing {@link IntFunction1.Serializable} that composes
* {@link IntFunction1} with a {@link Function1}. The function is only actually serializable
* if its constituent composed functions are serializable, of course.
*/
class IntComposedFunction1 implements IntFunction1.Serializable {
private static final long serialVersionUID = 1;
private final Function1 _first;
private final IntFunction1 super Q> _andThen;
/**
* Creates a new instance that composes two functions, i.e. {@code andThen(first(inputs))}.
*
* @param first the first function to be called in the composition
* @param andThen the second function to be called in the composition, accepting the {@code first} functions result
* as input
*/
IntComposedFunction1(Function1 first, IntFunction1 super Q> andThen) {
_first = first;
_andThen = andThen;
}
@Override
@SuppressWarnings("unchecked")
public IntComposedFunction1 safelySerializable() {
return new IntComposedFunction1<>(((Function1.Serializable) _first).safelySerializable(),
((IntFunction1.Serializable super Q>) _andThen).safelySerializable());
}
@Override
public int apply(A value1) {
return _andThen.apply(_first.apply(value1));
}
@Override
public int hashCode() {
return Objects.hash(IntComposedFunction1.class, _first, _andThen);
}
@Override
public boolean equals(Object obj) {
if (obj instanceof IntComposedFunction1) {
return this._first.equals(((IntComposedFunction1) obj)._first)
&& this._andThen.equals(((IntComposedFunction1) obj)._andThen);
}
return false;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy