com.payu.sdk.api.log.Platform Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of api-client Show documentation
Show all versions of api-client Show documentation
A fresh implementation of the PayU API Client for Android
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();
}
}
}