package common.tags;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

class TagFloat extends Tag {
	private float data;

	TagFloat() {
	}

	public TagFloat(float data) {
		this.data = data;
	}

	void write(DataOutput output) throws IOException {
		output.writeFloat(this.data);
	}

	void read(DataInput input, int depth, SizeTracker tracker) throws IOException {
		tracker.read(12);
		this.data = input.readFloat();
	}

	TagType getType() {
		return TagType.FLOAT;
	}

	public String toString() {
		return "" + this.data + "f";
	}

	public Tag copy() {
		return new TagFloat(this.data);
	}

	public boolean equals(Object other) {
		return super.equals(other) && this.data == ((TagFloat)other).data;
	}

	public int hashCode() {
		return super.hashCode() ^ Float.floatToIntBits(this.data);
	}

	public float getFloat() {
		return this.data;
	}
}
