• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Pair类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.musala.atmosphere.commons.util.Pair的典型用法代码示例。如果您正苦于以下问题:Java Pair类的具体用法?Java Pair怎么用?Java Pair使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Pair类属于com.musala.atmosphere.commons.util包,在下文中一共展示了Pair类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: resolveTypeForRoutingAction

import com.musala.atmosphere.commons.util.Pair; //导入依赖的package包/类
/**
 * Resolves the types of the arguments in some non-trivial cases (e. g. collections). Creates a {@link TypeToken}
 * according the {@link MessageAction} and {@link RoutingAction} of the response.
 */
private Type resolveTypeForRoutingAction(JsonElement typeElement,
                                         MessageAction messageAction,
                                         RoutingAction routingAction) {
    Type type = null;

    switch (messageAction) {
        case ROUTING_ACTION:
            type = resolve(typeElement, routingAction);
            break;
        case DEVICE_ALLOCATION_INFORMATION:
            type = defaultResolver(typeElement);
            break;
        case GET_ALL_AVAILABLE_DEVICES:
            type = new TypeToken<List<Pair<String, String>>>() {}.getType();
            break;
        default:
            LOGGER.error("The message action is not recognized.");
            break;
    }

    return type;
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-commons,代码行数:27,代码来源:ResponseMessageDeserializer.java


示例2: setUp

import com.musala.atmosphere.commons.util.Pair; //导入依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
    Class<?> agentClass = agent.getClass();
    Field agentManagerField = agentClass.getDeclaredField("agentManager");
    agentManagerField.setAccessible(true);
    AgentManager agentManager = (AgentManager) agentManagerField.get(agent);

    if (!agentManager.isAnyEmulatorPresent()) {
        EmulatorParameters emulatorCreationParameters = new EmulatorParameters();
        emulatorCreationParameters.setDpi(EMULATOR_CREATION_DPI);
        emulatorCreationParameters.setRam(EMULATOR_CREATION_RAM);
        emulatorCreationParameters.setResolution(new Pair<Integer, Integer>(EMULATOR_CREATION_RESOLUTION_H,
                                                                            EMULATOR_CREATION_RESOLUTION_W));
    }

    DeviceSelectorBuilder selectorBuilder = new DeviceSelectorBuilder().deviceType(DeviceType.EMULATOR_ONLY);
    DeviceSelector testDeviceSelector = selectorBuilder.build();
    initTestDevice(testDeviceSelector);
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-integration-tests,代码行数:20,代码来源:EmulatorConsoleTest.java


示例3: testGetScreenshot

import com.musala.atmosphere.commons.util.Pair; //导入依赖的package包/类
@Test
public void testGetScreenshot() throws Exception {
    byte[] screenshot = testDevice.getScreenshot();
    DeviceInformation deviceInformation = testDevice.getInformation();
    Pair<Integer, Integer> screenResolution = deviceInformation.getResolution();

    InputStream imageInput = new ByteArrayInputStream(screenshot);
    BufferedImage image = ImageIO.read(imageInput);

    assertNotNull("Screenshot data is not a valid image.", image);

    assertEquals("Device screen resolution height did not match screenshot height.",
                 (int) screenResolution.getValue(),
                 image.getHeight());
    assertEquals("Device screen resolution width did not match screenshot width.",
                 (int) screenResolution.getKey(),
                 image.getWidth());
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-integration-tests,代码行数:19,代码来源:GetScreenshotTest.java


示例4: parseAndExecuteShellCommand

import com.musala.atmosphere.commons.util.Pair; //导入依赖的package包/类
/**
 * Executes a passed shell command from the console.
 *
 * @param passedShellCommand
 *        - the passed shell command.
 * @throws IllegalArgumentException
 *         - if the passed argument is <b>null</b>
 */
public void parseAndExecuteShellCommand(String passedShellCommand) {
    if (passedShellCommand != null) {
        Pair<String, List<String>> parsedCommand = ConsoleControl.parseShellCommand(passedShellCommand);
        String command = parsedCommand.getKey();
        List<String> params = parsedCommand.getValue();

        AgentCommand commandForExecution = AgentCommandFactory.getCommandInstance(command, params);
        if (commandForExecution != null) {
            currentAgentState.executeCommand(commandForExecution);
        } else {
            String helpCommand = AgentConsoleCommands.AGENT_HELP.getCommand();
            String errorMessage = String.format("Unknown command \"%s\". Type '%s' for all available commands.",
                                                command,
                                                helpCommand);
            agentConsole.writeLine(errorMessage);
        }
    } else {
        LOGGER.error("Error in console: trying to execute 'null' as a command.");
        throw new IllegalArgumentException("Command passed for execution to agent is 'null'");
    }
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-agent,代码行数:30,代码来源:Agent.java


示例5: validatePointOnScreen

import com.musala.atmosphere.commons.util.Pair; //导入依赖的package包/类
/**
 * Checks whether the given point is inside the bounds of the screen, and throws an {@link IllegalArgumentException}
 * otherwise.
 *
 * @param point
 *        - the point to be checked
 */
private void validatePointOnScreen(Point point) {
    Pair<Integer, Integer> resolution = deviceInformation.getResolution();

    boolean hasPositiveCoordinates = point.getX() >= 0 && point.getY() >= 0;
    boolean isOnScreen = point.getX() <= resolution.getKey() && point.getY() <= resolution.getValue();

    if (!hasPositiveCoordinates || !isOnScreen) {
        String exeptionMessageFormat = "The passed point with coordinates (%d, %d) is outside the bounds of the screen. Screen dimentions (%d, %d)";
        String message = String.format(exeptionMessageFormat,
                                       point.getX(),
                                       point.getY(),
                                       resolution.getKey(),
                                       resolution.getValue());
        LOGGER.error(message);
        throw new IllegalArgumentException(message);
    }
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-agent,代码行数:25,代码来源:GestureEntity.java


示例6: startScreenRecording

import com.musala.atmosphere.commons.util.Pair; //导入依赖的package包/类
private void startScreenRecording(int timeLimit, boolean forceLandscape) throws CommandFailedException {
    String externalStorage = serviceCommunicator.getExternalStorage();
    String recordsParentDir = externalStorage != null ? externalStorage : FALLBACK_COMPONENT_PATH;

    Pair<Integer, Integer> resolution = deviceInformation.getResolution();
    int width = Math.max(resolution.getKey(), resolution.getValue());
    int height = Math.min(resolution.getKey(), resolution.getValue());

    String screenResoloution = !forceLandscape ? String.format("%sx%s", height, width)
            : String.format("%sx%s", width, height);
    int timeLimitInSeconds = timeLimit * 60;

    String screenRecordCommand = String.format("%s%s %d %s",
                                               START_SCREEN_RECORD_COMMAND,
                                               recordsParentDir,
                                               timeLimitInSeconds,
                                               screenResoloution);

    shellCommandExecutor.executeInBackground(screenRecordCommand);
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-agent,代码行数:21,代码来源:AbstractWrapDevice.java


示例7: parseScreenResolutionFromShell

import com.musala.atmosphere.commons.util.Pair; //导入依赖的package包/类
/**
 * Converts the shell response from the "dumpsys window policy" command to a pair of integers.
 * 
 * @param shellResponse
 *        String response from the shell command execution
 * @return Pair of integers - key is width, value is height in pixels.
 */
public static Pair<Integer, Integer> parseScreenResolutionFromShell(String shellResponse) {
    // Isolate the important line from the response
    int importantLineStart = shellResponse.indexOf("mUnrestrictedScreen");
    int importantLineEnd = shellResponse.indexOf('\r', importantLineStart);
    if (importantLineEnd == -1) {
        importantLineEnd = shellResponse.indexOf('\n', importantLineStart);
    }

    String importantLine = shellResponse.substring(importantLineStart, importantLineEnd);

    // Isolate the values from the line
    int valueStartIndex = importantLine.indexOf(' ');
    String importantValue = importantLine.substring(valueStartIndex + 1);

    // The values are in the form [integer]x[integer]
    int delimiterIndex = importantValue.indexOf('x');
    String widthString = importantValue.substring(0, delimiterIndex);
    String heightString = importantValue.substring(delimiterIndex + 1);

    int width = Integer.parseInt(widthString);
    int height = Integer.parseInt(heightString);

    Pair<Integer, Integer> screenResolution = new Pair<Integer, Integer>(width, height);
    return screenResolution;
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-agent,代码行数:33,代码来源:DeviceScreenResolutionParser.java


示例8: Device

import com.musala.atmosphere.commons.util.Pair; //导入依赖的package包/类
/**
 * Creates new device with the given serial number, device identifier and passkey.
 *
 * @param deviceInformation
 *        - the {@link DeviceInformation information} of this device
 * @param deviceId
 *        - the identifier of this device
 * @param passkeyAuthority
 *        - a passkey for validating authority
 */
public Device(DeviceInformation deviceInformation, String deviceId, long passkeyAuthority) {
    apiLevel = deviceInformation.getApiLevel();
    cpu = deviceInformation.getCpu();
    dpi = deviceInformation.getDpi();
    manufacturer = deviceInformation.getManufacturer();
    model = deviceInformation.getModel();
    os = deviceInformation.getOS();
    ram = deviceInformation.getRam();
    Pair<Integer, Integer> resolution = deviceInformation.getResolution();
    resolutionWidth = resolution.getValue();
    resolutionHeight = resolution.getKey();
    serialNumber = deviceInformation.getSerialNumber();
    isEmulator = deviceInformation.isEmulator();
    isTablet = deviceInformation.isTablet();
    hasCamera = deviceInformation.hasCamera();
    this.deviceId = deviceId;
    passkey = passkeyAuthority;
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-server,代码行数:29,代码来源:Device.java


示例9: setDeviceInformation

import com.musala.atmosphere.commons.util.Pair; //导入依赖的package包/类
@Override
public void setDeviceInformation(DeviceInformation information) {
    apiLevel = information.getApiLevel();
    cpu = information.getCpu();
    dpi = information.getDpi();
    manufacturer = information.getManufacturer();
    model = information.getModel();
    os = information.getOS();
    ram = information.getRam();
    Pair<Integer, Integer> resolution = information.getResolution();
    resolutionWidth = resolution.getValue();
    resolutionHeight = resolution.getKey();
    serialNumber = information.getSerialNumber();
    isEmulator = information.isEmulator();
    isTablet = information.isTablet();
    hasCamera = information.hasCamera();
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-server,代码行数:18,代码来源:Device.java


示例10: parseAndExecuteShellCommand

import com.musala.atmosphere.commons.util.Pair; //导入依赖的package包/类
/**
 * Executes a passed command from the console.
 *
 * @param passedShellCommand
 *        - the passed shell command.
 * @throws IOException
 */
private void parseAndExecuteShellCommand(String passedShellCommand) throws IOException {
    if (passedShellCommand != null) {
        Pair<String, List<String>> parsedCommand = ConsoleControl.parseShellCommand(passedShellCommand);
        String command = parsedCommand.getKey();
        List<String> paramsAsList = parsedCommand.getValue();

        if (!command.isEmpty()) {
            String[] params = new String[paramsAsList.size()];
            paramsAsList.toArray(params);
            executeShellCommand(command, params);
        }
    } else {
        LOGGER.error("Error in console: trying to execute 'null' as a command.");
        throw new IllegalArgumentException("Command passed to server is 'null'");
    }
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-server,代码行数:24,代码来源:Server.java


示例11: invokeSubscriberMethod

import com.musala.atmosphere.commons.util.Pair; //导入依赖的package包/类
private void invokeSubscriberMethod(Subscriber subscriber, Event event) {
    Class<?> eventClass = event.getClass();
    Class<?> subscriberClass = subscriber.getClass();

    try {
        Entry<Class<?>, Class<?>> methodIdentifiers = new Pair<Class<?>, Class<?>>(subscriberClass, eventClass);
        Method method = subscibersMethodsCache.get(methodIdentifiers);

        if (method == null) {
            method = subscriberClass.getDeclaredMethod(RECEIVER_METHOD_NAME, eventClass);
            subscibersMethodsCache.put(methodIdentifiers, method);
        }

        method.invoke(subscriber, event);
    } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException
            | InvocationTargetException e) {
        String errorMessage = String.format("Failed to invoke %s method with %s.",
                                            RECEIVER_METHOD_NAME,
                                            event.getClass().getSimpleName());
        throw new SubscriberMethodInvocationException(errorMessage, e);
    }
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-server,代码行数:23,代码来源:ServerEventService.java


示例12: setUp

import com.musala.atmosphere.commons.util.Pair; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@BeforeClass
public static void setUp() throws InterruptedException {
    try {
        server = new Server();
        server.run();
        Thread.sleep(START_SERVER_TIMEOUT);

        ServerManager serverManager = getFieldObject(server, "serverManager");
        dAllocManager = (DeviceAllocationManager) getFieldObject(server, "allocationManager");

        serverManager.registerAgent(AGENT_ID);

        poolManager = getFieldObject(serverManager, "poolManager");
        waitingClients = (List<Pair<DeviceSelector, String>>) getFieldObject(dAllocManager, "waitingClients");
    } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
        e.printStackTrace();
    }
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-server,代码行数:20,代码来源:DeviceAllocationManagerTest.java


示例13: setUiSelectorClassNameWithSelectionOption

import com.musala.atmosphere.commons.util.Pair; //导入依赖的package包/类
private static UiSelector setUiSelectorClassNameWithSelectionOption(UiSelector uiSelector, Pair<String, UiElementSelectionOption> propertyPair) {
    switch (propertyPair.getValue()) {
        case CONTAINS:
            String pattern = "^.*%s.*$";
            uiSelector = uiSelector.classNameMatches(String.format(pattern, propertyPair.getKey()));
            break;
        case EQUALS:
            uiSelector = uiSelector.className(propertyPair.getKey());
            break;
        case WORD_MATCH:
            uiSelector = uiSelector.classNameMatches(propertyPair.getKey());
            break;
        default:
            uiSelector = uiSelector.className(propertyPair.getKey());
            break;
    }

    return uiSelector;
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-uiautomator-bridge,代码行数:20,代码来源:UiSelectorParser.java


示例14: setUiSelectorPackageWithSelectionOption

import com.musala.atmosphere.commons.util.Pair; //导入依赖的package包/类
private static UiSelector setUiSelectorPackageWithSelectionOption(UiSelector uiSelector, Pair<String, UiElementSelectionOption> propertyPair) {
    switch (propertyPair.getValue()) {
        case CONTAINS:
            String pattern = "^.*%s.*$";
            uiSelector = uiSelector.packageNameMatches(String.format(pattern, propertyPair.getKey()));
            break;
        case EQUALS:
            uiSelector = uiSelector.packageName(propertyPair.getKey());
            break;
        case WORD_MATCH:
            uiSelector = uiSelector.packageNameMatches(propertyPair.getKey());
            break;
        default:
            uiSelector = uiSelector.packageName(propertyPair.getKey());
            break;
    }

    return uiSelector;
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-uiautomator-bridge,代码行数:20,代码来源:UiSelectorParser.java


示例15: setUiSelectorTextWithSelectionOption

import com.musala.atmosphere.commons.util.Pair; //导入依赖的package包/类
private static UiSelector setUiSelectorTextWithSelectionOption(UiSelector uiSelector, Pair<String, UiElementSelectionOption> propertyPair) {
    switch (propertyPair.getValue()) {
        case CONTAINS:
            uiSelector = uiSelector.textContains(propertyPair.getKey());
            break;
        case EQUALS:
            uiSelector = uiSelector.text(propertyPair.getKey());
            break;
        case WORD_MATCH:
            uiSelector = uiSelector.textMatches(propertyPair.getKey());
            break;
        default:
            uiSelector = uiSelector.text(propertyPair.getKey());
            break;

    }

    return uiSelector;
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-uiautomator-bridge,代码行数:20,代码来源:UiSelectorParser.java


示例16: setUiSelectorDescriptionWithSelectionOption

import com.musala.atmosphere.commons.util.Pair; //导入依赖的package包/类
private static UiSelector setUiSelectorDescriptionWithSelectionOption(UiSelector uiSelector, Pair<String, UiElementSelectionOption> propertyPair) {
    switch (propertyPair.getValue()) {
        case CONTAINS:
            uiSelector = uiSelector.descriptionContains(propertyPair.getKey());
            break;
        case EQUALS:
            uiSelector = uiSelector.description(propertyPair.getKey());
            break;
        case WORD_MATCH:
            uiSelector = uiSelector.descriptionMatches(propertyPair.getKey());
            break;
        default:
            uiSelector = uiSelector.description(propertyPair.getKey());
            break;
    }

    return uiSelector;
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-uiautomator-bridge,代码行数:19,代码来源:UiSelectorParser.java


示例17: printBuffer

import com.musala.atmosphere.commons.util.Pair; //导入依赖的package包/类
/**
 * Prints/Write data from the LogCat buffer and returns the total number of the lines.
 *
 * @param bufferedWriter
 *        - a {@link BufferedWriter}
 * @param buffer
 *        - {@link Pair} of control number and log data
 * @param expectedLineId
 *        - a control ID that verifies that the log data is received in consistent order
 * @return the ID of the next expected line from the buffer.
 * @throws IOException
 *         throw when fails to write the data from the buffer
 */
private int printBuffer(BufferedWriter bufferedWriter, List<Pair<Integer, String>> buffer, int expectedLineId)
    throws IOException {
    if (buffer.size() > 0) {
        for (Pair<Integer, String> idToLogLine : buffer) {
            if (expectedLineId != idToLogLine.getKey()) {
                LOGGER.error("Some logcat output is missing.");
            }
            System.out.println(idToLogLine.getValue());
            bufferedWriter.write(idToLogLine.getValue() + System.getProperty("line.separator"));
            expectedLineId++;
        }
    }

    return expectedLineId;
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-client,代码行数:29,代码来源:Device.java


示例18: isMatch

import com.musala.atmosphere.commons.util.Pair; //导入依赖的package包/类
private boolean isMatch(Pair<String, UiElementSelectionOption> selectorPair, String nodeValue) {
    if (nodeValue == null) {
        return false;
    }
    switch (selectorPair.getValue()) {
        case CONTAINS:
            return nodeValue.contains(selectorPair.getKey());
        case EQUALS:
            return nodeValue.equals(selectorPair.getKey());
        case WORD_MATCH:
            return nodeValue.matches(selectorPair.getKey());
        default:
            return nodeValue.equals(selectorPair.getKey());
    }
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-commons,代码行数:16,代码来源:UiElementSelectorMatcherCompat.java


示例19: getStringValueWithSelectionOption

import com.musala.atmosphere.commons.util.Pair; //导入依赖的package包/类
/**
 * Returns a {@link Pair} of the value of a string {@link CssAttribute} and its {@link UiElementSelectionOption} option.
 *
 * @param attribute
 *        - the string attribute to get the value of
 * @return a {@link Pair} of the attribute's value and its selection option, or <code>null</code>
 *         if the value or the selection option is <code>null</code>
 * @throws IllegalArgumentException if the provided attribute is not a string attribute
 */
public Pair<String, UiElementSelectionOption> getStringValueWithSelectionOption(CssAttribute attribute) {
    String stringValue = getStringValue(attribute);
    UiElementSelectionOption selectionOption = getUiElementSelectionOption(attribute);

    if (stringValue == null || selectionOption == null) {
        return null;
    }

    return new Pair<String, UiElementSelectionOption>(stringValue, selectionOption);
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-commons,代码行数:20,代码来源:UiElementSelector.java


示例20: buildCssQuery

import com.musala.atmosphere.commons.util.Pair; //导入依赖的package包/类
/**
 * Builds a CSS select element query based on the contents of this selector.
 *
 * @return the built CSS query
 */
public String buildCssQuery() {
    StringBuilder builder = new StringBuilder();

    for (Entry<CssAttribute, Pair<Object, UiElementSelectionOption>> attributeProjectionMapEntry : attributeProjectionMap.entrySet()) {
        Object selectionExpression = attributeProjectionMapEntry.getValue().getKey();
        if (selectionExpression != null) {
            CssAttribute attribute = attributeProjectionMapEntry.getKey();
            UiElementSelectionOption selectionOption = attributeProjectionMapEntry.getValue().getValue();
            builder.append(selectionOption.constructAttributeSelector(attribute, selectionExpression));
        }
    }

    return builder.toString();
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-commons,代码行数:20,代码来源:UiElementSelector.java



注:本文中的com.musala.atmosphere.commons.util.Pair类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TDisruptorServer类代码示例发布时间:2022-05-23
下一篇:
Java Matrix类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap