本文整理汇总了Java中javaslang.collection.List类的典型用法代码示例。如果您正苦于以下问题:Java List类的具体用法?Java List怎么用?Java List使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
List类属于javaslang.collection包,在下文中一共展示了List类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createAccount
import javaslang.collection.List; //导入依赖的package包/类
@Override
public Account createAccount(String name, String password) throws Exception {
List<Account> existing = accounts.filter(a -> a.getAccountName().equals(name)).toList();
if (existing.size() > 0) {
throw new Exception("account already exists");
}
Account acc = new Account();
acc.setAccountName(name);
acc.setAccountPassword(password);
acc.setAcountId(UUID.randomUUID().toString());
accounts = accounts.append(acc);
return acc;
}
开发者ID:drinkwater-io,项目名称:drinkwater-java,代码行数:17,代码来源:AccountService.java
示例2: exchangeToBean
import javaslang.collection.List; //导入依赖的package包/类
public String exchangeToBean() {
String params = "";
java.util.List<String> methodParams = new ArrayList<>();
//if has bod, first parm will be the body
if (hasBody) {
methodParams.add("${body}");
}
headerNames.forEach(name -> {
if("exchange".equals(name)){
methodParams.add("${exchange}");
}
methodParams.add("${header." + name + "}");
});
params = List.ofAll(methodParams).mkString(",");
return method.getName() + "(" + params + ")";
}
开发者ID:drinkwater-io,项目名称:drinkwater-java,代码行数:21,代码来源:MethodToRestParameters.java
示例3: mapBeanRoutes
import javaslang.collection.List; //导入依赖的package包/类
public static RoutesBuilder mapBeanRoutes(ServiceRepository serviceRepository,
Service service) {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
List<Method> methods = javaslang.collection.List.of(service.getConfiguration().getServiceClass().getDeclaredMethods());
// create an instance of the bean
Object beanToUse = service.getConfiguration().getTargetBean();
for (Method m : methods) {
if (Modifier.isPublic(m.getModifiers())) {
from("direct:" + formatBeanMethodRoute(m))
.bean(beanToUse, formatBeanEndpointRoute(m), true);
}
}
}
};
}
开发者ID:drinkwater-io,项目名称:drinkwater-java,代码行数:20,代码来源:RouteBuilders.java
示例4: mapBeanClassRoutes
import javaslang.collection.List; //导入依赖的package包/类
public static RouteBuilder mapBeanClassRoutes(DrinkWaterApplication app, Service service) {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
List<Method> methods = javaslang.collection.List.of(service.getConfiguration().getServiceClass().getDeclaredMethods());
// create an instance of the bean
Object beanToUse = BeanFactory.createBeanClass(app, service.getConfiguration(), service);
for (Method m : methods) {
if (Modifier.isPublic(m.getModifiers())) {
RouteDefinition def = from("direct:" + formatBeanMethodRoute(m));
def = addMethodInvokedStartTrace(service, def, Operation.of(m));
def.bean(beanToUse, formatBeanEndpointRoute(m), true);
addMethodInvokedEndTrace(service, def);
}
}
}
};
}
开发者ID:drinkwater-io,项目名称:drinkwater-java,代码行数:23,代码来源:RouteBuilders.java
示例5: formatBeanEndpointRoute
import javaslang.collection.List; //导入依赖的package包/类
public static String formatBeanEndpointRoute(Method m) {
String answer = m.getName();
Parameter[] params = m.getParameters();
java.util.List<String> paramList = new ArrayList<>();
if (params.length > 0) {
paramList.add("${body}");
for (int i = 1; i < params.length; i++) {
paramList.add("${header.param" + i + "}");
}
}
answer = answer + "(" + String.join(",", paramList) + ")";
return answer;
}
开发者ID:drinkwater-io,项目名称:drinkwater-java,代码行数:19,代码来源:RouteBuilders.java
示例6: validate
import javaslang.collection.List; //导入依赖的package包/类
@Nonnull
public Validation<java.util.List<String>, MooseDataCardPage1Validation> validate(
@Nonnull final MooseDataCardPage1 page, @Nonnull final MooseDataCardFilenameValidation filenameValidation) {
Objects.requireNonNull(page, "page is null");
Objects.requireNonNull(filenameValidation, "filenameValidation is null");
final Validation<List<String>, Either<String, String>> validationOfHunterNumberAndSsn =
validateHunterNumberAndSsn(page.getContactPerson());
final Validation<List<String>, Tuple3<String, String, GeoLocation>> validationOfRest =
validatePermitNumber(page, filenameValidation)
.combine(validateClubCode(page, filenameValidation))
.combine(validateClubCoordinates(page))
.combine(validateReportingPeriod(page))
.ap((permitNumber, clubCode, clubCoordinates, reportingPeriod) -> {
return Tuple.of(permitNumber, clubCode, clubCoordinates);
});
return reduce(validationOfHunterNumberAndSsn, validationOfRest, (eitherHunterNumberOrSsn, tuple3) -> {
return new MooseDataCardPage1Validation(eitherHunterNumberOrSsn, tuple3._1, tuple3._2, tuple3._3);
});
}
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:24,代码来源:MooseDataCardPage1Validator.java
示例7: PersonResource
import javaslang.collection.List; //导入依赖的package包/类
public PersonResource() {
logger.info("Initializing PersonResource");
persons = List.of(Person.newBuilder()
.id(UUID.fromString("08e3ba1f-2990-4a98-9260-59b568dbbd19"))
.firstName("Max")
.lastName("Mustermann")
.age(30)
.build(),
Person.newBuilder()
.id(UUID.fromString("118e315d-95cd-4d5f-814d-75c51c4cccdc"))
.firstName("Max2")
.lastName("Mustermann2")
.age(302)
.build()
);
}
开发者ID:fg-devs,项目名称:sample-spark,代码行数:18,代码来源:PersonResource.java
示例8: setupCompiler
import javaslang.collection.List; //导入依赖的package包/类
public static void setupCompiler(Project project, Node node) {
val componentNodes = componentNodes(node);
val compilerConfiguration = findByAttribute(componentNodes, "name", "CompilerConfiguration",
() -> node.appendNode("component", mapOf("name", "CompilerConfiguration")));
val annotationProcessing = getOrCreate(compilerConfiguration, "annotationProcessing",
() -> compilerConfiguration.appendNode("annotationProcessing"));
project.getPlugins().withId(ExtJavaPlugin.PLUGIN_ID, it -> {
val profile = createProfileNode(project, annotationProcessing);
final List<File> bootClasspath = List.ofAll(JavacUtils.getMutableBootClasspath(project));
if (!bootClasspath.isEmpty()) {
val javacSettings = findByAttribute(componentNodes, "name", "JavacSettings",
() -> node.appendNode("component", mapOf("name", "JavacSettings"))
);
javacSettings.appendNode("option",
mapOf("name", "ADDITIONAL_OPTIONS_STRING",
"value", "-Xbootclasspath/p:" +
bootClasspath.map(file -> file.getAbsolutePath()).mkString(PATH_SEPARATOR)));
}
allJavaProjects(project).forEach(prj -> profile.appendNode("module", mapOf("name", prj.getName())));
});
}
开发者ID:jdigger,项目名称:gradle-defaults,代码行数:27,代码来源:ExtIntellijPlugin.java
示例9: login
import javaslang.collection.List; //导入依赖的package包/类
@Override
public Account login(String name, String password) throws Exception {
List<Account> acclist = accounts.filter(a -> a.getAccountName().equals(name))
.filter(a -> a.getAccountPassword().equals(password)).toList();
if (acclist.size() == 0) {
throw new Exception("login failed");
}
acclist.get().setAuthenticated(true);
return acclist.get();
}
开发者ID:drinkwater-io,项目名称:drinkwater-java,代码行数:14,代码来源:AccountService.java
示例10: httpMethodFor
import javaslang.collection.List; //导入依赖的package包/类
public static HttpMethod httpMethodFor(Method method) {
HttpMethod defaultHttpMethod = HttpMethod.GET;
drinkwater.rest.HttpMethod methodAsAnnotation = method.getDeclaredAnnotation(drinkwater.rest.HttpMethod.class);
if (methodAsAnnotation != null) {
return mapToUnirestHttpMethod(methodAsAnnotation);
}
return List.ofAll(prefixesMap.entrySet())
.filter(prefix -> startsWithOneOf(method.getName(), prefix.getValue()))
.map(entryset -> entryset.getKey())
.getOrElse(defaultHttpMethod);
}
开发者ID:drinkwater-io,项目名称:drinkwater-java,代码行数:16,代码来源:RestHelper.java
示例11: buildRestRoutes
import javaslang.collection.List; //导入依赖的package包/类
public static void buildRestRoutes(RouteBuilder builder, Object bean,
IDrinkWaterService drinkWaterService) {
//check this for cors problems
//http://camel.465427.n5.nabble.com/Workaround-with-REST-DSL-to-avoid-HTTP-method-not-allowed-405-td5771508.html
try {
String serviceHost = endpointFrom(drinkWaterService);
drinkWaterService.getConfiguration().setServiceHost(serviceHost);
RestPropertyDefinition corsAllowedHeaders = new RestPropertyDefinition();
corsAllowedHeaders.setKey("Access-Control-Allow-Headers");
corsAllowedHeaders.setValue(getAllowedCorsheaders(drinkWaterService));
// builder.getContext().getDataFormats();
RestConfigurationDefinition restConfig =
builder.restConfiguration()
.component("jetty")
.enableCORS(true)
.scheme("http")
.host(host(drinkWaterService))
.port(port(drinkWaterService))
.contextPath(context(drinkWaterService, drinkWaterService.getConfiguration()))
.bindingMode(RestBindingMode.json)
.jsonDataFormat("json-drinkwater");
restConfig.setCorsHeaders(singletonList(corsAllowedHeaders));
} catch (Exception ex) {
throw new RuntimeException("could not configure the rest service correctly", ex);
}
javaslang.collection
.List.of(ReflectHelper.getPublicDeclaredMethods(bean.getClass()))
.map(method -> buildRestRoute(builder, method, drinkWaterService.getTracer()))
.map(tuple -> routeToBeanMethod(tuple._1, bean, tuple._2, drinkWaterService));
}
开发者ID:drinkwater-io,项目名称:drinkwater-java,代码行数:38,代码来源:RestHelper.java
示例12: restPath
import javaslang.collection.List; //导入依赖的package包/类
private static String restPath(Method method, HttpMethod httpMethod) {
if (httpMethod == HttpMethod.OPTIONS) {
return "";
}
String fromPath = getPathFromAnnotation(method);
if (fromPath == null || fromPath.isEmpty()) {
fromPath = List.of(prefixesMap.get(httpMethod))
.filter(prefix -> method.getName().toLowerCase().startsWith(prefix))
.map(prefix -> method.getName().replace(prefix, "").toLowerCase())
.getOrElse("");
//if still empty
if (fromPath.isEmpty()) {
fromPath = method.getName();
}
}
if (httpMethod == HttpMethod.GET) {
if (fromPath == null || fromPath.isEmpty()) {
fromPath = javaslang.collection.List.of(method.getParameters())
.map(p -> "{" + p.getName() + "}").getOrElse("");
}
}
return fromPath;
}
开发者ID:drinkwater-io,项目名称:drinkwater-java,代码行数:28,代码来源:RestHelper.java
示例13: init
import javaslang.collection.List; //导入依赖的package包/类
private void init() {
HttpMethod httpMethod = httpMethodFor(method);
List<Parameter> parameterInfos = javaslang.collection.List.of(method.getParameters());
NoBody noBodyAnnotation = method.getAnnotation(NoBody.class);
hasReturn = returnsVoid(method);
if (parameterInfos.size() == 0) {
return;
}
if (httpMethod == HttpMethod.GET) {
hasBody = false;
} else if (httpMethod == HttpMethod.POST || httpMethod == HttpMethod.DELETE || httpMethod == HttpMethod.PUT) {
if (parameterInfos.size() > 0) {
hasBody = true;
}
if (noBodyAnnotation != null) {
hasBody = false;
}
} else {
throw new RuntimeException("come back here : MethodToRestParameters.init()");
}
if (hasBody) { // first parameter of the method will be assigned with the body content
headerNames = parameterInfos.tail().map(p -> mapName(p)).toList();
} else {
headerNames = parameterInfos.map(p -> mapName(p)).toList();
}
}
开发者ID:drinkwater-io,项目名称:drinkwater-java,代码行数:33,代码来源:MethodToRestParameters.java
示例14: cleanBeforeStart
import javaslang.collection.List; //导入依赖的package包/类
private void cleanBeforeStart() {
if (serviceProxies != null) {
serviceProxies.clear();
}
serviceProxies = new HashMap<>();
services = List.empty();
dataStores = List.empty();
tracer = new TracerBean();
jvmMetricsBean = new JVMMetricsBean();
restConfiguration = new RestService();
// if (isTraceMaster) {
// eventAggregator.clear();
// }
// eventAggregator = new EventAggregator();
}
开发者ID:drinkwater-io,项目名称:drinkwater-java,代码行数:16,代码来源:DrinkWaterApplication.java
示例15: cofigureServices
import javaslang.collection.List; //导入依赖的package包/类
private void cofigureServices() {
if (applicationBuilder != null) {
// applicationBuilder.configure();
List.ofAll(applicationBuilder.getStores()).forEach(this::addStore);
List.ofAll(applicationBuilder.getConfigurations()).forEach(this::addService);
} else {
//TODO add explanation how to ad a srvice
logger.warn("no service builder initialized, add at leas one service");
}
}
开发者ID:drinkwater-io,项目名称:drinkwater-java,代码行数:14,代码来源:DrinkWaterApplication.java
示例16: startsWithOneOf
import javaslang.collection.List; //导入依赖的package包/类
public static boolean startsWithOneOf(String value, String[] prefixes) {
boolean result = List.of(prefixes)
.filter(p -> value.toLowerCase().startsWith(p))
.length() > 0;
return result;
}
开发者ID:drinkwater-io,项目名称:drinkwater-java,代码行数:8,代码来源:StringUtils.java
示例17: oneOf
import javaslang.collection.List; //导入依赖的package包/类
public static boolean oneOf(String value, java.util.List<String> values) {
boolean result = List.ofAll(values)
.filter(p -> value.equals(p))
.length() > 0;
return result;
}
开发者ID:drinkwater-io,项目名称:drinkwater-java,代码行数:8,代码来源:StringUtils.java
示例18: validateHunterNumberAndSsn
import javaslang.collection.List; //导入依赖的package包/类
@Nonnull
private static Validation<List<String>, Either<String, String>> validateHunterNumberAndSsn(
@Nonnull final MooseDataCardContactPerson contactPerson) {
return validateHunterNumber(contactPerson)
.combine(validateSsn(contactPerson))
.ap((hunterNumberOpt, ssnOpt) -> F.optionallyEither(hunterNumberOpt, () -> ssnOpt))
.flatMap(optionallyEitherHunterNumberOrSsn -> toValidation(
optionallyEitherHunterNumberOrSsn,
() -> invalid(List.of(hunterNumberAndSsnMissingForContactPerson()))));
}
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:12,代码来源:MooseDataCardPage1Validator.java
示例19: compute
import javaslang.collection.List; //导入依赖的package包/类
private int compute(final Function<CpuInfo, Integer> func) {
return Try.of(cpuInfo)
.map(List::of)
.map(List::head)
.map(func)
.getOrElse(0);
}
开发者ID:OctoPerf,项目名称:jmx-agent,代码行数:8,代码来源:SigarCpuMetrics.java
示例20: groupBy
import javaslang.collection.List; //导入依赖的package包/类
@Test
public void groupBy()
{
Map<Integer, List<Integer>> mapOfTuples = List.of(1, 2, 3, 4).groupBy(i -> i % 2);
assertThat(mapOfTuples.get(0)).isEqualTo(Option.of(List.of(2,4)));
assertThat(mapOfTuples.get(1)).isEqualTo(Option.of(List.of(1,3)));
}
开发者ID:bigkahuna1uk,项目名称:javaslang-tutorials,代码行数:9,代码来源:TuplesTest.java
注:本文中的javaslang.collection.List类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论