All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.payu.sdk.api.log.Platform Maven / Gradle / Ivy

The newest version!
package com.payu.sdk.api.log;

import android.os.Build;

abstract class Platform {
  private static final Platform PLATFORM = findPlatform();

  static Platform get() {
    return PLATFORM;
  }

  private static Platform findPlatform() {
    try {
      Class.forName("android.os.Build");
      if (Build.VERSION.SDK_INT != 0) {
        return new Android();
      }
    } catch (ClassNotFoundException ignored) {
    }

    return new Base();
  }

  abstract ApiLog defaultLog();

  /** Provides sane defaults for operation on the JVM. */
  private static class Base extends Platform {

    @Override ApiLog defaultLog() {
      return new ApiLog() {
        @Override public void log(String message) {
          System.out.format("%s \t %s \n", ApiLog.TAG, message);
        }
      };
    }
  }

  /** Provides sane defaults for operation on Android. */
  private static class Android extends Platform {

    @Override ApiLog defaultLog() {
      return new AndroidLog();
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy