net.amygdalum.testrecorder.values.SerializedNull Maven / Gradle / Ivy
package net.amygdalum.testrecorder.values;
import static java.util.Collections.emptyList;
import java.util.Arrays;
import java.util.List;
import net.amygdalum.testrecorder.types.RoleVisitor;
import net.amygdalum.testrecorder.types.ReferenceTypeVisitor;
import net.amygdalum.testrecorder.types.SerializedImmutableType;
import net.amygdalum.testrecorder.types.SerializedValue;
/**
* Serializing to SerializedNull is only valid and strongly recommended for any value that is null. Use the factory method
* {@link #nullInstance()}
*/
public class SerializedNull extends AbstractSerializedReferenceType implements SerializedImmutableType {
public static final SerializedValue VOID = new SerializedNull(void.class);
private SerializedNull(Class> clazz) {
super(clazz);
}
private SerializedNull() {
super(null);
}
@Override
public List referencedValues() {
return emptyList();
}
@Override
public T accept(RoleVisitor visitor) {
return visitor.visitReferenceType(this);
}
@Override
public T accept(ReferenceTypeVisitor visitor) {
return visitor.visitImmutableType(this);
}
public static SerializedNull nullInstance() {
return new SerializedNull();
}
@Override
public int hashCode() {
return Arrays.hashCode(getUsedTypes());
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
SerializedNull that = (SerializedNull) obj;
return Arrays.equals(this.getUsedTypes(), that.getUsedTypes());
}
@Override
public String toString() {
return ValuePrinter.print(this);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy