@Test public void bundleDefaultStyleMissingButSourceReferenced() { source.set("test", "missingDefaultStyle", "bold"); Styles styles = StyleBundleInvocationHandler.create(source, Styles.class); AttributedString string = styles.missingDefaultStyle("foo bar"); System.out.println(string.toAnsi()); assert string.equals(new AttributedString("foo bar", BOLD)); }
@SuppressWarnings("unchecked") static <T extends StyleBundle> T create(final StyleResolver resolver, final Class<T> type) { requireNonNull(resolver); requireNonNull(type); if (log.isLoggable(Level.FINEST)) { log.finest(String.format("Using style-group: %s for type: %s", resolver.getGroup(), type.getName())); } StyleBundleInvocationHandler handler = new StyleBundleInvocationHandler(type, resolver); return (T) Proxy.newProxyInstance(type.getClassLoader(), new Class<?>[]{type}, handler); }
StyleBundleInvocationHandler implements InvocationHandler { @SuppressWarnings("unchecked") static <T extends StyleBundle> T create(final StyleResolver resolver, final Class<T> type) { requireNonNull(resolver); requireNonNull(type); if (log.isLoggable(Level.FINEST)) { log.finest(String.format("Using style-group: %s for type: %s", resolver.getGroup(), type.getName())); } StyleBundleInvocationHandler handler = new StyleBundleInvocationHandler(type, resolver); return (T) Proxy.newProxyInstance(type.getClassLoader(), new Class<?>[]{type}, handler); } }
StyleBundleInvocationHandler implements InvocationHandler { @SuppressWarnings("unchecked") static <T extends StyleBundle> T create(final StyleResolver resolver, final Class<T> type) { requireNonNull(resolver); requireNonNull(type); if (log.isLoggable(Level.FINEST)) { log.finest(String.format("Using style-group: %s for type: %s", resolver.getGroup(), type.getName())); } StyleBundleInvocationHandler handler = new StyleBundleInvocationHandler(type, resolver); return (T) Proxy.newProxyInstance(type.getClassLoader(), new Class<?>[]{type}, handler); } StyleBundleInvocationHandler(final Class<? extends StyleBundle> type, final StyleResolver resolver); }
StyleBundleInvocationHandler implements InvocationHandler { @SuppressWarnings("unchecked") static <T extends StyleBundle> T create(final StyleResolver resolver, final Class<T> type) { requireNonNull(resolver); requireNonNull(type); if (log.isLoggable(Level.FINEST)) { log.finest(String.format("Using style-group: %s for type: %s", resolver.getGroup(), type.getName())); } StyleBundleInvocationHandler handler = new StyleBundleInvocationHandler(type, resolver); return (T) Proxy.newProxyInstance(type.getClassLoader(), new Class<?>[]{type}, handler); } StyleBundleInvocationHandler(final Class<? extends StyleBundle> type, final StyleResolver resolver); @Override Object invoke(final Object proxy, final Method method, final Object[] args); @Override String toString(); }
StyleBundleInvocationHandler implements InvocationHandler { @SuppressWarnings("unchecked") static <T extends StyleBundle> T create(final StyleResolver resolver, final Class<T> type) { requireNonNull(resolver); requireNonNull(type); if (log.isLoggable(Level.FINEST)) { log.finest(String.format("Using style-group: %s for type: %s", resolver.getGroup(), type.getName())); } StyleBundleInvocationHandler handler = new StyleBundleInvocationHandler(type, resolver); return (T) Proxy.newProxyInstance(type.getClassLoader(), new Class<?>[]{type}, handler); } StyleBundleInvocationHandler(final Class<? extends StyleBundle> type, final StyleResolver resolver); @Override Object invoke(final Object proxy, final Method method, final Object[] args); @Override String toString();  }