Code example for SortedMap

Methods: put

0
    this.defaultImplementation = defaultImplementation;
    this.implementations = new TreeMap<Integer,String>(Collections.reverseOrder());
  } 
   
  protected void addImplementationClass(int minVersion, String className) {
    implementations.put(minVersion, className);
  } 
 
  public T build() { 
    for (Integer minVersion : implementations.keySet()) {
      if (Build.VERSION.SDK_INT >= minVersion) {
        String className = implementations.get(minVersion);
        try { 
          Class<? extends T> clazz = Class.forName(className).asSubclass(managedInterface);
          Log.i(TAG, "Using implementation " + clazz + " of " + managedInterface + " for SDK " + minVersion);
          return clazz.getConstructor().newInstance();
        } catch (ClassNotFoundException cnfe) {
          Log.w(TAG, cnfe);
        } catch (IllegalAccessException iae) {
          Log.w(TAG, iae);
Stop searching for code, let great code find you!  Add Codota to your java IDE