added Method & Long property types

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@6664 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Brian Remedios committed 2008-10-25 00:40:17 +00:00
1 parent 989f020fab
commit 7962786726
1 file changed
+35 -14
@@ -1,5 +1,7 @@
package test.net.sourceforge.pmd.properties;
import java.lang.reflect.Method;
import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule;
import net.sourceforge.pmd.lang.rule.properties.BooleanMultiProperty;
import net.sourceforge.pmd.lang.rule.properties.BooleanProperty;
@@ -11,38 +13,53 @@ import net.sourceforge.pmd.lang.rule.properties.FloatMultiProperty;
import net.sourceforge.pmd.lang.rule.properties.FloatProperty;
import net.sourceforge.pmd.lang.rule.properties.IntegerMultiProperty;
import net.sourceforge.pmd.lang.rule.properties.IntegerProperty;
import net.sourceforge.pmd.lang.rule.properties.LongMultiProperty;
import net.sourceforge.pmd.lang.rule.properties.LongProperty;
import net.sourceforge.pmd.lang.rule.properties.MethodMultiProperty;
import net.sourceforge.pmd.lang.rule.properties.MethodProperty;
import net.sourceforge.pmd.lang.rule.properties.StringMultiProperty;
import net.sourceforge.pmd.lang.rule.properties.StringProperty;
import net.sourceforge.pmd.lang.rule.properties.TypeMultiProperty;
import net.sourceforge.pmd.lang.rule.properties.TypeProperty;
import net.sourceforge.pmd.util.ClassUtil;
/**
* A non-functional rule containing all property types. Used for testing UIs.
*
* @author Brian Remedios
*/
class NonRuleWithAllPropertyTypes extends AbstractJavaRule {
private static final Method stringLength = ClassUtil.methodFor(String.class, "length", ClassUtil.EMPTY_CLASS_ARRAY);
private static final Method stringToLowerCase = ClassUtil.methodFor(String.class, "toLowerCase", ClassUtil.EMPTY_CLASS_ARRAY);
// descriptors are public to enable us to write external tests
public static final StringProperty singleStr = new StringProperty("singleStr", "Property with a single string value", "hello world" , 3.0f);
public static final StringMultiProperty multiStr = new StringMultiProperty("multiStr", "Property with multiple string values", new String[] {"hello", "world"}, 5.0f, '|');
public static final StringProperty singleStr = new StringProperty("singleStr", "String value", "hello world" , 3.0f);
public static final StringMultiProperty multiStr = new StringMultiProperty("multiStr", "Multiple string values", new String[] {"hello", "world"}, 5.0f, '|');
public static final IntegerProperty singleInt = new IntegerProperty("singleInt", "Property with a single integer value", 1, 10, 8 , 3.0f);
public static final IntegerMultiProperty multiInt = new IntegerMultiProperty("multiInt", "Property with multiple integer values", 0, 10, new Integer[] {1,2,3,4}, 5.0f);
public static final IntegerProperty singleInt = new IntegerProperty("singleInt", "Single integer value", 1, 10, 8 , 3.0f);
public static final IntegerMultiProperty multiInt = new IntegerMultiProperty("multiInt", "Multiple integer values", 0, 10, new Integer[] {1,2,3,4}, 5.0f);
public static final LongProperty singleLong = new LongProperty("singleLong", "Single long value", 1l, 10l, 8l , 3.0f);
public static final LongMultiProperty multiLong = new LongMultiProperty("multiLong", "Multiple long values", 0l, 10l, new Long[] {1l,2l,3l,4l}, 5.0f);
public static final BooleanProperty singleBool = new BooleanProperty("singleBool", "Property with a single boolean value", true, 6.0f);
public static final BooleanMultiProperty multiBool = new BooleanMultiProperty("multiBool", "Property with multiple boolean values", new Boolean[] { true, false}, 5.0f);
public static final BooleanProperty singleBool = new BooleanProperty("singleBool", "Single boolean value", true, 6.0f);
public static final BooleanMultiProperty multiBool = new BooleanMultiProperty("multiBool", "Multiple boolean values", new Boolean[] { true, false}, 5.0f);
public static final CharacterProperty singleChar = new CharacterProperty("singleChar", "Property with a single character value", 'a', 5.0f);
public static final CharacterMultiProperty multiChar = new CharacterMultiProperty("multiChar", "Property with multiple character values", new Character[] {'a', 'e', 'i', 'o', 'u'}, 6.0f, '|');
public static final CharacterProperty singleChar = new CharacterProperty("singleChar", "Single character", 'a', 5.0f);
public static final CharacterMultiProperty multiChar = new CharacterMultiProperty("multiChar", "Multiple characters", new Character[] {'a', 'e', 'i', 'o', 'u'}, 6.0f, '|');
public static final FloatProperty singleFloat = new FloatProperty("singleFloat", "Property with a single float value", 9f, 10f, .9f, 5.0f);
public static final FloatMultiProperty multiFloat = new FloatMultiProperty("multiFloat", "Property with multiple float values", 0f, 5f, new Float[] {1f,2f,3f}, 6.0f);
public static final FloatProperty singleFloat = new FloatProperty("singleFloat", "Single float value", 9f, 10f, .9f, 5.0f);
public static final FloatMultiProperty multiFloat = new FloatMultiProperty("multiFloat", "Multiple float values", 0f, 5f, new Float[] {1f,2f,3f}, 6.0f);
public static final TypeProperty singleType = new TypeProperty("singleType", "Property with a single type value", String.class, new String[] { "java.lang" }, 5.0f);
public static final TypeMultiProperty multiType = new TypeMultiProperty("multiType", "Property with multiple type values", new Class[] {Integer.class, Object.class}, new String[] { "java.lang" }, 6.0f);
public static final TypeProperty singleType = new TypeProperty("singleType", "Single type", String.class, new String[] { "java.lang" }, 5.0f);
public static final TypeMultiProperty multiType = new TypeMultiProperty("multiType", "Multiple types", new Class[] {Integer.class, Object.class}, new String[] { "java.lang" }, 6.0f);
public static final EnumeratedProperty<Class> enumType = new EnumeratedProperty<Class>("enumType", "Property with a enumerated choices", new String[] {"String", "Object"}, new Class[] {String.class, Object.class}, 1, 5.0f);
public static final EnumeratedMultiProperty<Class> multiEnumType = new EnumeratedMultiProperty<Class>("multiEnumType", "Property with a enumerated choices", new String[] {"String", "Object"}, new Class[] {String.class, Object.class}, new int[] {0,1}, 5.0f);
public static final MethodProperty singleMethod = new MethodProperty("singleMethod", "Single method", stringLength, new String[] { "java.lang" }, 5.0f);
public static final MethodMultiProperty multiMethod = new MethodMultiProperty("multiMethod", "Multiple methods", new Method[] {stringLength, stringToLowerCase}, new String[] { "java.lang" }, 6.0f);
public static final EnumeratedProperty<Class> enumType = new EnumeratedProperty<Class>("enumType", "Enumerated choices", new String[] {"String", "Object"}, new Class[] {String.class, Object.class}, 1, 5.0f);
public static final EnumeratedMultiProperty<Class> multiEnumType = new EnumeratedMultiProperty<Class>("multiEnumType", "Multiple enumerated choices", new String[] {"String", "Object"}, new Class[] {String.class, Object.class}, new int[] {0,1}, 5.0f);
public NonRuleWithAllPropertyTypes() {
@@ -51,6 +68,8 @@ class NonRuleWithAllPropertyTypes extends AbstractJavaRule {
definePropertyDescriptor(multiStr);
definePropertyDescriptor(singleInt);
definePropertyDescriptor(multiInt);
definePropertyDescriptor(singleLong);
definePropertyDescriptor(multiLong);
definePropertyDescriptor(singleBool);
definePropertyDescriptor(multiBool);
definePropertyDescriptor(singleChar);
@@ -60,6 +79,8 @@ class NonRuleWithAllPropertyTypes extends AbstractJavaRule {
definePropertyDescriptor(singleType);
definePropertyDescriptor(multiType);
definePropertyDescriptor(enumType);
definePropertyDescriptor(singleMethod);
definePropertyDescriptor(multiMethod);
definePropertyDescriptor(multiEnumType);
}
}