35. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 3/24/2017 5:17:19 PM Eastern Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

35.1 Files compared

# Location File Last Modified
1 MHV_2017.2.0.0 Code In Flight.zip\National Portal\mhv_rxrefill\mhv-rx-refill-portal-main\src\main\java\gov\va\med\domain\typecode TypeCodeAbstract.java Thu Feb 11 17:10:26 2016 UTC
2 MHV_2017.2.0.0 Code In Flight.zip\National Portal\mhv_rxrefill\mhv-rx-refill-portal-main\src\main\java\gov\va\med\domain\typecode TypeCodeAbstract.java Fri Mar 24 20:33:53 2017 UTC

35.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 2 550
Changed 1 2
Inserted 0 0
Removed 0 0

35.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

35.4 Active regular expressions

No regular expressions were active.

35.5 Comparison detail

  1   package go v.va.med.d omain.type code;
  2  
  3   import jav a.util.Arr ayList;
  4   import jav a.util.Col lections;
  5   import jav a.util.Com parator;
  6   import jav a.util.Has hMap;
  7   import jav a.util.Ite rator;
  8   import jav a.util.Lis t;
  9   import jav a.util.Map ;
  10   import jav a.util.NoS uchElement Exception;
  11  
  12   import org .apache.lo gging.log4 j.LogManag er;
  13   import org .apache.lo gging.log4 j.Logger;
  14   import org .springfra mework.uti l.Assert;
  15  
  16   /*
  17    * This cl ass implem ents an ab straction  of the typ e-safe enu meration p attern, ex posing met hods that
  18    * return  sorted var ieties of  the instan ces of a s pecific co ncrete typ e. All sub classes sh ould
  19    * declare  private c onstructor s. 
  20    * @author   PII  Apr 12, 2 005 9:19:5 8 AM
  21    */
  22   public abs tract clas s TypeCode Abstract i mplements  TypeCode {
  23           pr ivate stat ic Logger  logger = L ogManager. getLogger( TypeCodeAb stract.cla ss);
  24           pr ivate Obje ct code;
  25           pr ivate Stri ng descrip tion;
  26           pr ivate Stri ng label;
  27           pr ivate stat ic Map typ eCache = n ew HashMap ();
  28  
  29           pr otected Ty peCodeAbst ract(Objec t code, St ring label , String d escription ) {
  30                    setC ode(code);
  31                    setL abel(label );
  32                    setD escription (descripti on);
  33                    putC ode(this);
  34           }
  35  
  36           pr otected Ty peCodeAbst ract(Objec t code, St ring label ) {
  37                    this (code, lab el, label) ;
  38           }
  39  
  40           /* *
  41            *  Return a  type code  instance f or a given  class typ e that map s back to  a given co de value.
  42            *  
  43            *  @param va lue
  44            *  @return T ypeCodeAbs tract
  45            * /
  46           pu blic stati c TypeCode  codeForVa lue(Class  target, Ob ject value ) {
  47                    retu rn fetchCo deCache(ta rget).find Code(value );
  48           }
  49  
  50           /* *
  51            *  Return an  array of  type codes , sorted b y their co des.
  52            *  @param ty pe
  53            *  @return T ypeCode[]
  54            * /
  55           pu blic stati c TypeCode [] sortByC ode(Class  type) {
  56                    retu rn fetchCo deCache(ty pe).sortBy Code();
  57           }
  58  
  59           /* *
  60            *  Return an  array of  type codes , sorted b y their la bels.
  61            *  @param ty pe
  62            *  @return T ypeCode[]
  63            * /
  64           pu blic stati c TypeCode [] sortByL abel(Class  type) {
  65                    retu rn fetchCo deCache(ty pe).sortBy Label();
  66           }
  67  
  68           /* *
  69            *  Return a  boolean in dicator of  whether a n instance  of the gi ven type c ode class  maps to th e
  70            *  specified  code valu e.
  71            *  @param ty pe
  72            *  @param co deValue
  73            *  @return b oolean
  74            * /
  75           pu blic stati c boolean  isDefined( Class type , Object c odeValue)  {
  76                    retu rn fetchCo deCache(ty pe).contai ns(codeVal ue);
  77           }
  78  
  79           /*
  80            *  Compare t o another  TypeCodeAb stract ins tance.
  81            *  @see java .lang.Comp arable#com pareTo(jav a.lang.Obj ect)
  82            * /
  83           pu blic int c ompareTo(O bject othe r) {
  84                    retu rn ((Compa rable)getC ode()).com pareTo(((T ypeCodeAbs tract)othe r).getCode ());
  85           }
  86  
  87           /* *
  88            *  Return th e code of  this type  code insta nce.
  89            *  
  90            *  @return O bject
  91            * /
  92           pu blic Objec t getCode( ) {
  93                    retu rn this.co de;
  94           }
  95  
  96           /* *
  97            *  Return th e descript ion of thi s type cod e instance .
  98            *  
  99            *  @return R eturns the  descripti on.
  100            * /
  101           pu blic Strin g getDescr iption() {
  102                    retu rn descrip tion;
  103           }
  104  
  105           /* *
  106            *  Return th e label of  this type code insta nce.
  107            *  
  108            *  @return R eturns the  label.
  109            * /
  110           pu blic Strin g getLabel () {
  111                    retu rn label;
  112           }
  113  
  114           /*
  115            *  Override  superclass  equals to  declare a s final. T his preven ts subclas ses from b reaking th e
  116            *  equals co ntract and  allows fo r safe ide ntity comp arison (wi th "==").
  117            *  
  118            *  @see java .lang.Obje ct#equals( java.lang. Object)
  119            * /
  120           pu blic final  boolean e quals(Obje ct obj) {
  121                    retu rn super.e quals(obj) ;
  122           }
  123  
  124           /*
  125            *  Override  superclass  hashCode  to declare  as final.  This prev ents subcl asses from  breaking  the
  126            *  hashCode  contract.
  127            *  
  128            *  @see java .lang.Obje ct#hashCod e()
  129            * /
  130           pu blic final  int hashC ode() {
  131                    retu rn super.h ashCode();
  132           }
  133  
  134           /* *
  135            *  Cache a t ypeCode in stance in  its approp riate cach e, keyed b y its code  value.
  136            *  
  137            *  @param ty peCode
  138            * /
  139           pr ivate stat ic void pu tCode(Type Code typeC ode) {
  140                    Code Cache code Cache = fe tchCodeCac he(typeCod e.getClass ());
  141                    code Cache.putC ode(typeCo de);
  142           }
  143  
  144           pr ivate stat ic CodeCac he fetchCo deCache(Cl ass target ) {
  145                    Asse rt.notNull (target, " Target cla ss cannot  be null.") ;
  146                    Asse rt.isTrue( TypeCode.c lass.isAss ignableFro m(target),  "Target c lass [" +  target.get Name()
  147                                      + "] doe s not impl ement " +  TypeCode.c lass.getNa me());
  148                    
  149                    Code Cache code Cache = (C odeCache)t ypeCache.g et(target) ;
  150  
  151                    if(c odeCache = = null) {
  152                             codeCa che = new  CodeCache( target);
  153                             typeCa che.put(ta rget, code Cache);
  154                    }
  155  
  156                    retu rn codeCac he;
  157           }
  158  
  159           /* *
  160            *  Set the c ode of thi s instance . Private,  as it sho uld be set  only on c onstructio n.
  161            *  
  162            *  @param co de The cod e to set.
  163            * /
  164           pr ivate void  setCode(O bject code ) {
  165                    Asse rt.notNull (code, "Co de value f or a type  code canno t be null. ");
  166                    this .code = co de;
  167           }
  168  
  169           /* *
  170            *  Set the d escription  of this i nstance. P rivate, as  it should  be set on ly on cons truction.
  171            *  
  172            *  @param de scription
  173            * /
  174           pr ivate void  setDescri ption(Stri ng descrip tion) {
  175                    Asse rt.notNull (descripti on, "Descr iption val ue for a t ype code c annot be n ull.");
  176                    this .descripti on = descr iption;
  177           }
  178  
  179           /* *
  180            *  Set the l abe of thi s instance . Private,  as it sho uld be set  only on c onstructio n.
  181            *  
  182            *  @param la bel
  183            * /
  184           pr ivate void  setLabel( String lab el) {
  185                    Asse rt.notNull (label, "L abel value  for a typ e code can not be nul l.");
  186                    this .label = l abel;
  187           }
  188  
  189           /*
  190            *  (non-Java doc)
  191            *  
  192            *  @see java .lang.Obje ct#toStrin g()
  193            * /
  194           pu blic Strin g toString () {
  195                    retu rn getClas s().getNam e() + ": c ode: " + g etCode() +  "; label:  " + getLa bel()
  196                                      + "; des cription:  " + getDes cription() ;
  197           }
  198  
  199           /* *
  200            *  Inner cla ss for cac heing of e numerated  type insta nces.
  201            * /
  202           pr ivate stat ic class C odeCache {
  203                    priv ate Map co des;
  204                    priv ate Class  parent;
  205  
  206                    priv ate CodeCa che(Class  parent) {
  207                             this.p arent = pa rent;
  208                             codes  = new Hash Map();
  209                    }
  210  
  211                    priv ate TypeCo de getCode (Object co deValue) {
  212                             return  (TypeCode )codes.get (codeValue );
  213                    }
  214  
  215                    priv ate TypeCo de findCod e(Object c odeValue)  {
  216                             TypeCo de typeCod e = (TypeC ode)codes. get(codeVa lue);
  217  
  218                             if(typ eCode == n ull) {
  219                                      if(logge r.isDebugE nabled())
  220                                               logger.deb ug(this);
  221  
  222                                      throw ne w NoSuchEl ementExcep tion("No i nstance of  type code  ["
  223                                                       +  parent.get Name() + " ] exists w ith code v alue " + c odeValue);
  224                             }
  225  
  226                             return  typeCode;
  227                    }
  228  
  229                    priv ate boolea n contains (Object co deValue) {
  230                             return  codes.con tainsKey(c odeValue);
  231                    }
  232  
  233                    priv ate synchr onized voi d putCode( TypeCode t ypeCode) {
  234                             if(cod es.contain sKey(typeC ode.getCod e()))
  235                                      throw ne w IllegalA rgumentExc eption("Ty peCode ins tance of t ype " + ty peCode.get Class().ge tName() +  " with cod e value "  + typeCode .getCode() );
  236                             codes. put(typeCo de.getCode (), typeCo de);
  237                    }
  238  
  239                    priv ate TypeCo de[] sortB yCode() {
  240                             List c odeList =  new ArrayL ist(codes. values());
  241                             Collec tions.sort (codeList) ;
  242                             return  (TypeCode [])codeLis t.toArray( new TypeCo de[codeLis t.size()]) ;
  243                    }
  244  
  245                    priv ate TypeCo de[] sortB yLabel() {
  246                             List c odeList =  new ArrayL ist(codes. values());
  247                             Collec tions.sort (codeList,  new Compa rator() {
  248                                      public i nt compare (Object fi rst, Objec t second)  {
  249                                               String fir stLabel =  ((TypeCode )first).ge tLabel();
  250                                               String sec ondLabel =  ((TypeCod e)second). getLabel() ;
  251                                               return fir stLabel.co mpareTo(se condLabel) ;
  252                                      }
  253                             });
  254                             return  (TypeCode [])codeLis t.toArray( new TypeCo de[codeLis t.size()]) ;
  255                    }
  256                    
  257                    /* ( non-Javado c)
  258                     * @ see java.l ang.Object #toString( )
  259                     */
  260                    publ ic String  toString()  {
  261                             String  sep = Sys tem.getPro perty("lin e.separato r");
  262                             String Buffer buf  = new Str ingBuffer( getClass() .getName() ).append(s ep);
  263                             buf.ap pend("Type Code cache  for insta nces of ty pe: " + pa rent.getNa me());
  264                             
  265                             for (I terator i  = codes.va lues().ite rator(); i .hasNext() ;) {
  266                                      TypeCode  element =  (TypeCode )i.next();
  267                                      buf.appe nd(sep).ap pend("code : ").appen d(element. getCode()) ;
  268                                      buf.appe nd(sep).ap pend("labe l: ").appe nd(element .getLabel( ));
  269                                      buf.appe nd(sep).ap pend("desc : ").appen d(element. getDescrip tion());
  270                                      buf.appe nd(sep);
  271                             }
  272                             
  273                             return  buf.toStr ing();
  274                    }
  275           }
  276   }