Class StaticFactoryConverter

  • All Implemented Interfaces:
    java.beans.PropertyEditor, Converter

    public class StaticFactoryConverter
    extends AbstractConverter
    Of the javax and java packages in the Java 8 JVM, there are roughly 10 static factory patterns in use. Here they are listed in the order they are preferred by this library 64 valueOf 7 new 6 decode 5 for 4 of 1 parse 1 from 1 create 1 compile 40 get Though get* has the second most usage in the JVM, it is also the least consistent and in classes that have multiple factories, it is the least preferred. For each of these prefixes there is a sub order of preference, using "create" as an example, this is the preferred usage: - create - create - create*
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.reflect.Method method  
    • Constructor Summary

      Constructors 
      Constructor Description
      StaticFactoryConverter​(java.lang.Class type, java.lang.reflect.Method method)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static StaticFactoryConverter editor​(java.lang.Class type)  
      (package private) static java.util.List<java.lang.reflect.Method> getCandidates​(java.lang.Class type)  
      private static int grade​(java.lang.reflect.Method a)  
      (package private) static java.lang.reflect.Method select​(java.util.List<java.lang.reflect.Method> candidates)
      We want the selection to be stable and not dependent on VM reflection ordering.
      (package private) static void sort​(java.util.List<java.lang.reflect.Method> candidates)  
      protected java.lang.Object toObjectImpl​(java.lang.String text)
      Converts the supplied text in to an instance of the editor type.
      • Methods inherited from class java.beans.PropertyEditorSupport

        addPropertyChangeListener, firePropertyChange, getCustomEditor, getJavaInitializationString, getSource, getTags, isPaintable, paintValue, removePropertyChangeListener, setSource, supportsCustomEditor
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.beans.PropertyEditor

        addPropertyChangeListener, getCustomEditor, getJavaInitializationString, getTags, isPaintable, paintValue, removePropertyChangeListener, supportsCustomEditor
    • Field Detail

      • method

        private final java.lang.reflect.Method method
    • Constructor Detail

      • StaticFactoryConverter

        public StaticFactoryConverter​(java.lang.Class type,
                                      java.lang.reflect.Method method)
    • Method Detail

      • toObjectImpl

        protected java.lang.Object toObjectImpl​(java.lang.String text)
        Description copied from class: AbstractConverter
        Converts the supplied text in to an instance of the editor type. The text will never be null, and trim() will already have been called.
        Specified by:
        toObjectImpl in class AbstractConverter
        Parameters:
        text - the text to convert
        Returns:
        an instance of the editor type
      • getCandidates

        static java.util.List<java.lang.reflect.Method> getCandidates​(java.lang.Class type)
      • select

        static java.lang.reflect.Method select​(java.util.List<java.lang.reflect.Method> candidates)
        We want the selection to be stable and not dependent on VM reflection ordering.
      • sort

        static void sort​(java.util.List<java.lang.reflect.Method> candidates)
      • grade

        private static int grade​(java.lang.reflect.Method a)