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

io.github.thunderz99.cosmos.dto.RecordData Maven / Gradle / Ivy

There is a newer version: 0.7.11
Show newest version
package io.github.thunderz99.cosmos.dto;

import io.github.thunderz99.cosmos.util.JsonUtil;

/**
 * A simple bean class with built-in hashCode/equals/toString implement
 */
public abstract class RecordData {

	public RecordData() {
	}

	@Override
	public String toString() {
		return JsonUtil.toJson(this);
	}

	@Override
	public int hashCode() {
		return this.toString().hashCode();
	}

	@Override
	public boolean equals(Object obj2) {
		if (obj2 == null) {
			return false;
		}

		return this.toString().equals(obj2.toString());
	}

	/**
	 * deep copy using json util
	 * @param  generic param for bean
	 *
	 * @return object copied
	 */
	public  T copy() {
		return JsonUtil.fromJson(JsonUtil.toJson(this), this.getClass().getName());
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy