check for naming convention in java.
Posted
by Vivart
on Stack Overflow
See other posts from Stack Overflow
or by Vivart
Published on 2010-04-13T19:57:24Z
Indexed on
2010/04/13
20:03 UTC
Read the original article
Hit count: 357
java
|reflection
through java reflection how to check that method name is in camelCase? e.g.
import java.lang.reflect.*;
public class TestClass {
private int simpleMethod(
Object p, int x) throws NullPointerException
{
if (p == null)
throw new NullPointerException();
return x;
}
public static void main(String args[])
{
try {
Class cls = Class.forName("method1");
Method methlist[]
= cls.getDeclaredMethods();
for (int i = 0; i < methlist.length;
i++) {
Method m = methlist[i];
System.out.println("name= " + m.getName());
}
}
catch (Throwable e) {
System.err.println(e);
}
}
}
here i am getting method names simpleMethod and main i have to check that these names are in camelCase.
© Stack Overflow or respective owner