Updated copyright message.
[meviz.git] / src / main / java / eu / svjatoslav / meviz / encoder / BitrateParameter.java
1 /*
2  * Meviz - Various tools collection to work with multimedia.
3  * Copyright (C) 2012 -- 2018, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of version 2 of the GNU General Public License
7  * as published by the Free Software Foundation.
8  */
9
10 package eu.svjatoslav.meviz.encoder;
11
12 import eu.svjatoslav.commons.commandline.parameterparser.ArgumentCount;
13 import eu.svjatoslav.commons.commandline.parameterparser.Parameter;
14
15 public class BitrateParameter extends Parameter<BitrateParameter.Bitrate, BitrateParameter> {
16
17     public BitrateParameter(final String description) {
18         super(description, ArgumentCount.SINGLE);
19     }
20
21     @Override
22     public String describeFormat() {
23         return "Target bitrate [NONE / LOW / MEDIUM / HIGH / COPY ]";
24     }
25
26     @Override
27     public Bitrate getValue() {
28         return Bitrate.valueOf(arguments.get(0).toUpperCase());
29     }
30
31     @Override
32     public boolean validate(final String value) {
33         try {
34             Bitrate.valueOf(value.toUpperCase());
35         } catch (final IllegalArgumentException exception) {
36             return false;
37         }
38
39         return true;
40     }
41
42     public enum Bitrate {
43         NONE, LOW, MEDIUM, HIGH, COPY
44     }
45 }