当前位置: 首页>>代码示例>>Java>>正文


Java Arrays.asList方法代码示例

本文整理汇总了Java中java.util.Arrays.asList方法的典型用法代码示例。如果您正苦于以下问题:Java Arrays.asList方法的具体用法?Java Arrays.asList怎么用?Java Arrays.asList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.Arrays的用法示例。


在下文中一共展示了Arrays.asList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testUpdatePortStatus

import java.util.Arrays; //导入方法依赖的package包/类
@Test
public final void testUpdatePortStatus() {
    putDevice(DID1, SW1);
    List<PortDescription> pds = Arrays.<PortDescription>asList(
            new DefaultPortDescription(P1, true)
            );
    deviceStore.updatePorts(PID, DID1, pds);

    DeviceEvent event = deviceStore.updatePortStatus(PID, DID1,
            new DefaultPortDescription(P1, false));
    assertEquals(PORT_UPDATED, event.type());
    assertDevice(DID1, SW1, event.subject());
    assertEquals(P1, event.port().number());
    assertFalse("Port is disabled", event.port().isEnabled());

}
 
开发者ID:shlee89,项目名称:athena,代码行数:17,代码来源:SimpleDeviceStoreTest.java

示例2: getExecCommandForInstallService

import java.util.Arrays; //导入方法依赖的package包/类
/**
 * Method to generate remote command for installing service for jvm
 *
 * @param jvm
 * @return
 */
private ExecCommand getExecCommandForInstallService(Jvm jvm) {
    final String userName;
    final String encryptedPassword;

    if (jvm.getUserName() != null) {
        userName = jvm.getUserName();
        encryptedPassword = jvm.getEncryptedPassword();
    } else {
        userName = null;
        encryptedPassword = null;
    }

    final String quotedUsername = addQuotes(userName);
    final String decryptedPassword = encryptedPassword != null && encryptedPassword.length() > 0 ? new DecryptPassword().decrypt(encryptedPassword) : "";
    final String quotedPassword = addQuotes(decryptedPassword);

    List<String> formatStrings = Arrays.asList(getFullPathScript(jvm, INSTALL_SERVICE_SCRIPT_NAME.getValue()),
            jvm.getJvmName(), jvm.getTomcatMedia().getRemoteDir().normalize().toString(),
            jvm.getTomcatMedia().getRootDir().toString());
    List<String> unformatStrings = Arrays.asList(quotedUsername, quotedPassword);

    return new ExecCommand(formatStrings, unformatStrings);
}
 
开发者ID:cerner,项目名称:jwala,代码行数:30,代码来源:JvmCommandFactory.java

示例3: getSubscriptions

import java.util.Arrays; //导入方法依赖的package包/类
/**
 * Gets a list of {@link Subscription}s that the current user is subscribed
 * to.
 * 
 * @return {@link List}<{@link Subscription}> representing the subscriptions
 * @throws URISyntaxException
 * @throws IOException
 * @throws GroupsIOApiException
 */
public List<Subscription> getSubscriptions() throws URISyntaxException, IOException, GroupsIOApiException
{
    final URIBuilder uri = new URIBuilder().setPath(baseUrl + "getsubs");
    uri.setParameter("limit", MAX_RESULTS);
    final HttpGet request = new HttpGet();
    request.setURI(uri.build());
    
    Page page = callApi(request, Page.class);
    
    final List<Subscription> subscriptions = Arrays.asList(OM.convertValue(page.getData(), Subscription[].class));
    
    while (page.getHasMore())
    {
        uri.setParameter("page_token", page.getNextPageToken().toString());
        request.setURI(uri.build());
        page = callApi(request, Page.class);
        subscriptions.addAll(Arrays.asList(OM.convertValue(page.getData(), Subscription[].class)));
    }
    
    return subscriptions;
}
 
开发者ID:lake54,项目名称:groupsio-api-java,代码行数:31,代码来源:UserResource.java

示例4: rotateMatix1

import java.util.Arrays; //导入方法依赖的package包/类
@Test
public void rotateMatix1() {
    expected = Arrays.asList(
            Arrays.asList(13,9,5,1),
            Arrays.asList(14,10,6,2),
            Arrays.asList(15,11,7,3),
            Arrays.asList(16,12,8,4)
    );
    matrix = Arrays.asList(
            Arrays.asList(1,2,3,4),
            Arrays.asList(5,6,7,8),
            Arrays.asList(9,10,11,12),
            Arrays.asList(13,14,15,16)
    );

    test(expected, matrix);
}
 
开发者ID:gardncl,项目名称:elements-of-programming-interviews-solutions,代码行数:18,代码来源:Rotate2DArrayTest.java

示例5: insertGroupToNestedSectionNotifiesAtCorrectIndex

import java.util.Arrays; //导入方法依赖的package包/类
@Test
public void insertGroupToNestedSectionNotifiesAtCorrectIndex() throws Exception {
    final Section rootSection = new Section();

    rootSection.setGroupDataObserver(groupAdapter);
    groupAdapter.add(rootSection);

    final Section nestedSection1 = new Section(Arrays.asList(new DummyItem(), new DummyItem()));
    rootSection.add(nestedSection1);

    final Section nestedSection2 = new Section(Arrays.asList(new DummyItem(), new DummyItem(), new DummyItem()));
    rootSection.add(nestedSection2);

    final Section nestedSection3 = new Section(Arrays.asList(new DummyItem(), new DummyItem()));

    reset(groupAdapter);
    rootSection.add(1, nestedSection3);
    verify(groupAdapter).onItemRangeInserted(rootSection, 2, 2);
}
 
开发者ID:Genius,项目名称:genius-groupie,代码行数:20,代码来源:SectionTest.java

示例6: register

import java.util.Arrays; //导入方法依赖的package包/类
@Override
public boolean register(String fallbackPrefix, Command command, String label) {
    if (label == null) {
        label = command.getName();
    }
    label = label.trim().toLowerCase();
    fallbackPrefix = fallbackPrefix.trim().toLowerCase();

    boolean registered = this.registerAlias(command, false, fallbackPrefix, label);

    List<String> aliases = new ArrayList<>(Arrays.asList(command.getAliases()));

    for (Iterator<String> iterator = aliases.iterator(); iterator.hasNext(); ) {
        String alias = iterator.next();
        if (!this.registerAlias(command, true, fallbackPrefix, alias)) {
            iterator.remove();
        }
    }
    command.setAliases(aliases.stream().toArray(String[]::new));

    if (!registered) {
        command.setLabel(fallbackPrefix + ":" + label);
    }

    command.register(this);

    return registered;
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:29,代码来源:SimpleCommandMap.java

示例7: getChildren

import java.util.Arrays; //导入方法依赖的package包/类
@Override
public Object[] getChildren(final Object element) {
	List<Object> children = Arrays.asList(super.getChildren(element));
	List<Object> filteredChildren = new ArrayList<Object>(children);

	for (Object child : children) {
		if ((child instanceof IFile) && (!isAccepted((IFile)child))) {
			filteredChildren.remove(child);
		}
	}

	return filteredChildren.toArray();
}
 
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:14,代码来源:FilteredFileContentProvider.java

示例8: getPersistentToken

import java.util.Arrays; //导入方法依赖的package包/类
/**
 * Validate the token and return it.
 */
private PersistentToken getPersistentToken(String[] cookieTokens) {
    if (cookieTokens.length != 2) {
        throw new InvalidCookieException("Cookie token did not contain " + 2 +
            " tokens, but contained '" + Arrays.asList(cookieTokens) + "'");
    }
    String presentedSeries = cookieTokens[0];
    String presentedToken = cookieTokens[1];
    PersistentToken token = persistentTokenRepository.findOne(presentedSeries);

    if (token == null) {
        // No series match, so we can't authenticate using this cookie
        throw new RememberMeAuthenticationException("No persistent token found for series id: " + presentedSeries);
    }

    // We have a match for this user/series combination
    log.info("presentedToken={} / tokenValue={}", presentedToken, token.getTokenValue());
    if (!presentedToken.equals(token.getTokenValue())) {
        // Token doesn't match series value. Delete this session and throw an exception.
        persistentTokenRepository.delete(token);
        throw new CookieTheftException("Invalid remember-me token (Series/token) mismatch. Implies previous " +
            "cookie theft attack.");
    }

    if (token.getTokenDate().plusDays(TOKEN_VALIDITY_DAYS).isBefore(LocalDate.now())) {
        persistentTokenRepository.delete(token);
        throw new RememberMeAuthenticationException("Remember-me login has expired");
    }
    return token;
}
 
开发者ID:quanticc,项目名称:sentry,代码行数:33,代码来源:CustomPersistentRememberMeServices.java

示例9: UnstructuredMeshGeometryInfo

import java.util.Arrays; //导入方法依赖的package包/类
/**
 * Designated constructor
 * @param coordinates array with dimensions of unstructured mesh
 * @param points     array with points of unstructured mesh
 */
public UnstructuredMeshGeometryInfo(IQuantityInfo[] coordinates, IArray points)
{
	if (coordinates.length != points.getDimensions()[1] ) {
		throw new RuntimeException(String.format("Number of coordinates %d does not agree with the dimensions of the points array %d.",coordinates.length, points.getNumberOfDimensions() ));
	}
	this.coordinates = new ArrayList<IQuantityInfo>(Arrays.asList(coordinates));
	this.points = new Array(points);
}
 
开发者ID:OpenDA-Association,项目名称:OpenDA,代码行数:14,代码来源:UnstructuredMeshGeometryInfo.java

示例10: findKth1

import java.util.Arrays; //导入方法依赖的package包/类
@Test
public void findKth1() throws Exception {
    expected = 5;
    list = Arrays.asList(3,2,1,5,4);
    k = 1;

    test(expected, list, k);
}
 
开发者ID:gardncl,项目名称:elements-of-programming-interviews-solutions,代码行数:9,代码来源:FindKthLargestTest.java

示例11: testPlay7

import java.util.Arrays; //导入方法依赖的package包/类
@Test
@Ignore
public void testPlay7() throws Exception {
    /*TinkerGraph graph = TinkerGraph.open();
    graph.createIndex("name",Vertex.class);
    graph.io(GraphMLIo.build()).readGraph("/Users/marko/software/tinkerpop/tinkerpop3/data/grateful-dead.xml");*/
    //System.out.println(g.V().properties().key().groupCount().next());
    TinkerGraph graph = TinkerFactory.createModern();
    GraphTraversalSource g = graph.traversal();
    final List<Supplier<GraphTraversal<?, ?>>> traversals = Arrays.asList(
            () -> g.V().out().as("v").match(
                    __.as("v").outE().count().as("outDegree"),
                    __.as("v").inE().count().as("inDegree")).select("v", "outDegree", "inDegree").by(valueMap()).by().by().local(union(select("v"), select("inDegree", "outDegree")).unfold().fold())
    );

    traversals.forEach(traversal -> {
        logger.info("pre-strategy:  {}", traversal.get());
        logger.info("post-strategy: {}", traversal.get().iterate());
        logger.info(TimeUtil.clockWithResult(50, () -> traversal.get().toList()).toString());
    });
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:22,代码来源:TinkerGraphPlayTest.java

示例12: toList

import java.util.Arrays; //导入方法依赖的package包/类
public List<Float> toList() {
    float[] a = toArray();
    Float ab[] = new Float[a.length];
    for(int i=0; i<a.length; i++)
        ab[i] = a[i];
    return Arrays.asList(ab);
}
 
开发者ID:wblgers,项目名称:OpenCV_Android_Plus,代码行数:8,代码来源:MatOfFloat.java

示例13: test

import java.util.Arrays; //导入方法依赖的package包/类
@Test
public void test() throws Exception {

    Method method = SharedProxyUtils.getMethodUnchecked(TheoreticalDelegate.class, "test", PrintStream.class, int.class,
            byte.class,
            String.class);
    List<Parameter> parameters = Arrays.asList(method.getParameters());

    String methodArgsClassName = MethodArgumentsGenerator.getName(TheoreticalDelegate.class, method, 0);

    // Practical to debug the generated bytecode with javap -c
    // Files.write(File.createTempFile("test", ".class").toPath(), bytecode);

    ProxyClassLoader dynamicClassLoader = new ProxyClassLoader(
            MethodArgumentsGeneratorTest.class.getClassLoader());
    dynamicClassLoader.declareClassToProxy(TheoreticalDelegate.class, new Class<?>[0], new Method[] { method },
            m -> true);
    Class<?> genClass = dynamicClassLoader.loadClass(methodArgsClassName);

    Arguments args = (Arguments) genClass
            .getConstructor(List.class, PrintStream.class, int.class, byte.class, String.class)
            .newInstance(parameters, System.out, 5, (byte) 42, "foo");

    assertThat(args.parameters()).isSameAs(parameters);

    PrintStream ps = args.objectArg("ps");
    assertThat(ps).isSameAs(System.out);

    String foo = args.objectArg("s");
    assertThat(foo).isEqualTo("foo");

    byte b = args.byteArg("b");
    assertThat(b).isEqualTo((byte) 42);

    int i = args.intArg("i");
    assertThat(i).isEqualTo(5);

    assertThatThrownBy(() -> {
        args.objectArg("unknown");
    }).isInstanceOf(IllegalArgumentException.class)
            .hasMessage("No Object parameter named unknown").hasNoCause();

    assertThatThrownBy(() -> {
        args.floatArg("radius");
    }).isInstanceOf(IllegalArgumentException.class)
            .hasMessage("No float parameter named radius").hasNoCause();

    ArgumentsUpdater updater = args.updater();
    Arguments arguments = updater.update();

    assertThat(arguments).isEqualTo(args);

    Arguments args2 = updater.setObjectArg("s", "bar").update();
    assertThat(args2.objectArg("s", String.class)).isEqualTo("bar");

    Arguments args3 = updater.setIntArg("i", 30).update();
    assertThat(args3.intArg("i")).isEqualTo(30);

}
 
开发者ID:primeval-io,项目名称:primeval-reflex,代码行数:60,代码来源:MethodArgumentsGeneratorTest.java

示例14: getElements

import java.util.Arrays; //导入方法依赖的package包/类
public List<ByteBuffer> getElements()
{
    return Arrays.asList(elements);
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:5,代码来源:Tuples.java

示例15: appendNumberSet

import java.util.Arrays; //导入方法依赖的package包/类
/**
 * Appends the given value to this list as a set of BigDecimals.
 */
public ValueList appendNumberSet(BigDecimal... val) {
    super.append(new LinkedHashSet<BigDecimal>(Arrays.asList(val)));
    return this;
}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:8,代码来源:ValueList.java


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