1 package com.puppycrawl.tools.checkstyle.checks; 20 21 import java.io.Serializable ; 22 import java.io.ObjectStreamException ; 23 import java.util.Map ; 24 25 32 public abstract class AbstractOption 33 implements Serializable 34 { 35 36 37 private final String mStrRep; 38 39 43 protected AbstractOption(String aStrRep) 44 { 45 mStrRep = aStrRep.trim().toLowerCase(); 46 final Map strToOpt = getStrToOpt(); 47 strToOpt.put(mStrRep, this); 48 } 49 50 54 protected abstract Map getStrToOpt(); 55 56 63 public AbstractOption decode(String aStrRep) 64 { 65 final Map strToOpt = getStrToOpt(); 66 return (AbstractOption) strToOpt.get(aStrRep.trim().toLowerCase()); 67 } 68 69 72 public String toString() 73 { 74 return mStrRep; 75 } 76 77 85 protected Object readResolve() 86 throws ObjectStreamException 87 { 88 return decode(mStrRep); 89 } 90 } 91 | Popular Tags |