/*
 * Java GPX Library (@__identifier__@).
 * Copyright (c) @__year__@ Franz Wilhelmstötter
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Author:
 *    Franz Wilhelmstötter (franz.wilhelmstoetter@gmail.com)
 */
package io.jenetics.jpx;

import static java.lang.String.format;

import java.io.Serializable;

/**
 * Represents a differential GPS station. This object only holds int values in
 * the range of {@code [0..1023]}.
 *
 * @see <a href="https://en.wikipedia.org/wiki/Value_object">Value object</a>
 *
 * @author <a href="mailto:franz.wilhelmstoetter@gmail.com">Franz Wilhelmstötter</a>
 * @version 1.0
 * @since 1.0
 */
public final class DGPSStation extends Number implements Serializable {

	private static final long serialVersionUID = 1L;

	private final int _value;

	/**
	 * Create a new {@code DGPSStation} object.
	 *
	 * @param value the differential GPS station number
	 * @throws IllegalArgumentException if the given station number is not in the
	 *         range of {@code [0..1023]}
	 */
	private DGPSStation(final int value) {
		if (value < 0 || value > 1023) {
			throw new IllegalArgumentException(format(
				"%d is out of range [0, 1023].", value
			));
		}

		_value = value;
	}

	/**
	 * Return the differential GPS station number.
	 *
	 * @return the differential GPS station number
	 */
	public int intValue() {
		return _value;
	}

	@Override
	public double doubleValue() {
		return (double)_value;
	}

	@Override
	public long longValue() {
		return (long)_value;
	}

	@Override
	public float floatValue() {
		return (float)_value;
	}

	@Override
	public int hashCode() {
		return Integer.hashCode(_value);
	}

	@Override
	public boolean equals(final Object obj) {
		return obj instanceof DGPSStation &&
			((DGPSStation)obj)._value == _value;
	}

	@Override
	public String toString() {
		return Integer.toString(_value);
	}


	/* *************************************************************************
	 *  Static object creation methods
	 * ************************************************************************/

	/**
	 * Create a new {@code DGPSStation} object.
	 *
	 * @param value the differential GPS station number
	 * @return a new {@code DGPSStation} object
	 * @throws IllegalArgumentException if the given station number is not in the
	 *         range of {@code [0..1023]}
	 */
	public static DGPSStation of(final int value) {
		return new DGPSStation(value);
	}

	/**
	 * Parses the given object.
	 *
	 * @param object the object to parse
	 * @return the parsed object
	 */
	static DGPSStation parse(final Object object) {
		return object instanceof DGPSStation
			? (DGPSStation)object
			: object instanceof Number
				? of(((Number) object).intValue())
				: object != null
					? of(Integer.parseInt(object.toString()))
					: null;
	}

}

@@ -1170,17 +1170,18 @@
 SStation
- 
+%0A%09
 extends 
@@ -1186,17 +1186,18 @@
 s Number
- 
+%0A%09
 implemen
@@ -1198,17 +1198,46 @@
 plements
- 
+%0A%09%09Comparable%3CDGPSStation%3E,%0A%09%09
 Serializ
@@ -1240,17 +1240,17 @@
 alizable
- 
+%0A
 %7B%0A%0A%09priv
@@ -2103,32 +2103,144 @@
 oat)_value;%0A%09%7D%0A%0A
+%09@Override%0A%09public int compareTo(final DGPSStation other) %7B%0A%09%09return Integer.compare(_value, other._value);%0A%09%7D%0A%0A
 %09@Override%0A%09publ

Implement 'Comparable' interface.