addresses.add(Str.add(rootAddress, "/", classMeta.longName())); addresses.add(Str.add(rootAddress, "/", classMeta.longName().toLowerCase())); if (Str.isEmpty(serviceAddress)) { serviceAddress = readAddressFromAnnotation(classMeta); if (Str.isEmpty(serviceAddress)) { serviceAddress = Str.camelCaseLower(classMeta.name()); if (Str.isEmpty(name)) { this.name = Str.uncapitalize(classMeta.name()); serviceAddress = Str.slc(serviceAddress, 0, -1); if (!Str.isEmpty(rootAddress)) { rootAddress = Str.slc(rootAddress, 0, -1); this.address = Str.add(rootAddress, serviceAddress); } else { this.address = Str.add(rootAddress, "/", serviceAddress); ? methodAnnotation.getValues().get("value").toString() : null; if (Str.isEmpty(methodEventBusName)) { methodEventBusName = methodAccess.name();
public String method2(final String arg1, final int arg2, final float arg3, final double arg4) { return sputs(arg1, arg2, arg3, arg4); }
private RequestMetaData doGet(final String path) { RequestMetaData requestMetaData = metaDataMap.get(path); if (requestMetaData == null) { Map.Entry<String, NavigableMap<Integer, RequestMetaData>> uriParamNumMapEntry = treeMap.lowerEntry(path); if (uriParamNumMapEntry == null) { return null; } final String requestURI = Str.isEmpty(rootURI) ? path : StringScanner.substringAfter(path, rootURI); int count = Str.split(requestURI, '/').length - 1; NavigableMap<Integer, RequestMetaData> uriParamMap = uriParamNumMapEntry.getValue(); requestMetaData = uriParamMap.get(count); if (requestMetaData != null && path.startsWith(requestMetaData.getPath())) { return requestMetaData; } else { return null; } } else { return requestMetaData; } }
private String getServiceName(ClassMeta<?> classMeta) { String name = AnnotationUtils.readServiceName(classMeta); if (Str.isEmpty(name)) { name = Str.camelCaseLower(classMeta.name()); } return name; }
public static StackTraceElement[] getFilteredStackTrace(StackTraceElement[] stackTrace) { if (stackTrace == null || stackTrace.length == 0) { return new StackTraceElement[0]; } List<StackTraceElement> list = new ArrayList<>(); Set<String> seenThisBefore = new HashSet<>(); for (StackTraceElement st : stackTrace) { if (startsWithItemInCollection(st.getClassName(), ignorePackages)) { continue; } String key = Str.sputs(st.getClassName(), st.getFileName(), st.getMethodName(), st.getLineNumber()); if (seenThisBefore.contains(key)) { continue; } else { seenThisBefore.add(key); } list.add(st); } return array(StackTraceElement.class, list); }
private boolean isJsonContent(final String contentType) { return Str.isEmpty(contentType) || contentType.equals("application/json") || contentType.equals("application/json;charset=utf-8") || contentType.startsWith("application/json"); } }
namedParam = ((NamedParam) parameterMeta.getParam()); value = request.getParam(namedParam.getName()); if (namedParam.isRequired() && Str.isEmpty(value)) { errorsList.add(sputs("Unable to find required request param", namedParam.getName())); break loop; if (Str.isEmpty(value)) { value = namedParam.getDefaultValue(); namedParam = ((NamedParam) parameterMeta.getParam()); value = request.headers().get(namedParam.getName()); if (namedParam.isRequired() && Str.isEmpty(value)) { errorsList.add(sputs("Unable to find required header param", namedParam.getName())); break loop; if (Str.isEmpty(value)) { value = namedParam.getDefaultValue(); namedParam = ((NamedParam) parameterMeta.getParam()); value = request.data().get(namedParam.getName()); if (namedParam.isRequired() && Str.isEmpty(value)) { errorsList.add(sputs("Unable to find required data param", namedParam.getName())); break loop; case PATH_BY_NAME: URINamedParam uriNamedParam = ((URINamedParam) parameterMeta.getParam()); final String[] split = Str.split(request.address(), '/'); if (uriNamedParam.getIndexIntoURI() >= split.length) { if (uriNamedParam.isRequired()) {
protected URI createURI(String path) { URI uri = URI.create(Str.add(scheme, "://", host, ":", port, rootPath, path)); return uri; }
public static int findURIPosition(String path, String findString) { final String[] pathParts = Str.split(path, '/'); int position; for (position = 0; position < pathParts.length; position++) { String pathPart = pathParts[position]; if (pathPart.equals(findString)) { break; } } return position; }
/** * Get slice of string * @param str string * @param start start index * @param end end index * @return new string */ public static String sliceOf( String str, int start, int end ) { return slc(str, start, end); }
public BaseService(final Reactor reactor, final Timer timer, final StatsCollector statsCollector) { this.statsCollector = statsCollector; this.reactor = reactor; this.timer = timer; statKeyPrefix = Str.underBarCase(this.getClass().getSimpleName()).replace('_', '.') + "."; statNameMap = new HashMap<>(); }
public static String createChannelName(final String channelPrefix, final String classChannelNamePart, final String methodChannelNamePart) { if (methodChannelNamePart == null) { throw new IllegalArgumentException("Each method must have an event bus channel name"); } //If Channel prefix is null then just use class channel name and method channel name if (channelPrefix == null) { //If the class channel name is null just return the method channel name. if (classChannelNamePart == null) { return methodChannelNamePart; } else { //Channel name takes the form ${classChannelNamePart.methodChannelNamePart} return Str.join('.', classChannelNamePart, methodChannelNamePart); } } else { //If classChannelNamePart null then channel name takes the form ${channelPrefix.methodChannelNamePart} if (classChannelNamePart == null) { return Str.join('.', channelPrefix, methodChannelNamePart); } else { //Nothing was null so the channel name takes the form ${channelPrefix.classChannelNamePart.methodChannelNamePart} return Str.join('.', channelPrefix, classChannelNamePart, methodChannelNamePart); } } }
public static Currency toCurrency(Object obj) { if (obj instanceof Currency) { return (Currency) obj; } if (obj instanceof String) { String str = Str.toString(obj); return Currency.getInstance(str); } return null; }
public AnnotationData( Annotation annotation, Set<String> allowedAnnotations ) { this.annotationSimpleName = annotation.annotationType().getSimpleName (); this.annotationClassName = annotation.annotationType().getName (); this.annotationPackageName = annotationClassName.substring ( 0, annotationClassName.length () - annotationSimpleName.length () - 1 ); this.allowedAnnotations = allowedAnnotations; this.name = uncapitalize( annotationSimpleName ); this.values = doGetValues(annotation); }
/** * Finds the admin port. * Searches under environment variables, * {@code QBIT_ADMIN_PORT}, {@code ADMIN_PORT}, {@code PORT1}. * * @return admin port */ public String findAdminPort() { String qbitAdminPort = System.getenv("QBIT_ADMIN_PORT"); if (Str.isEmpty(qbitAdminPort)) { qbitAdminPort = System.getenv("ADMIN_PORT"); } /* Uses PORT1 for admin port for Mesosphere / Heroku like environments. */ if (Str.isEmpty(qbitAdminPort)) { qbitAdminPort = System.getenv("PORT1"); } return qbitAdminPort; }
public static StackTraceElement[] getFilteredStackTrace(StackTraceElement[] stackTrace) { if (stackTrace == null || stackTrace.length == 0) { return new StackTraceElement[0]; } List<StackTraceElement> list = new ArrayList<>(); Set<String> seenThisBefore = new HashSet<>(); for (StackTraceElement st : stackTrace) { if ( startsWithItemInCollection( st.getClassName(), ignorePackages ) ) { continue; } String key = Str.sputs(st.getClassName(), st.getFileName(), st.getMethodName(), st.getLineNumber()); if (seenThisBefore.contains(key)) { continue; } else { seenThisBefore.add(key); } list.add(st); } return array( StackTraceElement.class, list ); }
default void respond(int code, String json) { response(code, "application/json", Str.add("\"", json, "\"")); }