public StampedValue asType ( final Type type ) { StampedValue cachedValue = null ; //looping around a list is probably quicker than having a map since there are probably only one or two different //types in use at any one time for ( StampedValue value : typeCache ) { if ( value . getType ( ) . equals ( type ) ) { cachedValue = value ; break ; } } if ( cachedValue == null ) { StampedValue newValue = new StampedValue ( type , this , config ) ; typeCache . add ( newValue ) ; cachedValue = newValue ; } return cachedValue ; }
Check if a StampedValue already exists for the type if it does return it otherwise create a new one and add it