BeanUtils.idx(httpRequest, "receiver", httpTextReceiver);
public static ShardedMethodDispatcher shardOnBeanPath(final String beanPath) { return new ShardedMethodDispatcher((methodName, methodArgs, numWorkers) -> { //noinspection UnnecessaryLocalVariable @SuppressWarnings("UnnecessaryLocalVariable") int shardKey = BeanUtils.idx(methodArgs, beanPath).hashCode() % numWorkers; return shardKey; }); }
public static void setIterableProperty(Iterable<?> list, String propertyName, Object value) { for (Object object : list) { BeanUtils.idx(object, propertyName, value); } }
@Override public T next() { T next = (T) BeanUtils.idx(value, i); i++; return next; }
public static void setListProperty(List<?> list, String propertyName, Object value) { for (Object object : list) { BeanUtils.idx(object, propertyName, value); } }
@Override public WebSocket createWebSocket(final String uri) { final WebSocketBuilder webSocketBuilder = WebSocketBuilder.webSocketBuilder().setRemoteAddress("test").setUri(uri).setBinary(false).setOpen(true); final WebSocket webSocket = webSocketBuilder.build(); final WebSocketSender webSocketSender = new WebSocketSender() { @Override public void sendText(final String body) { httpSendWebSocketCalled = true; periodicFlushCallback.accept(null); Sys.sleep(100); } }; BeanUtils.idx(webSocket, "networkSender", webSocketSender); return webSocket; }
public static <PROP> List<PROP> toList( List<?> inputList, Class<PROP> cls, String propertyPath ) { List<PROP> outputList = new ArrayList<>(); for (Object o : inputList) { outputList.add((PROP) BeanUtils.idx(o, propertyPath)); } return outputList; }
public static List<?> toList( List<?> inputList, String propertyPath ) { List<Object> outputList = new ArrayList<>(); for (Object o : inputList) { outputList.add(BeanUtils.idx(o, propertyPath)); } return outputList; }
public static <T> List<T> listFromProperty( Class<T> propertyType, String propertyPath, Iterable<?> list ) { List<T> newList = new ArrayList<>( ); for ( Object item : list ) { T newItem = ( T ) BeanUtils.idx( item, propertyPath ); newList.add( newItem ); } return newList; } public static List<Map<String, Object>> toListOfMaps( List<?> list ) {
public static List<?> toList( List<?> inputList, String propertyPath ) { List<Object> outputList = new ArrayList<>(); for (Object o : inputList) { outputList.add(BeanUtils.idx(o, propertyPath)); } return outputList; }
public static <T> Set<T> setFromProperty( Class<T> propertyType, String propertyPath, Iterable<?> list ) { Set<T> newSet = new LinkedHashSet<>( ); for ( Object item : list ) { T newItem = ( T ) BeanUtils.idx( item, propertyPath ); newSet.add(newItem); } return newSet; }
public static <T> List<T> listFromProperty( Class<T> propertyType, String propertyPath, Collection<?> list ) { List<T> newList = new ArrayList<>( list.size() ); for ( Object item : list ) { T newItem = ( T ) BeanUtils.idx( item, propertyPath ); newList.add( newItem ); } return newList; }
public static <T> Set<T> setFromProperty( Class<T> propertyType, String propertyPath, Collection<?> list ) { Set<T> newSet = new LinkedHashSet<>( list.size() ); for ( Object item : list ) { T newItem = ( T ) BeanUtils.idx( item, propertyPath ); newSet.add(newItem); } return newSet; }
public static <T> List<T> listFromProperty( Class<T> propertyType, String propertyPath, Collection<?> list ) { List<T> newList = new ArrayList<>( list.size() ); for ( Object item : list ) { T newItem = ( T ) BeanUtils.idx( item, propertyPath ); newList.add( newItem ); } return newList; }
@Override public WebSocket createWebSocket(final String uri) { final WebSocketBuilder webSocketBuilder = WebSocketBuilder.webSocketBuilder().setRemoteAddress("test").setUri(uri).setBinary(false).setOpen(true); final WebSocket webSocket = webSocketBuilder.build(); final WebSocketSender webSocketSender = new WebSocketSender() { @Override public void sendText(final String body) { httpSendWebSocketCalled.set(true); periodicFlushCallback.accept(null); final List<MethodCall<Object>> methodCalls = QBit.factory().createProtocolParser().parseMethodCalls("", body); serviceBundle.call(methodCalls); serviceBundle.flush(); Sys.sleep(100); if (response != null) { if (response.wasErrors()) { puts("FAILED RESPONSE", response); } else { String simulatedMessageFromServer = QBit.factory().createEncoder().encodeResponses("", Lists.list(response)); webSocket.onTextMessage(simulatedMessageFromServer); } } else { puts(response); } } }; BeanUtils.idx(webSocket, "networkSender", webSocketSender); return webSocket; }
public static Object toArrayGuessType(Collection<?> value) { Class<?> componentType = Reflection.getComponentType(value); Object array = Array.newInstance(componentType, value.size()); @SuppressWarnings("unchecked") Iterator<Object> iterator = (Iterator<Object>) value.iterator(); int index = 0; while (iterator.hasNext()) { BeanUtils.idx(array, index, iterator.next()); index++; } return array; }
private static <K, T> void doPopulateMapWithCollectionAndPropPath( Class<K> keyType, String propertyPath, Collection<T> collection, Map<K, T> map ) { for ( T item : collection ) { Object oKey = BeanUtils.idx( item, propertyPath ); if ( oKey == null ) { continue; } K key = Conversions.coerce( keyType, oKey ); map.put( key, item ); } }
/** * Get property value * * @param object object * @param path in dotted notation * @return string */ public static String idxStr( Object object, String path ) { final Object val = idx(object, path); return Conversions.toString(val); }
public static ShardedMethodDispatcher shardOnBeanPath(final String beanPath) { return new ShardedMethodDispatcher((methodName, methodArgs, numWorkers) -> { //noinspection UnnecessaryLocalVariable @SuppressWarnings("UnnecessaryLocalVariable") int shardKey = BeanUtils.idx(methodArgs, beanPath).hashCode() % numWorkers; return shardKey; }); }
public static Object toArrayGuessType(Collection<?> value) { Class<?> componentType = Reflection.getComponentType(value); Object array = Array.newInstance(componentType, value.size()); @SuppressWarnings("unchecked") Iterator<Object> iterator = (Iterator<Object>) value.iterator(); int index = 0; while (iterator.hasNext()) { BeanUtils.idx(array, index, iterator.next()); index++; } return array; }