
com.linkedin.dagli.util.function.IntDefaultOnNullArgument1 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/DefaultOnNullArgument.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 IntFunction1.Serializable that returns 0 if any of
* the function's inputs are null.
*/
class IntDefaultOnNullArgument1 implements IntFunction1.Serializable {
private static final long serialVersionUID = 1;
private static final int CLASS_HASH = IntDefaultOnNullArgument1.class.hashCode();
private final IntFunction1 _wrapped;
IntDefaultOnNullArgument1(IntFunction1 wrapped) {
// stacking this wrapper multiple times should be idempotent:
if (wrapped instanceof IntDefaultOnNullArgument1) {
_wrapped = ((IntDefaultOnNullArgument1) wrapped)._wrapped;
} else {
_wrapped = Objects.requireNonNull(wrapped);
}
}
@Override
public IntDefaultOnNullArgument1 safelySerializable() {
return new IntDefaultOnNullArgument1<>(((IntFunction1.Serializable) _wrapped).safelySerializable());
}
@Override
public int apply(A value1) {
if (value1 == null) {
return 0;
}
return _wrapped.apply(value1);
}
@Override
public int hashCode() {
return CLASS_HASH + _wrapped.hashCode();
}
@Override
public boolean equals(Object obj) {
if (obj instanceof IntDefaultOnNullArgument1) {
return this._wrapped.equals(((IntDefaultOnNullArgument1) obj)._wrapped);
}
return false;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy