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

net.amygdalum.testrecorder.values.SerializedImmutable Maven / Gradle / Ivy

package net.amygdalum.testrecorder.values;

import static java.util.Collections.emptyList;

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 SerializedImmutable is restricted to objects of a class that complies with following criteria:
 * - it is a class with immutable values (like BigInteger, BigDecimal ...)
 * - each custom serialized immutable class needs its own deserializer
 *    
 */
public class SerializedImmutable extends AbstractSerializedReferenceType implements SerializedImmutableType {

	private V value;

	public SerializedImmutable(Class type) {
		super(type);
	}

	public SerializedImmutable withValue(V value) {
		this.value = value;
		return this;
	}
	
	public V getValue() {
		return value;
	}

	public void setValue(V value) {
		this.value = value;
	}

	@Override
	public List referencedValues() {
		return emptyList();
	}

	@Override
	public  T accept(RoleVisitor visitor) {
		return visitor.visitImmutableType(this);
	}

	@Override
	public  T accept(ReferenceTypeVisitor visitor) {
		return visitor.visitImmutableType(this);
	}

	@Override
	public String toString() {
		return ValuePrinter.print(this);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy