List of usage examples for java.lang.reflect Method isSynthetic
@Override public boolean isSynthetic()
From source file:org.unitils.core.reflect.ClassWrapper.java
protected void addMethods(Class<?> clazz, List<Method> methods) { if (Object.class.equals(clazz)) { return;/*from w w w . j ava 2 s. c o m*/ } Method[] classMethods = clazz.getDeclaredMethods(); for (Method method : classMethods) { // exclude special methods if (!method.isSynthetic() && !method.isBridge() && !isStatic(method.getModifiers())) { methods.add(method); } } addMethods(clazz.getSuperclass(), methods); }
From source file:org.vulpe.commons.util.VulpeReflectUtil.java
/** * Returns list of methods in class or superclass. * * @param clazz/*w w w . ja va 2 s.c o m*/ * @return */ public static List<Method> getMethods(final Class<?> clazz) { if (VulpeCacheHelper.getInstance().contains(clazz.getName().concat(".methods"))) { return VulpeCacheHelper.getInstance().get(clazz.getName().concat(".methods")); } Class<?> baseClass = clazz; final List<Method> list = new ArrayList<Method>(); while (!baseClass.equals(Object.class)) { for (Method method : baseClass.getDeclaredMethods()) { if (!method.isSynthetic() && !method.isBridge() && !Modifier.isStatic(method.getModifiers())) { list.add(method); } } baseClass = baseClass.getSuperclass(); } VulpeCacheHelper.getInstance().put(clazz.getName().concat(".methods"), list); return list; }
From source file:repast.simphony.visualization.gui.styleBuilder.EditedStyleDialog.java
public void init(Class agentClass, String userStyleName, CartesianDisplayDescriptor descriptor) { this.agentClassName = agentClass.getCanonicalName(); this.userStyleName = userStyleName; this.displayType = descriptor.getDisplayType(); userStyleData = EditedStyleUtils.getStyle(descriptor.getEditedStyleName(agentClass.getName())); Method[] methods = agentClass.getMethods(); for (Method method : methods) { if (!method.isSynthetic()) { if (method.getParameterTypes().length == 0 && (pTypes.contains(method.getReturnType()) || Number.class.isAssignableFrom(method.getReturnType()))) { methodList.add(method.getName()); }//ww w .j a v a 2s . c o m if (method.getParameterTypes().length == 0 && (pTypes.contains(method.getReturnType()) || Number.class.isAssignableFrom(method.getReturnType()) || method.getReturnType().equals(String.class))) { labelMethodList.add(method.getName()); } } } methodList.remove("hashCode"); labelMethodList.remove("hashCode"); labelMethodList.remove("toString"); labelMethodList.add("Name"); // TODO Projections: init from viz registry data entries // Set objects based on display type 2D/3D if (displayType.equals(DisplayType.TWO_D)) { if (userStyleData == null) userStyleData = new DefaultEditedStyleData2D(); // TODO Eliminate GIS plugin depedency. shapeModel = new DefaultComboBoxModel(IconFactory2D.Shape_List); shapeModel.setSelectedItem(userStyleData.getShapeWkt()); } else { if (userStyleData == null) userStyleData = new DefaultEditedStyleData3D(); shapeModel = new DefaultComboBoxModel(new String[] { "sphere", "cube", "cylinder", "cone" }); shapeModel.setSelectedItem(userStyleData.getShapeWkt()); } sizeModel = new DefaultComboBoxModel(); sizeMinModel = new DefaultComboBoxModel(); sizeMaxModel = new DefaultComboBoxModel(); sizeScaleModel = new DefaultComboBoxModel(); labelModel = new DefaultComboBoxModel(); labelFontFamilyModel = new DefaultComboBoxModel(); variableIconRedColorValueModel = new DefaultComboBoxModel(); variableIconGreenColorValueModel = new DefaultComboBoxModel(); variableIconBlueColorValueModel = new DefaultComboBoxModel(); variableIconRedColorMinModel = new DefaultComboBoxModel(); variableIconGreenColorMinModel = new DefaultComboBoxModel(); variableIconBlueColorMinModel = new DefaultComboBoxModel(); variableIconRedColorMaxModel = new DefaultComboBoxModel(); variableIconGreenColorMaxModel = new DefaultComboBoxModel(); variableIconBlueColorMaxModel = new DefaultComboBoxModel(); variableIconRedColorScaleModel = new DefaultComboBoxModel(); variableIconGreenColorScaleModel = new DefaultComboBoxModel(); variableIconBlueColorScaleModel = new DefaultComboBoxModel(); // sizeModel.addElement(ICON_SIZE); // Add available methods to appropriate combo box models for (String method : methodList) { sizeModel.addElement(method); sizeMinModel.addElement(method); sizeMaxModel.addElement(method); sizeScaleModel.addElement(method); variableIconRedColorValueModel.addElement(method); variableIconGreenColorValueModel.addElement(method); variableIconBlueColorValueModel.addElement(method); // variableIconRedColorMinModel.addElement(method); // variableIconGreenColorMinModel.addElement(method); // variableIconBlueColorMinModel.addElement(method); // variableIconRedColorMaxModel.addElement(method); // variableIconGreenColorMaxModel.addElement(method); // variableIconBlueColorMaxModel.addElement(method); // variableIconRedColorScaleModel.addElement(method); // variableIconGreenColorScaleModel.addElement(method); // variableIconBlueColorScaleModel.addElement(method); } for (String method : labelMethodList) labelModel.addElement(method); if (userStyleData.getSizeMethodName() != null) sizeModel.setSelectedItem(userStyleData.getSizeMethodName()); else { sizeModel.addElement(userStyleData.getSize()); sizeModel.setSelectedItem(userStyleData.getSize()); } if (userStyleData.getSizeMinMethodName() != null) sizeMinModel.setSelectedItem(userStyleData.getSizeMinMethodName()); else { sizeMinModel.addElement(userStyleData.getSizeMin()); sizeMinModel.setSelectedItem(userStyleData.getSizeMin()); } if (userStyleData.getSizeMaxMethodName() != null) sizeMaxModel.setSelectedItem(userStyleData.getSizeMaxMethodName()); else { sizeMaxModel.addElement(userStyleData.getSizeMax()); sizeMaxModel.setSelectedItem(userStyleData.getSizeMax()); } if (userStyleData.getSizeScaleMethodName() != null) sizeScaleModel.setSelectedItem(userStyleData.getSizeScaleMethodName()); else { sizeScaleModel.addElement(userStyleData.getSizeScale()); sizeScaleModel.setSelectedItem(userStyleData.getSizeScale()); } if (userStyleData.getLabelMethod() != null) { if ("toString".equals(userStyleData.getLabelMethod())) labelModel.setSelectedItem("Name"); else labelModel.setSelectedItem(userStyleData.getLabelMethod()); } else { labelModel.addElement(userStyleData.getLabel()); labelModel.setSelectedItem(userStyleData.getLabel()); } if (userStyleData.getRedMethod() != null) variableIconRedColorValueModel.setSelectedItem(userStyleData.getRedMethod()); else { variableIconRedColorValueModel.addElement(userStyleData.getColor()[0]); variableIconRedColorValueModel.setSelectedItem(userStyleData.getColor()[0]); } if (userStyleData.getGreenMethod() != null) variableIconGreenColorValueModel.setSelectedItem(userStyleData.getGreenMethod()); else { variableIconGreenColorValueModel.addElement(userStyleData.getColor()[1]); variableIconGreenColorValueModel.setSelectedItem(userStyleData.getColor()[1]); } if (userStyleData.getBlueMethod() != null) variableIconBlueColorValueModel.setSelectedItem(userStyleData.getBlueMethod()); else { variableIconBlueColorValueModel.addElement(userStyleData.getColor()[2]); variableIconBlueColorValueModel.setSelectedItem(userStyleData.getColor()[2]); } variableIconRedColorMinModel.addElement(userStyleData.getColorMin()[0]); variableIconRedColorMinModel.setSelectedItem(userStyleData.getColorMin()[0]); variableIconGreenColorMinModel.addElement(userStyleData.getColorMin()[1]); variableIconGreenColorMinModel.setSelectedItem(userStyleData.getColorMin()[1]); variableIconBlueColorMinModel.addElement(userStyleData.getColorMin()[2]); variableIconBlueColorMinModel.setSelectedItem(userStyleData.getColorMin()[2]); variableIconRedColorMaxModel.addElement(userStyleData.getColorMax()[0]); variableIconRedColorMaxModel.setSelectedItem(userStyleData.getColorMax()[0]); variableIconGreenColorMaxModel.addElement(userStyleData.getColorMax()[1]); variableIconGreenColorMaxModel.setSelectedItem(userStyleData.getColorMax()[1]); variableIconBlueColorMaxModel.addElement(userStyleData.getColorMax()[2]); variableIconBlueColorMaxModel.setSelectedItem(userStyleData.getColorMax()[2]); variableIconRedColorScaleModel.addElement(userStyleData.getColorScale()[0]); variableIconRedColorScaleModel.setSelectedItem(userStyleData.getColorScale()[0]); variableIconGreenColorScaleModel.addElement(userStyleData.getColorScale()[1]); variableIconGreenColorScaleModel.setSelectedItem(userStyleData.getColorScale()[1]); variableIconBlueColorScaleModel.addElement(userStyleData.getColorScale()[2]); variableIconBlueColorScaleModel.setSelectedItem(userStyleData.getColorScale()[2]); // Label font Toolkit toolkit = Toolkit.getDefaultToolkit(); String fontList[] = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames(); for (int i = 0; i < fontList.length; i++) labelFontFamilyModel.addElement(fontList[i]); if (labelFontFamilyModel.getIndexOf(userStyleData.getLabelFontFamily()) != -1) labelFontFamilyModel.setSelectedItem(userStyleData.getLabelFontFamily()); initComponents(); initMyComponents(displayType); }
From source file:wwutil.sys.ReflectUtil.java
public static List<Method> getAllMethods(Class clazz, List<Method> list) { for (Method method : clazz.getDeclaredMethods()) { if (!method.isSynthetic() && !Modifier.isStatic(method.getModifiers())) list.add(method);//from w ww . ja va 2 s. c o m } Class superClazz = clazz.getSuperclass(); if (superClazz != null) getAllMethods(superClazz, list); return list; }