001package net.filebot.format;
002
003public class ChannelCount extends AutoUnitDecimal {
004
005        private final boolean layout;
006        private final int streamIndex;
007
008        public ChannelCount(double channels, boolean layout, int streamIndex) {
009                super(channels);
010                this.layout = layout;
011                this.streamIndex = streamIndex;
012        }
013
014        @Override
015        public String getUnit() {
016                return layout ? "" : "ch";
017        }
018
019        @Override
020        public int getFractionDigits() {
021                return layout ? 1 : 0;
022        }
023
024        public int getStreamIndex() {
025                return streamIndex;
026        }
027
028        public static ChannelCount count(Number channels, int streamIndex) {
029                return new ChannelCount(channels.intValue(), false, streamIndex);
030        }
031
032        public static ChannelCount layout(Number channels, int streamIndex) {
033                return new ChannelCount(channels.doubleValue(), true, streamIndex);
034        }
035
036}