001package jmri.jmrit.logixng.expressions;
002
003import java.util.Locale;
004import java.util.Map;
005
006import jmri.InstanceManager;
007import jmri.jmrit.logixng.*;
008
009/**
010 * Always evaluates to True.
011 * 
012 * @author Daniel Bergqvist Copyright 2018
013 */
014public class True extends AbstractDigitalExpression {
015
016    public True(String sys, String user)
017            throws BadUserNameException, BadSystemNameException {
018        super(sys, user);
019    }
020    
021    @Override
022    public Base getDeepCopy(Map<String, String> systemNames, Map<String, String> userNames) {
023        DigitalExpressionManager manager = InstanceManager.getDefault(DigitalExpressionManager.class);
024        String sysName = systemNames.get(getSystemName());
025        String userName = userNames.get(getSystemName());
026        if (sysName == null) sysName = manager.getAutoSystemName();
027        DigitalExpressionBean copy = new True(sysName, userName);
028        copy.setComment(getComment());
029        return manager.registerExpression(copy);
030    }
031    
032    /** {@inheritDoc} */
033    @Override
034    public Category getCategory() {
035        return Category.OTHER;
036    }
037    
038    /** {@inheritDoc} */
039    @Override
040    public boolean evaluate() {
041        return true;
042    }
043    
044    @Override
045    public FemaleSocket getChild(int index) throws IllegalArgumentException, UnsupportedOperationException {
046        throw new UnsupportedOperationException("Not supported.");
047    }
048    
049    @Override
050    public int getChildCount() {
051        return 0;
052    }
053    
054    @Override
055    public String getShortDescription(Locale locale) {
056        return Bundle.getMessage(locale, "True_Short");
057    }
058    
059    @Override
060    public String getLongDescription(Locale locale) {
061        return Bundle.getMessage(locale, "True_Long");
062    }
063
064    /** {@inheritDoc} */
065    @Override
066    public void setup() {
067        // Do nothing
068    }
069    
070    /** {@inheritDoc} */
071    @Override
072    public void registerListenersForThisClass() {
073    }
074    
075    /** {@inheritDoc} */
076    @Override
077    public void unregisterListenersForThisClass() {
078    }
079    
080    /** {@inheritDoc} */
081    @Override
082    public void disposeMe() {
083    }
084
085}