View Javadoc

1   package com.bradmcevoy.http.quota;
2   
3   import com.bradmcevoy.http.QuotaResource;
4   import com.bradmcevoy.http.Resource;
5   
6   /**
7    * Default implementation which just reads the quota properties from
8    * QuotaResource, if the given resource implements it. Otherwise
9    * returns null;
10   *
11   * @author brad
12   */
13  public class DefaultQuotaDataAccessor implements QuotaDataAccessor {
14  
15      public Long getQuotaAvailable( Resource res ) {
16          if( res instanceof QuotaResource ) {
17              QuotaResource quotaRes = (QuotaResource) res;
18              Long l = quotaRes.getQuotaAvailable();
19              return l;
20          } else {
21              return null;
22          }
23  
24      }
25  
26      public Long getQuotaUsed( Resource res ) {
27          if( res instanceof QuotaResource ) {
28              QuotaResource quotaRes = (QuotaResource) res;
29              Long l = quotaRes.getQuotaUsed();
30              return l;
31          } else {
32              return null;
33          }
34      }
35  }