01: /*
02: * Copyright 2006 JBoss Inc
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.drools.base.extractors;
18:
19: import org.drools.base.ValueType;
20: import org.drools.common.InternalWorkingMemory;
21:
22: /**
23: * A special field extractor for the self reference "this".
24: *
25: * @author etirelli
26: */
27: public class SelfReferenceClassFieldExtractor extends
28: BaseObjectClassFieldExtractor {
29:
30: private static final long serialVersionUID = 400L;
31:
32: public SelfReferenceClassFieldExtractor(final Class clazz,
33: final String fieldName) {
34: super (-1, // index
35: clazz, // fieldType
36: ValueType.determineValueType(clazz)); // value type
37: }
38:
39: public Object getValue(InternalWorkingMemory workingMemory,
40: final Object object) {
41: //return (object instanceof ShadowProxy) ? ((ShadowProxy) object).getShadowedObject() : object;
42: return object;
43: }
44:
45: public boolean isNullValue(InternalWorkingMemory workingMemory,
46: final Object object) {
47: return getValue(workingMemory, object) == null;
48: }
49: }
|