1 11 package org.eclipse.core.internal.expressions; 12 13 import org.eclipse.core.runtime.Assert; 14 15 import org.eclipse.core.expressions.IPropertyTester; 16 17 public class Property { 18 19 private Class fType; 20 private String fNamespace; 21 private String fName; 22 23 private IPropertyTester fTester; 24 25 Property(Class type, String namespace, String name) { 26 Assert.isNotNull(type); 27 Assert.isNotNull(namespace); 28 Assert.isNotNull(name); 29 30 fType= type; 31 fNamespace= namespace; 32 fName= name; 33 } 34 35 void setPropertyTester(IPropertyTester tester) { 36 Assert.isNotNull(tester); 37 fTester= tester; 38 } 39 40 public boolean isInstantiated() { 41 return fTester.isInstantiated(); 42 } 43 44 public boolean isDeclaringPluginActive() { 45 return fTester.isDeclaringPluginActive(); 46 } 47 48 public boolean isValidCacheEntry(boolean forcePluginActivation) { 49 if (forcePluginActivation) { 50 return isInstantiated() && isDeclaringPluginActive(); 51 } else { 52 return (isInstantiated() && isDeclaringPluginActive()) || 53 (!isInstantiated() && !isDeclaringPluginActive()); 54 } 55 } 56 57 public boolean test(Object receiver, Object [] args, Object expectedValue) { 58 return fTester.test(receiver, fName, args, expectedValue); 59 } 60 61 public boolean equals(Object obj) { 62 if (!(obj instanceof Property)) 63 return false; 64 Property other= (Property)obj; 65 return fType.equals(other.fType) && fNamespace.equals(other.fNamespace) && fName.equals(other.fName); 66 } 67 68 public int hashCode() { 69 return (fType.hashCode() << 16) | fNamespace.hashCode() << 8 | fName.hashCode(); 70 } 71 } 72 | Popular Tags |