...17package org.openqa.selenium.json;18import java.lang.reflect.Method;19import java.util.HashMap;20import java.util.Map;21public class SimplePropertyDescriptor {22 private String name;23 private Method readMethod;24 private Method writeMethod;25 public SimplePropertyDescriptor() {26 }27 public SimplePropertyDescriptor(String name, Method readMethod, Method writeMethod) {28 this.name = name;29 this.readMethod = readMethod;30 this.writeMethod = writeMethod;31 }32 public String getName() {33 return name;34 }35 public Method getReadMethod() {36 return readMethod;37 }38 public Method getWriteMethod() {39 return writeMethod;40 }41 public static SimplePropertyDescriptor[] getPropertyDescriptors(Class<?> clazz) {42 Map<String, SimplePropertyDescriptor> properties = new HashMap<>();43 for (Method m : clazz.getMethods()) {44 String methodName = m.getName();45 if (methodName.length() > 2 && methodName.startsWith("is")) {46 String propertyName = uncapitalize(methodName.substring(2));47 if (properties.containsKey(propertyName))48 properties.get(propertyName).readMethod = m;49 else50 properties.put(propertyName, new SimplePropertyDescriptor(propertyName, m, null));51 }52 if (methodName.length() <= 3) {53 continue;54 }55 String propertyName = uncapitalize(methodName.substring(3));56 if (methodName.startsWith("get") || methodName.startsWith("has")) {57 if (properties.containsKey(propertyName))58 properties.get(propertyName).readMethod = m;59 else60 properties.put(propertyName, new SimplePropertyDescriptor(propertyName, m, null));61 }62 if (methodName.startsWith("set")) {63 if (properties.containsKey(propertyName))64 properties.get(propertyName).writeMethod = m;65 else66 properties.put(propertyName, new SimplePropertyDescriptor(propertyName, null, m));67 }68 }69 SimplePropertyDescriptor[] pdsArray = new SimplePropertyDescriptor[properties.size()];70 return properties.values().toArray(pdsArray);71 }72 private static String uncapitalize(String s) {73 return s.substring(0, 1).toLowerCase() + s.substring(1);74 }75}...