/* ************************************************************************
#
#  DivConq
#
#  http://divconq.com/
#
#  Copyright:
#    Copyright 2012 eTimeline, LLC. All rights reserved.
#
#  License:
#    See the license.txt file in the project's top-level directory for details.
#
#  Authors:
#    * Andy White
#
************************************************************************ */
package divconq.struct.scalar;

import divconq.struct.ScalarStruct;

public class NullStruct extends ScalarStruct {
	@Override
	public Object getGenericValue() {
		return null;
	}
	
	@Override
	public void adaptValue(Object v) {
		// NA
	}

	public Object getValue() {
		return null; 
	}
	
	@Override
	public boolean isEmpty() {
		return false;
	}

	@Override
	public Object clone() {
		NullStruct n = new NullStruct();
		//n.setName(this.name);
		return n;
	}

	@Override
	public boolean equals(Object obj) {
		return (NullStruct.comparison(this, obj) == 0);
	}

	@Override
	public int compare(Object y) {
		return NullStruct.comparison(this, y);
	}

	@Override
	public int hashCode() {
		return 0;
	}
	
	@Override
	public String toString() {
		return "null";
	}

	public static int comparison(Object x, Object y) {
		if ((y == null) && (x == null))
			return 0;

		if (y == null)
			return 1;

		if (x == null)
			return -1;

		return 0;
	}
}
