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

org.decision_deck.jmcda.structure.DecisionMaker Maven / Gradle / Ivy

Go to download

The base classes of the J-MCDA project. Contains the main structure classes that define MCDA concepts such as alternatives and performance matrixes.

The newest version!
package org.decision_deck.jmcda.structure;

import com.google.common.base.Function;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;

/**
 * 

* A decision maker object. Has a unique id (not null). *

*

* Objects of this type are immutable. *

*

* A decision maker {@link #equals(Object)} an other one iff they have the same id. *

* * @author Olivier Cailloux * */ public class DecisionMaker implements Comparable { @Override public String toString() { final ToStringHelper helper = Objects.toStringHelper(this); helper.addValue(m_id); return helper.toString(); } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((m_id == null) ? 0 : m_id.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } DecisionMaker other = (DecisionMaker) obj; if (m_id == null) { if (other.m_id != null) { return false; } } else if (!m_id.equals(other.m_id)) { return false; } return true; } private String m_id; /** * @param id * not null, not empty. */ public DecisionMaker(String id) { if (id == null || id.trim().length() == 0) { throw new NullPointerException("" + id); } m_id = id; } public String getId() { return m_id; } @Override public int compareTo(DecisionMaker o) { return m_id.compareTo(o.m_id); } /** *

* Retrieves a function which gives the id of the given decision maker. No null values are accepted. *

*

* This provides an easy way to get short debug strings. E.g. to get a string representing the contents of a set of * decision makers s, use Joiner.on(", ").join(Iterables.transform(s, getIdFct())). *

* * @return not null. */ static public Function getIdFct() { final Function namer = new Function() { @Override public String apply(DecisionMaker input) { return input.getId(); } }; return namer; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy