@Override public AlertDialog build() { return Platform.getPlatform().getInstance(AlertDialog.class, this); } }
public static PlatformType getType() { return PLATFORM.getPlatformType(); }
@Override public void show() { Platform.getPlatform().runOnUIThread(alert::show); }
@SuppressWarnings("unchecked") public <T> T getInstance(String identifier, Class<T> type, Object... args) { Util.requireNonNull(type, "type"); if (!type.isInterface()) { throw new IllegalArgumentException("type must be an interface"); } Map<String, Class<?>> classes = implementations.get(type); if (classes == null) { classes = findImplementations(type); implementations.put(type, classes); } if (classes.size() > 0) { Class<?> target = classes.get(identifier); return (T) constructInstance(target, args); } if (getType() == PlatformType.Headless) { // Create default implementation on headless platforms. return (T) Proxy.newProxyInstance(type.getClassLoader(), new Class[] { type }, (proxy, method, args1) -> { Class<?> returnType = method.getReturnType(); if (returnType.isPrimitive()) { return getPrimitiveNullValue(returnType); } return null; }); } throw new IllegalArgumentException("No class found that implements " + type.getSimpleName()); }
public <T> T getInstance(Class<T> type, Object... args) { return getInstance(null, type, args); }
@SuppressWarnings("unchecked") public <T> T getInstance(Class<T> type, Object... args) { Objects.requireNonNull(type, "type"); if (!type.isInterface()) { throw new IllegalArgumentException("type must be an interface"); } List<Class<?>> classes = implementations.get(type); if (classes == null) { classes = findImplementations(type); implementations.put(type, classes); } if (classes.size() > 0) { Class<?> target = classes.get(0); // We only use the first at the // moment. return (T) constructInstance(target, args); } throw new IllegalArgumentException("No class found that implements " + type.getSimpleName()); }
@SuppressWarnings("unchecked") private <T> T constructInstance(Class<T> type, Object... args) { try { Constructor<?> construct = type.getDeclaredConstructor(getClassesOfArguments(args)); construct.setAccessible(true); return (T) construct.newInstance(args); } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException e) { throw new AssertionError(e); } }
@SuppressWarnings("unchecked") public <T> T getInstance(String identifier, Class<T> type, Object... args) { Util.requireNonNull(type, "type"); if (!type.isInterface()) { throw new IllegalArgumentException("type must be an interface"); } Map<String, Class<?>> classes = implementations.get(type); if (classes == null) { classes = findImplementations(type); implementations.put(type, classes); } if (classes.size() > 0) { Class<?> target = classes.get(identifier); return (T) constructInstance(target, args); } if (getType() == PlatformType.Headless) { // Create default implementation on headless platforms. return (T) Proxy.newProxyInstance(type.getClassLoader(), new Class[] { type }, (proxy, method, args1) -> { Class<?> returnType = method.getReturnType(); if (returnType.isPrimitive()) { return getPrimitiveNullValue(returnType); } return null; }); } throw new IllegalArgumentException("No class found that implements " + type.getSimpleName()); }
public <T> T getInstance(Class<T> type, Object... args) { return getInstance(null, type, args); }
@SuppressWarnings("unchecked") private <T> T constructInstance(Class<T> type, Object... args) { try { Constructor<?> construct = type.getDeclaredConstructor(getClassesOfArguments(args)); construct.setAccessible(true); return (T) construct.newInstance(args); } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException e) { throw new AssertionError(e); } }
@Override public AlertDialog build() { return Platform.getPlatform().getInstance(AlertDialog.class, this); } }
@Override public void show() { Platform.getPlatform().runOnUIThread(() -> { if (alertView != null) { alertView.show(); } else { alertController.show(); } }); }
classes = findImplementations(type); implementations.put(type, classes); throw new IllegalArgumentException("No class found that implements " + type.getSimpleName()); return (T) constructInstance(target, args); if (getType() == PlatformType.Headless) { Class<?> returnType = method.getReturnType(); if (returnType.isPrimitive()) { return getPrimitiveNullValue(returnType);
public <T> T getInstance(Class<T> type, Object... args) { return getInstance(null, type, args); }
public static PlatformType getType() { return PLATFORM.getPlatformType(); }
@SuppressWarnings("unchecked") private <T> T constructInstance(Class<T> type, Object... args) { try { Constructor<?> construct = type.getDeclaredConstructor(getClassesOfArguments(args)); construct.setAccessible(true); return (T) construct.newInstance(args); } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException e) { throw new AssertionError(e); } }
@Override public ProgressDialog build() { return Platform.getPlatform().getInstance(ProgressDialog.class, this); } }
@Override public void hide() { Platform.getPlatform().runOnUIThread(() -> { if (alertView != null) { alertView.dismiss(-1, true); } else { alertController.dismissViewController(true, null); } }); }
public static PlatformType getType() { return PLATFORM.getPlatformType(); }
@SuppressWarnings("unchecked") private <T> T constructInstance(Class<T> type, Object... args) { try { Constructor<?> construct = type.getDeclaredConstructor(getClassesOfArguments(args)); construct.setAccessible(true); return (T) construct.newInstance(args); } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException e) { throw new AssertionError(e); } }