001package jmri.jmrit.logixng.util;
002
003import java.text.MessageFormat;
004
005/**
006 * Units for timer classes.
007 * 
008 * @author Daniel Bergqvist Copyright 2021
009 */
010public enum TimerUnit {
011    
012    MilliSeconds(1, Bundle.getMessage("TimerUnit_UnitMilliSeconds"), Bundle.getMessage("TimerUnit_TimeMilliSeconds")),
013    Seconds(1000, Bundle.getMessage("TimerUnit_UnitSeconds"), Bundle.getMessage("TimerUnit_TimeSeconds")),
014    Minutes(1000 * 60, Bundle.getMessage("TimerUnit_UnitMinutes"), Bundle.getMessage("TimerUnit_TimeMinutes")),
015    Hours(1000 * 60 * 60, Bundle.getMessage("TimerUnit_UnitHours"), Bundle.getMessage("TimerUnit_TimeHours"));
016    
017    private final long _multiply;
018    private final String _text;
019    private final String _timeText;
020    
021    private TimerUnit(long multiply, String text, String timeText) {
022        this._multiply = multiply;
023        this._text = text;
024        this._timeText = timeText;
025    }
026    
027    public long getMultiply() {
028        return _multiply;
029    }
030    
031    @Override
032    public String toString() {
033        return _text;
034    }
035    
036    public String getTimeWithUnit(int time) {
037        return MessageFormat.format(_timeText, time);
038    }
039    
040}