1   /*
2    * (C) Copyright 1989-2011 Trend Micro, Inc.
3    * All Rights Reserved.
4    *
5    * This program is an unpublished copyrighted work which is proprietary
6    * to Trend Micro, Inc. and contains confidential information that is not
7    * to be reproduced or disclosed to any other person or entity without
8    * prior written consent from Trend Micro, Inc. in each and every instance.
9    *
10   * WARNING:  Unauthorized reproduction of this program as well as
11   * unauthorized preparation of derivative works based upon the
12   * program or distribution of copies by sale, rental, lease or
13   * lending are violations of federal copyright laws and state trade
14   * secret laws, punishable by civil and criminal penalties.
15   */
16  
17  package com.trendmicro.grid.acl.ds.cache.translation;
18  
19  import com.trendmicro.grid.acl.ds.datatypes.SharedFileDetails;
20  import com.trendmicro.grid.acl.ds.datatypes.SharedFileInformation;
21  
22  /**
23   * Extension to ValueExistsTranslator that honors the "isUnknown" flag on SharedFileInformation instances.
24   *
25   * @author juergen_kellerer, 2011-04-21
26   * @version 1.0
27   */
28  public class FileAwareValueExistsTranslator<K> extends ValueExistsTranslator<K> {
29  	@Override
30  	protected Boolean fromDelegateValue(K key, K delegateKey, Object delegateValue) {
31  		if (delegateValue != null) {
32  			if (delegateValue instanceof SharedFileDetails)
33  				delegateValue = ((SharedFileDetails) delegateValue).getInformation();
34  			if (delegateValue instanceof SharedFileInformation)
35  				return !((SharedFileInformation) delegateValue).isUnknown();
36  		}
37  		return super.fromDelegateValue(key, delegateKey, delegateValue);
38  	}
39  }