/** * Join collection of objects, converted to string, using space as separator. Returns null if given objects array is * null and empty if empty. * * @param objects collection of objects to join. * @return joined string. */ public static String join(Iterable<?> objects) { return join(objects, " "); }
@Override public String getValue() { return Strings.join(classNames); } }
/** * Create new illegal argument exception with joined list of arguments. * * @param args arguments are joined and used as exception message. */ public IllegalArgumentException(Object[] args) { super(Strings.join(args)); } }
/** * Join array of objects, converted to string, using space as separator. Returns null if given objects array is null * and empty if empty. Null objects or empty strings from given <code>objects</code> parameter are ignored. * * @param objects array of objects to join. * @return joined string. */ public static String join(Object[] objects) { return join(objects, " "); }
/** * Join array of objects, converted to string, using specified separator. Returns null if given objects array is null * and empty if empty. Null objects or empty strings from given <code>objects</code> parameter are ignored. * * @param objects array of objects to join, * @param separator character used as separator. * @return joined string. */ public static String join(Object[] objects, char separator) { return join(objects, Character.toString(separator)); }
/** * Join collection of objects, converted to string, using specified char separator. Returns null if given objects * array is null and empty if empty. * * @param objects collection of objects to join, * @param separator character used as separator. * @return joined string. */ public static String join(Iterable<?> objects, char separator) { return join(objects, Character.toString(separator)); }
/** * Join array of objects, converted to string, using specified specified separator. Returns null if given objects * array is null and empty if empty. If separator is null uses space string instead, like invoking * {@link Strings#join(Iterable)}. Null objects or empty strings from given <code>objects</code> parameter are * ignored. * * @param objects array of objects to join, * @param separator string used as separator. * @return joined string. */ public static String join(Object[] objects, String separator) { return objects != null ? join(Arrays.asList(objects), separator) : null; }
/** * Construct meter instance. Store declaring class and initialize method signature. * * @param method instrumented method. */ Meter(Method method) { this.declaringClass = method.getDeclaringClass(); List<String> formalParameters = new ArrayList<String>(); for (Class<?> formalParameter : method.getParameterTypes()) { formalParameters.add(formalParameter.getSimpleName()); } this.methodSignature = String.format(SIMPLE_NAME_FORMAT, method.getName(), Strings.join(formalParameters, ',')); }
/** * Construct a managed method with optional invocation interceptor. Store declaring class and Java reflective method, * initialize this managed method signature and arguments processor. * <p> * If method invocation interceptor is present initialize {@link #invoker} field with {@link InterceptedInvoker}; otherwise * uses {@link DefaultInvoker}. * * @param declaringClass declaring managed class, * @param methodInterceptor optional method invocation interceptor, possible null, * @param method Java reflective method wrapped by this managed method. */ public ManagedMethod(ManagedClassSPI declaringClass, Class<? extends Interceptor> methodInterceptor, Method method) { this.container = declaringClass.getContainer(); this.declaringClass = declaringClass; this.method = method; this.method.setAccessible(true); invoker = methodInterceptor == null ? new DefaultInvoker() : new InterceptedInvoker(methodInterceptor); List<String> formalParameters = new ArrayList<String>(); for (Class<?> formalParameter : method.getParameterTypes()) { formalParameters.add(formalParameter.getSimpleName()); } signature = String.format(QUALIFIED_NAME_FORMAT, method.getDeclaringClass().getName(), method.getName(), Strings.join(formalParameters, ',')); argumentsProcessor = new ArgumentsProcessor(); }
return Strings.join(relativePath, forceURLPath.length > 0 && forceURLPath[0] ? '/' : File.separatorChar);
/** * Variant for {@link #invokeSetter(Object, String, String)} but no exception if setter not found. * * @param object object instance, * @param name setter name, * @param value value to set. * @throws Exception if invocation fail for whatever reason including method logic. */ public static void invokeOptionalSetter(Object object, String name, String value) throws Exception { String setterName = Strings.getMethodAccessor("set", name); Class<?> clazz = object.getClass(); Method method = null; try { method = findMethod(clazz, setterName); } catch(NoSuchMethodException e) { log.debug("Setter |%s| not found in class |%s| or its super hierarchy.", setterName, clazz); return; } Class<?>[] parameterTypes = method.getParameterTypes(); if(parameterTypes.length != 1) { log.debug("Setter |%s#%s(%s)| with invalid parameters number.", method.getDeclaringClass(), method.getName(), Strings.join(parameterTypes, ',')); return; } invoke(object, method, ConverterRegistry.getConverter().asObject((String)value, parameterTypes[0])); }
instance = constructor.newInstance(args); } catch (IllegalArgumentException e) { log.error("Wrong number of arguments or bad types for |%s|: [%s].", constructor, Strings.join(Classes.getParameterTypes(args))); throw e; } catch (InstantiationException e) {