public DualCache < T > build ( ) { if ( ramMode == null ) { throw new IllegalStateException ( "No ram mode set" ) ; } if ( diskMode == null ) { throw new IllegalStateException ( "No disk mode set" ) ; } DualCache < T > cache = new DualCache <> ( appVersion , new Logger ( logEnabled ) , ramMode , ramSerializer , maxRamSizeBytes , sizeOf , diskMode , diskSerializer , maxDiskSizeBytes , diskFolder ) ; boolean isRamDisable = cache . getRAMMode ( ) . equals ( DualCacheRamMode . DISABLE ) ; boolean isDiskDisable = cache . getDiskMode ( ) . equals ( DualCacheDiskMode . DISABLE ) ; if ( isRamDisable && isDiskDisable ) { throw new IllegalStateException ( "The ram cache layer and the disk cache layer are " + "disable. You have to use at least one of those " + "layers." ) ; } return cache ; }
Builder the cache . Exception will be thrown if it can not be created .