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

com.versionone.apiclient.Monad Maven / Gradle / Ivy

Go to download

A library for custom Java development against the VersionOne Development Platform's REST API.

There is a newer version: 16.1.3
Show newest version
package com.versionone.apiclient;

import com.versionone.utils.HashCode;

class Monad extends Tuple {
	private Object value;

	public Object getValue() {
		return (value == Null) ? null : value;
	}

	public Monad(Object value) {
		this.value = value == null ? Null : value;
	}

	public static boolean compare(Monad m1, Monad m2) {
		if (null != m1)
			return m1.equals(m2);
		return null == m2;
	}

	@Override
	public boolean equals(Object obj) {
		boolean rc = false;

		if (null != obj && obj instanceof Monad) {
			Monad other = (Monad) obj;
			rc = this.value.equals(other.value);
		}

        return rc;
	}

	@Override
	public Object get(int i) {
		if (i != 0) {
			throw new java.lang.IndexOutOfBoundsException();
        }

		return getValue();
	}

	@Override
	public int hashCode() {
		return HashCode.Hash(getValue());
	}

	@Override
	public Object[] toArray() {
		return new Object[] { getValue() };
	}

	@Override
	public int getSize() {
		return 1;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy