Java 8 FeatureDescriptor - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 FeatureDescriptor class.

This code example shows how to use the following methods:getName, getReadMethod, getWriteMethod
		private Class<?> propertyType;
 
		private Class<?> propertyEditorClass;
 
		public SimplePropertyDescriptor(PropertyDescriptor original) throws IntrospectionException {
			this(original.getName(), original.getReadMethod(), original.getWriteMethod());
			PropertyDescriptorUtils.copyNonMethodProperties(original, this);
		} 
 
		public SimplePropertyDescriptor(String propertyName, Method readMethod, Method writeMethod) throws IntrospectionException {
			super(propertyName, null, null);
			this.readMethod = readMethod;
			this.writeMethod = writeMethod;
			this.propertyType = PropertyDescriptorUtils.findPropertyType(readMethod, writeMethod);
		} 
 
		@Override 
		public Method getReadMethod() {
			return this.readMethod;
		} 
7
CodeRank
This code example shows how to use the following methods:setDisplayName, setExpert, setHidden, setName, setPreferred
This code example shows how to use the following methods:getName, getReadMethod
 
 
  public Object invokeGetter(Object obj, PropertyMappingDefinition md) {
    PropertyDescriptor pd = md.getPropDesc();
 
    Method getter = pd.getReadMethod();
    if (null == getter) {
      throw new RuntimeException("missing getter method for property, " + pd.getName());
    } 
 
    try { 
      return getter.invoke(obj, (Object[]) null);
    } catch (Throwable e) {
      throw new HectorObjectMapperException("exception while invoking getter on object of type, " 
          + obj.getClass().getName(), e);
    } 
  } 
 
} 
 
6
CodeRank
This code example shows how to use the following methods:getName, getPropertyType, getReadMethod, getWriteMethod
    /** 
     * {@inheritDoc} 
     */ 
    @Override 
    public String getName() {
        return _propDesc.getName();
    } 
 
    /** 
     * {@inheritDoc} 
     */ 
    @Override 
    @SuppressWarnings("unchecked") 
    public Class<T> getType() {
        return (Class<T>)_propDesc.getPropertyType();
    } 
 
    /** 
     * {@inheritDoc} 
     */ 

6
CodeRank
This code example shows how to use the following methods:getAddListenerMethod, getGetListenerMethod, getListenerType, getRemoveListenerMethod, getName
 
    /** 
     * Reports all the interesting information in an EventSetDescriptor 
     */ 
    public static void reportEventSetDescriptor(EventSetDescriptor esd) {
        System.out.println("event set name:   " + esd.getName());
        System.out.println(" listener type:   " + esd.getListenerType());
        System.out.println("   method get:    " + esd.getGetListenerMethod());
        System.out.println("   method add:    " + esd.getAddListenerMethod());
        System.out.println("   method remove: " + esd.getRemoveListenerMethod());
    } 
 
    /** 
     * Reports all the interesting information in a MethodDescriptor 
     */ 
    public static void reportMethodDescriptor(MethodDescriptor md) {
        System.out.println("method name: " + md.getName());
        System.out.println("     method: " + md.getMethod());
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getName, getPropertyType, getReadMethod, getWriteMethod
    private final PropertyDescriptor property;
    private final boolean readable;
    private final boolean writable;
 
    public MethodProperty(PropertyDescriptor property) {
        super(property.getName(), property.getPropertyType(),
                property.getReadMethod() == null ? null : property.getReadMethod()
                        .getGenericReturnType());
        this.property = property;
        this.readable = property.getReadMethod() != null;
        this.writable = property.getWriteMethod() != null;
    } 
 
    @Override 
    public void set(Object object, Object value) throws Exception {
        property.getWriteMethod().invoke(object, value);
    } 
 
    @Override 
    public Object get(Object object) { 
6
CodeRank
This code example shows how to use the following methods:isExpert, isHidden, getReadMethod, getWriteMethod
     * </ul> 
     * @param descriptor 
     * @return true if the descriptor should be ignored 
     */ 
    public static boolean isDescriptorIgnored(PropertyDescriptor descriptor) {
        return descriptor.isHidden() 
            || (descriptor.isExpert() && !JMeterUtils.isExpertMode())
            || descriptor.getReadMethod() == null 
            || descriptor.getWriteMethod() == null;
    } 
} 
6
CodeRank
This code example shows how to use the following methods:setDisplayName, setExpert, setHidden, setName, setPreferred
 
	@Override 
	public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
	    if (base != null) return null; 
	    ArrayList<FeatureDescriptor> list = new ArrayList<FeatureDescriptor>(1);
	    FeatureDescriptor descriptor = new FeatureDescriptor();
	    descriptor.setName(NAME);
	    descriptor.setDisplayName(DISPLAYNAME);
	    descriptor.setShortDescription(DESCRIPTION);
	    descriptor.setExpert(EXPERT);
	    descriptor.setHidden(HIDDEN);
	    descriptor.setPreferred(PREFERRED);
	    list.add(descriptor);
	     
	    return list.iterator();
	  } 
 
	@Override 
	public Class<?> getCommonPropertyType(ELContext context, Object base) {
		return Object.class; 
6
CodeRank
This code example shows how to use the following methods:getDisplayName, getReadMethod, getWriteMethod
      out.writeObject(value);
    } catch (Exception ex) {
      throw new IOException("Can't serialize object: " + ex.getMessage());
    } 
    out.writeObject(parentClass);
    out.writeObject(property.getDisplayName());
    out.writeObject(property.getReadMethod().getName());
    out.writeObject(property.getWriteMethod().getName());
  } 
  private void readObject(java.io.ObjectInputStream in)
    throws IOException, ClassNotFoundException {
 
    value = in.readObject();
    parentClass = (Class) in.readObject();
    String name = (String) in.readObject();
    String getter = (String) in.readObject();
    String setter = (String) in.readObject();
    /* 
    System.err.println("Loading property descriptor:\n" 
		       + "\tparentClass: " + parentClass.getName() 
6
CodeRank
This code example shows how to use the following methods:attributeNames, getPropertyType
     * @param pe the propertyEditor 
     */ 
    private static void validateAttributes(PropertyDescriptor pd, PropertyEditor pe) {
        final Object deflt = pd.getValue(DEFAULT);
        if (deflt == null) { 
            if (notNull(pd)) {
                log.warn(getDetails(pd) + " requires a value but does not provide a default.");
            }             
        } else { 
            final Class<?> defltClass = deflt.getClass(); // the DEFAULT class
            // Convert int to Integer etc: 
            final Class<?> propClass = ClassUtils.primitiveToWrapper(pd.getPropertyType());
            if (!propClass.isAssignableFrom(defltClass) ){
                log.warn(getDetails(pd) + " has a DEFAULT of class " + defltClass.getCanonicalName());
            }             
        } 
        if (notOther(pd) && pd.getValue(TAGS) == null && pe.getTags() == null) {
            log.warn(getDetails(pd) + " does not have tags but other values are not allowed.");
        } 
        if (!notNull(pd)) {

6
CodeRank
See Code Examples for Java 8 FeatureDescriptor Methods: