1 // Copyright (c) 2017, the R8 project authors. Please see the AUTHORS file 2 // for details. All rights reserved. Use of this source code is governed by a 3 // BSD-style license that can be found in the LICENSE file. 4 5 package com.android.tools.r8.utils; 6 7 import joptsimple.ValueConversionException; 8 import joptsimple.ValueConverter; 9 10 public enum OffOrAuto { 11 Off, Auto; 12 13 static final ValueConverter<OffOrAuto> CONVERTER = new ValueConverter<OffOrAuto>() { 14 @Override 15 public OffOrAuto convert(String input) { 16 try { 17 input = Character.toUpperCase(input.charAt(0)) + input.substring(1).toLowerCase(); 18 return Enum.valueOf(OffOrAuto.class, input); 19 } catch (Exception e) { 20 throw new ValueConversionException("Value must be one of: " + valuePattern()); 21 } 22 } 23 24 @Override 25 public Class<OffOrAuto> valueType() { 26 return OffOrAuto.class; 27 } 28 29 @Override 30 public String valuePattern() { 31 return "off|auto"; 32 } 33 }; 34 } 35