package aalg.algebra;

import java.math.BigInteger;

/**
 * Element of prime field.
 * @author Ing. Petr Ležák
 */
public class PrimeFieldElement implements IElement {
	
	public static final PrimeFieldElement ZERO = new PrimeFieldElement(BigInteger.ZERO);
	public static final PrimeFieldElement ONE = new PrimeFieldElement(BigInteger.ONE);

	private final BigInteger number;
	
	/**
	 * Creates prime field element with given number.
	 * @param number number
	 */
	public PrimeFieldElement(final BigInteger number) {
		this.number = number;
	}

	/**
	 * Returns number.
	 * @return number
	 */
	public BigInteger getNumber() {
		return number;
	}

	@Override
	public boolean equals (final Object obj) {
		if (!(obj instanceof PrimeFieldElement))
			return false;
		
		final PrimeFieldElement cmp = (PrimeFieldElement) obj;
		
		return number.equals(cmp.number);
	}
	
	@Override
	public int hashCode() {
		return number.hashCode();
	}
	
	@Override
	public String toString() {
		return number.toString();
	}
	
}
