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

ai.platon.pulsar.common.ScoreEntry Maven / Gradle / Ivy

There is a newer version: 2.1.0
Show newest version
package ai.platon.pulsar.common;

import ai.platon.pulsar.common.config.Params;

import javax.annotation.Nonnull;

/**
 * Created by vincent on 17-4-20.
 * Copyright @ 2013-2023 Platon AI. All rights reserved
 *
 * @author vincent
 * @version $Id: $Id
 */
public class ScoreEntry implements Comparable {

    
    public static final int DEFAULT_DIGITS = 5;

    private String name;
    private int priority;
    private int value;
    // Reserved for optimization
    private int digits = DEFAULT_DIGITS;

    /**
     * 

Constructor for ScoreEntry.

* * @param name a {@link java.lang.String} object. * @param value a int. */ public ScoreEntry(String name, int value) { this(name, 0, value, DEFAULT_DIGITS); } /** *

Constructor for ScoreEntry.

* * @param name a {@link java.lang.String} object. * @param priority a int. * @param value a int. */ public ScoreEntry(String name, int priority, int value) { this(name, priority, value, DEFAULT_DIGITS); } /** *

Constructor for ScoreEntry.

* * @param name a {@link java.lang.String} object. * @param priority a int. * @param value a int. * @param digits a int. */ public ScoreEntry(String name, int priority, int value, int digits) { this.name = name; this.priority = priority; this.value = value; this.digits = digits; } /** *

Constructor for ScoreEntry.

* * @param other a {@link ai.platon.pulsar.common.ScoreEntry} object. */ public ScoreEntry(ScoreEntry other) { this.name = other.name; this.priority = other.priority; this.value = other.value; this.digits = other.digits; } /** *

Getter for the field name.

* * @return a {@link java.lang.String} object. */ public String getName() { return name; } /** *

Setter for the field name.

* * @param name a {@link java.lang.String} object. */ public void setName(String name) { this.name = name; } /** *

Getter for the field priority.

* * @return a int. */ public int getPriority() { return priority; } /** *

Setter for the field priority.

* * @param priority a int. */ public void setPriority(int priority) { this.priority = priority; } /** *

Getter for the field value.

* * @return a int. */ public int getValue() { return value; } /** *

Setter for the field value.

* * @param value a int. */ public void setValue(int value) { this.value = value; } /** *

Getter for the field digits.

* * @return a int. */ public int getDigits() { return digits; } /** *

Setter for the field digits.

* * @param digits a int. */ public void setDigits(int digits) { this.digits = digits; } /** {@inheritDoc} */ @Override public ScoreEntry clone() { return new ScoreEntry(name, priority, value, digits); } /** {@inheritDoc} */ @Override public String toString() { return Params.formatAsLine( "name", name, "priority", priority, "value", value, "digits", digits ); } /** {@inheritDoc} */ @Override public boolean equals(Object other) { if (this == other) { return true; } return other instanceof ScoreEntry && compareTo((ScoreEntry) other) == 0; } /** {@inheritDoc} */ @Override public int compareTo(@Nonnull ScoreEntry scoreEntry) { int diff = priority - scoreEntry.priority; if (diff != 0) { return diff; } return value - scoreEntry.value; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy