diff options
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/PersistentAttributePropertyTester.java')
-rw-r--r-- | jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/PersistentAttributePropertyTester.java | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/PersistentAttributePropertyTester.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/PersistentAttributePropertyTester.java index 7620a04d2e..ff5cfc699e 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/PersistentAttributePropertyTester.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/PersistentAttributePropertyTester.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Oracle. All rights reserved. + * Copyright (c) 2007, 2012 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -12,36 +12,45 @@ package org.eclipse.jpt.jpa.core.internal.context; import org.eclipse.core.expressions.PropertyTester; import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; +/** + * Property tester for {@link ReadOnlyPersistentAttribute}. + * See <code>org.eclipse.jpt.jpa.core/plugin.xml</code> + */ public class PersistentAttributePropertyTester extends PropertyTester { public static final String IS_MAPPED = "isMapped"; //$NON-NLS-1$ - + public static final String IS_NOT_MAPPED = "isNotMapped"; //$NON-NLS-1$ public static final String IS_VIRTUAL = "isVirtual"; //$NON-NLS-1$ + public static final String IS_NOT_VIRTUAL = "isNotVirtual"; //$NON-NLS-1$ public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { - if (property == null) { - return false; - } - if ( ! (expectedValue instanceof Boolean)) { - return false; + if (receiver instanceof ReadOnlyPersistentAttribute) { + return this.test((ReadOnlyPersistentAttribute) receiver, property, expectedValue); } - return this.test_(receiver, property, ((Boolean) expectedValue).booleanValue()); + return false; } - /** - * pre-condition: property is not <code>null</code> - */ - protected boolean test_(Object receiver, String property, boolean expected) { + protected boolean test(ReadOnlyPersistentAttribute attribute, String property, Object expectedValue) { + if (property.equals(IS_NOT_MAPPED)) { + return ! this.test(attribute, IS_MAPPED, expectedValue); + } if (property.equals(IS_MAPPED)) { - boolean actual = ((ReadOnlyPersistentAttribute) receiver).getMapping().getKey() != null; + boolean expected = (expectedValue == null) ? true : ((Boolean) expectedValue).booleanValue(); + boolean actual = (attribute.getMapping().getKey() != null); return actual == expected; } + + if (property.equals(IS_NOT_VIRTUAL)) { + return ! this.test(attribute, IS_VIRTUAL, expectedValue); + } if (property.equals(IS_VIRTUAL)) { - boolean actual = ((ReadOnlyPersistentAttribute) receiver).isVirtual(); + boolean expected = (expectedValue == null) ? true : ((Boolean) expectedValue).booleanValue(); + boolean actual = attribute.isVirtual(); return actual == expected; } + return false; } } |