1 package net.avcompris.commons3.web; 2 3 import static com.google.common.base.Preconditions.checkNotNull; 4 5 import net.avcompris.commons3.utils.Level; 6 import net.avcompris.commons3.utils.LogFactory; 7 8 public abstract class AbstractConfig { 9 10 public final boolean inMemory; 11 public final boolean rds; 12 13 protected AbstractConfig(final AbstractApplicationArgs myargs) { 14 15 checkNotNull(myargs, "myargs"); 16 17 if (myargs.inMemory) { 18 19 inMemory = true; 20 rds = false; 21 22 } else if (myargs.rds) { 23 24 inMemory = false; 25 rds = true; 26 27 } else { 28 29 throw new IllegalStateException( 30 "Either \"--inMemory\" or \"--rds\" must be specified when launching the application."); 31 } 32 33 if (myargs.debug || System.getProperty("debug") != null) { 34 35 LogFactory.setLevel(Level.DEBUG); 36 37 } else if (myargs.info) { 38 39 LogFactory.setLevel(Level.INFO); 40 41 } else if (myargs.warn) { 42 43 LogFactory.setLevel(Level.WARN); 44 45 } else if (myargs.error) { 46 47 LogFactory.setLevel(Level.ERROR); 48 49 } else { 50 51 LogFactory.setLevel(Level.INFO); 52 } 53 } 54 }