index int64 | repo_id string | file_path string | content string |
|---|---|---|---|
0 | java-sources/am/ik/servicebroker/cloud-karafka-service-broker/0.1.0/am/ik/servicebroker/cloudkarafka | java-sources/am/ik/servicebroker/cloud-karafka-service-broker/0.1.0/am/ik/servicebroker/cloudkarafka/servicebroker/CatalogController.java | package am.ik.servicebroker.cloudkarafka.servicebroker;
import java.io.IOException;
import java.io.InputStream;
import org.yaml.snakeyaml.Yaml;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/v2/catalog")
public class CatalogController {
private final Object catalog;
public CatalogController(
@Value("${service-broker.catalog:classpath:catalog.yml}") Resource catalog)
throws IOException {
Yaml yaml = new Yaml();
try (InputStream stream = catalog.getInputStream()) {
this.catalog = yaml.load(stream);
}
}
@GetMapping
public Object catalog() {
return this.catalog;
}
}
|
0 | java-sources/am/ik/servicebroker/cloud-karafka-service-broker/0.1.0/am/ik/servicebroker/cloudkarafka | java-sources/am/ik/servicebroker/cloud-karafka-service-broker/0.1.0/am/ik/servicebroker/cloudkarafka/servicebroker/ServiceInstanceBindingController.java | package am.ik.servicebroker.cloudkarafka.servicebroker;
import java.util.HashMap;
import java.util.Map;
import am.ik.servicebroker.cloudkarafka.cloudkarafka.CloudKarafkaClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/v2/service_instances/{instanceId}/service_bindings/{bindingId}")
public class ServiceInstanceBindingController {
private static final Logger log = LoggerFactory
.getLogger(ServiceInstanceBindingController.class);
private final CloudKarafkaClient cloudKarafkaClient;
public ServiceInstanceBindingController(CloudKarafkaClient cloudKarafkaClient) {
this.cloudKarafkaClient = cloudKarafkaClient;
}
@PutMapping
public ResponseEntity<Map<String, Object>> bind(
@PathVariable("instanceId") String instanceId,
@PathVariable("bindingId") String bindingId) {
log.info("bind instanceId={}, bindingId={}", instanceId, bindingId);
String name = "cf_" + instanceId;
Map<String, Object> body = new HashMap<>();
this.cloudKarafkaClient.findByName(name)
.ifPresent(i -> body.put("credentials", i.credential()));
return ResponseEntity.status(HttpStatus.CREATED).body(body);
}
@DeleteMapping
public ResponseEntity<Map<String, Object>> unbind(
@PathVariable("instanceId") String instanceId,
@PathVariable("bindingId") String bindingId) {
log.info("unbind instanceId={}, bindingId={}", instanceId, bindingId);
Map<String, Object> body = new HashMap<>();
return ResponseEntity.ok(body);
}
}
|
0 | java-sources/am/ik/servicebroker/cloud-karafka-service-broker/0.1.0/am/ik/servicebroker/cloudkarafka | java-sources/am/ik/servicebroker/cloud-karafka-service-broker/0.1.0/am/ik/servicebroker/cloudkarafka/servicebroker/ServiceInstanceController.java | package am.ik.servicebroker.cloudkarafka.servicebroker;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import am.ik.servicebroker.cloudkarafka.cloudkarafka.CloudKarafkaClient;
import am.ik.servicebroker.cloudkarafka.cloudkarafka.CloudKarafkaInstance;
import am.ik.servicebroker.cloudkarafka.cloudkarafka.CloudKarafkaPlan;
import am.ik.servicebroker.cloudkarafka.cloudkarafka.CloudKarafkaRegion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import static am.ik.servicebroker.cloudkarafka.cloudkarafka.CloudKarafkaPlan.DUCKY;
import static am.ik.servicebroker.cloudkarafka.cloudkarafka.CloudKarafkaRegion.GOOGLE_COMPUTE_ENGINE_US_CENTRAL1;
@RestController
@RequestMapping("/v2/service_instances/{instanceId}")
public class ServiceInstanceController {
private static final Logger log = LoggerFactory
.getLogger(ServiceInstanceController.class);
private final CloudKarafkaClient cloudKarafkaClient;
public ServiceInstanceController(CloudKarafkaClient cloudKarafkaClient) {
this.cloudKarafkaClient = cloudKarafkaClient;
}
@PutMapping
public ResponseEntity<Map<String, Object>> provisioning(
@PathVariable("instanceId") String instanceId) {
log.info("Provisioning instanceId={}", instanceId);
String name = "cf_" + instanceId;
if (this.cloudKarafkaClient.findByName(name).isPresent()) {
return ResponseEntity.status(HttpStatus.CONFLICT)
.body(Collections.emptyMap());
}
CloudKarafkaPlan plan = DUCKY;
CloudKarafkaRegion region = GOOGLE_COMPUTE_ENGINE_US_CENTRAL1;
CloudKarafkaInstance instance = this.cloudKarafkaClient.createInstance(name, plan,
region);
Map<String, Object> body = new HashMap<>();
body.put("dashboard_url", String.format(
"https://customer.cloudkarafka.com/instance/%d/sso", instance.getId()));
return ResponseEntity.status(HttpStatus.CREATED).body(body);
}
@PatchMapping
public ResponseEntity<Map<String, Object>> update(
@PathVariable("instanceId") String instanceId) {
Map<String, Object> body = new HashMap<>();
return ResponseEntity.ok(body);
}
@DeleteMapping
public ResponseEntity<?> deprovisioning(
@PathVariable("instanceId") String instanceId) {
log.info("Deprovisioning instanceId={}", instanceId);
Map<String, Object> body = new HashMap<>();
String name = "cf_" + instanceId;
return this.cloudKarafkaClient.findByName(name) //
.map(i -> {
this.cloudKarafkaClient.deleteInstance(i.getId());
return ResponseEntity.ok(body);
}) //
.orElseGet(() -> ResponseEntity.status(HttpStatus.GONE).body(body));
}
}
|
0 | java-sources/am/ik/servicebroker/shared-smysql-service-broker/0.0.5/am/ik/servicebroker | java-sources/am/ik/servicebroker/shared-smysql-service-broker/0.0.5/am/ik/servicebroker/mysql/SharedMysqlServiceBrokerApplication.java | package am.ik.servicebroker.mysql;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SharedMysqlServiceBrokerApplication {
public static void main(String[] args) {
SpringApplication.run(SharedMysqlServiceBrokerApplication.class, args);
}
}
|
0 | java-sources/am/ik/servicebroker/shared-smysql-service-broker/0.0.5/am/ik/servicebroker/mysql | java-sources/am/ik/servicebroker/shared-smysql-service-broker/0.0.5/am/ik/servicebroker/mysql/config/SecurityConfig.java | package am.ik.servicebroker.mysql.config;
import org.springframework.boot.actuate.autoconfigure.security.servlet.EndpointRequest;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.crypto.factory.PasswordEncoderFactories;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {
private final ServiceBrokerAdmin admin;
public SecurityConfig(ServiceBrokerAdmin admin) {
this.admin = admin;
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.mvcMatchers("/actuator/health").permitAll()
.requestMatchers(EndpointRequest.toAnyEndpoint()).hasRole("ADMIN")
.mvcMatchers("/v2/**").hasRole("ADMIN")
.and()
.httpBasic()
.and()
.csrf().disable()
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.NEVER);
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(new InMemoryUserDetailsManager(this.admin.asUserDetails()))
.passwordEncoder(PasswordEncoderFactories.createDelegatingPasswordEncoder());
}
}
|
0 | java-sources/am/ik/servicebroker/shared-smysql-service-broker/0.0.5/am/ik/servicebroker/mysql | java-sources/am/ik/servicebroker/shared-smysql-service-broker/0.0.5/am/ik/servicebroker/mysql/config/ServiceBrokerAdmin.java | package am.ik.servicebroker.mysql.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.crypto.password.Pbkdf2PasswordEncoder;
import org.springframework.stereotype.Component;
@ConfigurationProperties(prefix = "service-broker.admin")
@Component
public class ServiceBrokerAdmin {
private String username;
private String password;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = new Pbkdf2PasswordEncoder().encode(password);
}
public UserDetails asUserDetails() {
return User.withUsername(this.username) //
.password("{pbkdf2}" + this.password) //
.roles("ADMIN") //
.build();
}
}
|
0 | java-sources/am/ik/servicebroker/shared-smysql-service-broker/0.0.5/am/ik/servicebroker/mysql | java-sources/am/ik/servicebroker/shared-smysql-service-broker/0.0.5/am/ik/servicebroker/mysql/config/SharedMysql.java | package am.ik.servicebroker.mysql.config;
import com.zaxxer.hikari.HikariConfig;
import org.springframework.stereotype.Component;
import org.springframework.web.util.UriComponents;
import org.springframework.web.util.UriComponentsBuilder;
@Component
public class SharedMysql {
private final HikariConfig hikariConfig;
public SharedMysql(HikariConfig hikariConfig) {
this.hikariConfig = hikariConfig;
}
public Credentials credentials(String name, String username, String password) {
String uri = this.hikariConfig.getJdbcUrl().replace("jdbc:", "");
UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(uri);
UriComponents components = builder.build();
int port = components.getPort() == -1 ? 3306 : components.getPort();
Credentials credentials = new Credentials();
credentials.setHostname(components.getHost());
credentials.setPort(port);
credentials.setName(name);
credentials.setUsername(username);
credentials.setPassword(password);
credentials.setUri(builder.cloneBuilder()
.userInfo(username + ":" + password)
.port(port)
.replacePath(name)
.queryParam("reconnect", "true")
.build()
.toUriString());
credentials.setJdbcUrl("jdbc:" + builder.cloneBuilder()
.port(port)
.replacePath(name)
.queryParam("user", username)
.queryParam("password", password)
.build()
.toUriString());
return credentials;
}
public static class Credentials {
public String hostname;
public int port;
public String name;
public String username;
public String password;
public String uri;
public String jdbcUrl;
public String getHostname() {
return hostname;
}
public void setHostname(String hostname) {
this.hostname = hostname;
}
public int getPort() {
return port;
}
public void setPort(int port) {
this.port = port;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public String getJdbcUrl() {
return jdbcUrl;
}
public void setJdbcUrl(String jdbcUrl) {
this.jdbcUrl = jdbcUrl;
}
@Override
public String toString() {
return "Credentials{" +
"hostname='" + hostname + '\'' +
", port=" + port +
", name='" + name + '\'' +
", username='" + username + '\'' +
", password='" + password + '\'' +
", uri='" + uri + '\'' +
", jdbcUrl='" + jdbcUrl + '\'' +
'}';
}
}
}
|
0 | java-sources/am/ik/servicebroker/shared-smysql-service-broker/0.0.5/am/ik/servicebroker/mysql | java-sources/am/ik/servicebroker/shared-smysql-service-broker/0.0.5/am/ik/servicebroker/mysql/servicebroker/CatalogController.java | package am.ik.servicebroker.mysql.servicebroker;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.yaml.snakeyaml.Yaml;
import java.io.IOException;
import java.io.InputStream;
@RestController
@RequestMapping("/v2/catalog")
public class CatalogController {
private final Object catalog;
public CatalogController(@Value("${service-broker.catalog:classpath:catalog.yml}") Resource catalog) throws IOException {
Yaml yaml = new Yaml();
try (InputStream stream = catalog.getInputStream()) {
this.catalog = yaml.load(stream);
}
}
@GetMapping
public Object catalog() {
return this.catalog;
}
}
|
0 | java-sources/am/ik/servicebroker/shared-smysql-service-broker/0.0.5/am/ik/servicebroker/mysql | java-sources/am/ik/servicebroker/shared-smysql-service-broker/0.0.5/am/ik/servicebroker/mysql/servicebroker/ServiceInstanceBindingController.java | package am.ik.servicebroker.mysql.servicebroker;
import am.ik.servicebroker.mysql.config.SharedMysql;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@RestController
@RequestMapping("/v2/service_instances/{instanceId}/service_bindings/{bindingId}")
public class ServiceInstanceBindingController {
private static final Logger log = LoggerFactory.getLogger(ServiceInstanceBindingController.class);
private final JdbcTemplate jdbcTemplate;
private final SharedMysql sharedMysql;
public ServiceInstanceBindingController(JdbcTemplate jdbcTemplate, SharedMysql sharedMysql) {
this.jdbcTemplate = jdbcTemplate;
this.sharedMysql = sharedMysql;
}
@PutMapping
@Transactional
public ResponseEntity<Map<String, Object>> bind(@PathVariable("instanceId") String instanceId,
@PathVariable("bindingId") String bindingId) {
log.info("bind instanceId={}, bindingId={}", instanceId, bindingId);
Integer count = this.jdbcTemplate.queryForObject("SELECT COUNT(*) FROM service_instance_binding WHERE instance_id = ? AND binding_id = ?",
Integer.class, instanceId, bindingId);
Map<String, Object> body = new HashMap<>();
if (count != null && count > 0) {
return ResponseEntity.status(HttpStatus.CONFLICT).body(body);
}
String name = this.jdbcTemplate.queryForObject("SELECT db_name FROM service_instance WHERE instance_id = ?",
String.class, instanceId);
String username = UUID.randomUUID().toString().replace("-", "").substring(16);
String password = UUID.randomUUID().toString().replace("-", "");
this.jdbcTemplate.update("INSERT INTO service_instance_binding(instance_id, binding_id, username) VALUES(?, ?, ?)",
instanceId, bindingId, username);
this.jdbcTemplate.execute("CREATE USER '" + username + "' IDENTIFIED BY '" + password + "'");
this.jdbcTemplate.execute("GRANT ALL PRIVILEGES ON " + name + ".* TO '" + username + "'@'%'");
this.jdbcTemplate.execute("FLUSH PRIVILEGES");
SharedMysql.Credentials credentials = this.sharedMysql.credentials(name, username, password);
body.put("credentials", credentials);
return ResponseEntity.status(HttpStatus.CREATED).body(body);
}
@DeleteMapping
@Transactional
public ResponseEntity<Map<String, Object>> unbind(@PathVariable("instanceId") String instanceId,
@PathVariable("bindingId") String bindingId) {
log.info("unbind instanceId={}, bindingId={}", instanceId, bindingId);
Map<String, Object> body = new HashMap<>();
Integer count = this.jdbcTemplate.queryForObject("SELECT COUNT(*) FROM service_instance_binding WHERE instance_id = ? AND binding_id = ?",
Integer.class, instanceId, bindingId);
if (count != null && count == 0) {
return ResponseEntity.status(HttpStatus.GONE).body(body);
}
String username = this.jdbcTemplate.queryForObject("SELECT username FROM service_instance_binding WHERE instance_id = ? AND binding_id = ?",
String.class, instanceId, bindingId);
this.jdbcTemplate.update("DELETE FROM service_instance_binding WHERE instance_id = ? AND binding_id = ?",
instanceId, bindingId);
jdbcTemplate.execute("DROP USER '" + username + "'");
return ResponseEntity.ok(body);
}
}
|
0 | java-sources/am/ik/servicebroker/shared-smysql-service-broker/0.0.5/am/ik/servicebroker/mysql | java-sources/am/ik/servicebroker/shared-smysql-service-broker/0.0.5/am/ik/servicebroker/mysql/servicebroker/ServiceInstanceController.java | package am.ik.servicebroker.mysql.servicebroker;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@RestController
@RequestMapping("/v2/service_instances/{instanceId}")
public class ServiceInstanceController {
private static final Logger log = LoggerFactory.getLogger(ServiceInstanceController.class);
private final JdbcTemplate jdbcTemplate;
public ServiceInstanceController(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}
@PutMapping
@Transactional
public ResponseEntity<Map<String, Object>> provisioning(@PathVariable("instanceId") String instanceId) {
log.info("Provisioning instanceId={}", instanceId);
Integer count = this.jdbcTemplate.queryForObject("SELECT COUNT(*) FROM service_instance WHERE instance_id = ?",
Integer.class, instanceId);
Map<String, Object> body = new HashMap<>();
if (count != null && count > 0) {
return ResponseEntity.status(HttpStatus.CONFLICT).body(body);
}
String dbName = "cf_" + UUID.randomUUID().toString().replace("-", "");
this.jdbcTemplate.execute("CREATE DATABASE IF NOT EXISTS " + dbName);
this.jdbcTemplate.update("INSERT INTO service_instance(instance_id, db_name) VALUES(?, ?)",
instanceId, dbName);
return ResponseEntity.status(HttpStatus.CREATED).body(body);
}
@PatchMapping
public ResponseEntity<Map<String, Object>> update(@PathVariable("instanceId") String instanceId) {
Map<String, Object> body = new HashMap<>();
return ResponseEntity.ok(body);
}
@DeleteMapping
@Transactional
public ResponseEntity<Map<String, Object>> deprovisioning(@PathVariable("instanceId") String instanceId) {
log.info("Deprovisioning instanceId={}", instanceId);
Map<String, Object> body = new HashMap<>();
Integer count = this.jdbcTemplate.queryForObject("SELECT COUNT(*) FROM service_instance WHERE instance_id = ?",
Integer.class, instanceId);
if (count != null && count == 0) {
return ResponseEntity.status(HttpStatus.GONE).body(body);
}
String dbName = this.jdbcTemplate.queryForObject("SELECT db_name FROM service_instance WHERE instance_id = ?",
String.class, instanceId);
this.jdbcTemplate.update("DELETE FROM service_instance WHERE instance_id = ?", instanceId);
this.jdbcTemplate.execute("DROP DATABASE IF EXISTS " + dbName);
return ResponseEntity.ok(body);
}
}
|
0 | java-sources/am/ik/spring/ecs/logback-ecs-encoder-autoconfigure/0.1.3/am/ik/spring/ecs | java-sources/am/ik/spring/ecs/logback-ecs-encoder-autoconfigure/0.1.3/am/ik/spring/ecs/logback/EcsEncoderConfigurationListener.java | package am.ik.spring.ecs.logback;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.OutputStreamAppender;
import co.elastic.logging.logback.EcsEncoder;
import org.slf4j.ILoggerFactory;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
import org.springframework.boot.context.logging.LoggingApplicationListener;
import org.springframework.boot.context.properties.bind.Binder;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.event.GenericApplicationListener;
import org.springframework.core.ResolvableType;
import org.springframework.util.ClassUtils;
public class EcsEncoderConfigurationListener implements GenericApplicationListener {
@Override
public boolean supportsEventType(ResolvableType eventType) {
if (eventType.getRawClass() == null) {
return false;
}
return ApplicationEnvironmentPreparedEvent.class.isAssignableFrom(eventType.getRawClass());
}
@Override
public boolean supportsSourceType(Class<?> sourceType) {
return SpringApplication.class.isAssignableFrom(sourceType)
|| ApplicationContext.class.isAssignableFrom(sourceType);
}
@Override
public void onApplicationEvent(ApplicationEvent event) {
if (!ClassUtils.isPresent("ch.qos.logback.classic.LoggerContext", null)
|| !ClassUtils.isPresent("co.elastic.logging.logback.EcsEncoder", null)) {
return;
}
if (event instanceof ApplicationEnvironmentPreparedEvent applicationEnvironmentPreparedEvent) {
ILoggerFactory loggerFactorySpi = LoggerFactory.getILoggerFactory();
if (!(loggerFactorySpi instanceof LoggerContext loggerContext)) {
return;
}
Binder binder = Binder.get(applicationEnvironmentPreparedEvent.getEnvironment());
boolean enabled = binder.bind("logging.logback.ecs-encoder.enabled", Boolean.class).orElse(true);
if (!enabled) {
return;
}
EcsEncoder ecsEncoder = new EcsEncoder();
this.configureEcsEncoder(ecsEncoder, binder);
loggerContext.getLoggerList().forEach(logger -> logger.iteratorForAppenders().forEachRemaining(appender -> {
if (appender instanceof OutputStreamAppender<ILoggingEvent>) {
((OutputStreamAppender<ILoggingEvent>) appender).setEncoder(ecsEncoder);
}
}));
}
}
void configureEcsEncoder(EcsEncoder ecsEncoder, Binder binder) {
binder.bind("spring.application.name", String.class).ifBound(ecsEncoder::setServiceName);
}
@Override
public int getOrder() {
// After org.springframework.boot.context.logging.LoggingApplicationListener
return LoggingApplicationListener.DEFAULT_ORDER + 2;
}
}
|
0 | java-sources/am/ik/spring/logbook/access-logger-logbook/0.3.2/am/ik/spring | java-sources/am/ik/spring/logbook/access-logger-logbook/0.3.2/am/ik/spring/logbook/AccessLoggerLogbookAutoConfiguration.java | package am.ik.spring.logbook;
import org.springframework.aot.hint.MemberCategory;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar;
import org.springframework.aot.hint.TypeReference;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ImportRuntimeHints;
import org.springframework.util.ClassUtils;
import org.zalando.logbook.Logbook;
import org.zalando.logbook.autoconfigure.LogbookAutoConfiguration;
@AutoConfiguration
@ConditionalOnClass(Logbook.class)
@AutoConfigureBefore(LogbookAutoConfiguration.class)
@ConditionalOnProperty(name = "access-logger.logbook.enabled", havingValue = "true", matchIfMissing = true)
@ImportRuntimeHints(AccessLoggerLogbookAutoConfiguration.AccessLoggerHints.class)
public class AccessLoggerLogbookAutoConfiguration {
public static final String JAKARTA_SERVLET_HTTP_HTTP_SERVLET_REQUEST = "jakarta.servlet.http.HttpServletRequest";
@Bean
@ConditionalOnMissingClass(JAKARTA_SERVLET_HTTP_HTTP_SERVLET_REQUEST)
public AccessLoggerSink accessLoggerSink() {
return new AccessLoggerSink();
}
@Bean
@ConditionalOnClass(name = JAKARTA_SERVLET_HTTP_HTTP_SERVLET_REQUEST)
public ServletAwareAccessLoggerSink servletAwareAccessLoggerSink() {
return new ServletAwareAccessLoggerSink();
}
@Bean
public AccessLoggerRequestCondition requestCondition() {
return new AccessLoggerRequestCondition();
}
static class AccessLoggerHints implements RuntimeHintsRegistrar {
@Override
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
if (ClassUtils.isPresent(JAKARTA_SERVLET_HTTP_HTTP_SERVLET_REQUEST, classLoader)) {
hints.reflection()
.registerType(TypeReference.of(JAKARTA_SERVLET_HTTP_HTTP_SERVLET_REQUEST),
builder -> builder.withMembers(MemberCategory.INVOKE_PUBLIC_METHODS));
}
}
}
}
|
0 | java-sources/am/ik/spring/logbook/access-logger-logbook/0.3.2/am/ik/spring | java-sources/am/ik/spring/logbook/access-logger-logbook/0.3.2/am/ik/spring/logbook/AccessLoggerRequestCondition.java | package am.ik.spring.logbook;
import java.util.function.Predicate;
import org.zalando.logbook.HttpHeaders;
import org.zalando.logbook.HttpRequest;
public class AccessLoggerRequestCondition implements Predicate<HttpRequest> {
@Override
public boolean test(HttpRequest request) {
String path = request.getPath();
if (path.equals("/readyz")) {
return false;
}
if (path.equals("/livez")) {
return false;
}
if (path.startsWith("/actuator")) {
return false;
}
if (path.startsWith("/cloudfoundryapplication")) {
return false;
}
HttpHeaders headers = request.getHeaders();
String userAgent = headers.getFirst("User-Agent");
if (userAgent != null) {
userAgent = headers.getFirst("user-agent");
}
return userAgent == null || !userAgent.contains("Amazon-Route53-Health-Check-Service");
}
}
|
0 | java-sources/am/ik/spring/logbook/access-logger-logbook/0.3.2/am/ik/spring | java-sources/am/ik/spring/logbook/access-logger-logbook/0.3.2/am/ik/spring/logbook/AccessLoggerSink.java | package am.ik.spring.logbook;
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.spi.LoggingEventBuilder;
import org.springframework.util.StringUtils;
import org.zalando.logbook.Correlation;
import org.zalando.logbook.HttpHeaders;
import org.zalando.logbook.HttpRequest;
import org.zalando.logbook.HttpResponse;
import org.zalando.logbook.Origin;
import org.zalando.logbook.Precorrelation;
import org.zalando.logbook.Sink;
public class AccessLoggerSink implements Sink {
private static final Logger log = LoggerFactory.getLogger("accesslog");
@Override
public boolean isActive() {
return log.isInfoEnabled();
}
@Override
public void write(Precorrelation precorrelation, HttpRequest request) throws IOException {
// NO-OP
}
@Override
public void write(Correlation correlation, HttpRequest request, HttpResponse response) throws IOException {
Origin origin = request.getOrigin();
String kind = switch (origin) {
case LOCAL -> "client";
case REMOTE -> "server";
};
String method = request.getMethod();
String url = request.getRequestUri();
String remote = request.getRemote();
int status = response.getStatus();
long duration = correlation.getDuration().toMillis();
StringBuilder messageBuilder = new StringBuilder().append("kind=")
.append(kind)
.append(" method=")
.append(method)
.append(" url=\"")
.append(url)
.append("\"")
.append(" status=")
.append(status)
.append(" duration=")
.append(duration);
LoggingEventBuilder loggingEventBuilder = log.atInfo()
.addKeyValue("kind", kind)
.addKeyValue("method", method)
.addKeyValue("url", url)
.addKeyValue("status", status)
.addKeyValue("duration", duration)
.addKeyValue("host", request.getHost())
.addKeyValue("path", request.getPath());
if (origin == Origin.REMOTE) {
messageBuilder.append(" protocol=\"")
.append(request.getProtocolVersion())
.append("\"") //
.append(" remote=\"")
.append(remote)
.append("\""); //
loggingEventBuilder = loggingEventBuilder.addKeyValue("remote", remote)
.addKeyValue("protocol", request.getProtocolVersion());
}
String username = getUsername(request);
if (username != null) {
messageBuilder.append(" username=\"").append(username).append("\"");
loggingEventBuilder = loggingEventBuilder.addKeyValue("username", username);
}
HttpHeaders headers = request.getHeaders();
String userAgent = headers.getFirst("User-Agent");
if (StringUtils.hasLength(userAgent)) {
messageBuilder.append(" user_agent=\"").append(userAgent).append("\"");
loggingEventBuilder = loggingEventBuilder.addKeyValue("user_agent", userAgent);
}
String referer = headers.getFirst("Referer");
if (StringUtils.hasLength(referer)) {
messageBuilder.append(" referer=\"").append(referer).append("\"");
loggingEventBuilder = loggingEventBuilder.addKeyValue("referer", referer);
}
String requestBody = request.getBodyAsString();
if (StringUtils.hasLength(requestBody)) {
messageBuilder.append(" request_body=\"").append(escape(requestBody)).append("\"");
}
String responseBody = response.getBodyAsString();
if (StringUtils.hasLength(responseBody)) {
messageBuilder.append(" response_body=\"").append(escape(responseBody)).append("\"");
}
loggingEventBuilder.log(messageBuilder.toString());
}
protected String getUsername(HttpRequest request) {
return null;
}
private static String escape(String input) {
if (input == null) {
return "";
}
StringBuilder escapedString = new StringBuilder();
for (char c : input.toCharArray()) {
switch (c) {
case '"':
escapedString.append("\\\"");
break;
case '\\':
escapedString.append("\\\\");
break;
case '\b':
escapedString.append("\\b");
break;
case '\f':
escapedString.append("\\f");
break;
case '\n':
escapedString.append("\\n");
break;
case '\r':
escapedString.append("\\r");
break;
case '\t':
escapedString.append("\\t");
break;
default:
if (c <= 0x1F) {
escapedString.append(String.format("\\u%04x", (int) c));
}
else {
escapedString.append(c);
}
break;
}
}
return escapedString.toString();
}
} |
0 | java-sources/am/ik/spring/logbook/access-logger-logbook/0.3.2/am/ik/spring | java-sources/am/ik/spring/logbook/access-logger-logbook/0.3.2/am/ik/spring/logbook/OpinionatedFilters.java | package am.ik.spring.logbook;
import java.util.Locale;
import java.util.Set;
import java.util.TreeSet;
import org.zalando.logbook.HeaderFilter;
import org.zalando.logbook.core.HeaderFilters;
public class OpinionatedFilters {
public static HeaderFilter headerFilter() {
Set<String> replaceHeaders = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
replaceHeaders
.addAll(Set.of("authorization", "proxy-authenticate", "cookie", "set-cookie", "x-amz-security-token"));
Set<String> removeHeaders = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
removeHeaders.addAll(Set.of("http2-settings", "connection", "access-control-expose-headers",
"content-security-policy", "referrer-policy", "access-control-allow-origin",
"strict-transport-security", "access-control-allow-credentials", ":status", "date", "vary", "alt-svc"));
return HeaderFilter.merge(HeaderFilters.replaceHeaders(replaceHeaders, "***"), HeaderFilter
.merge(HeaderFilters.removeHeaders(removeHeaders::contains), HeaderFilters.removeHeaders(s -> {
String headerName = s.toLowerCase(Locale.US);
return (headerName.startsWith("x-") && !s.startsWith("x-forwarded")) || headerName.startsWith("sec-")
|| headerName.startsWith("accept") || headerName.startsWith("upgrade")
|| headerName.startsWith("cf-") || headerName.startsWith("openai-");
})));
}
}
|
0 | java-sources/am/ik/spring/logbook/access-logger-logbook/0.3.2/am/ik/spring | java-sources/am/ik/spring/logbook/access-logger-logbook/0.3.2/am/ik/spring/logbook/ServletAwareAccessLoggerSink.java | package am.ik.spring.logbook;
import jakarta.servlet.http.HttpServletRequest;
import org.zalando.logbook.ForwardingHttpRequest;
import org.zalando.logbook.HttpRequest;
public class ServletAwareAccessLoggerSink extends AccessLoggerSink {
@Override
protected String getUsername(HttpRequest request) {
if (request instanceof HttpServletRequest httpServletRequest) {
return httpServletRequest.getRemoteUser();
}
else if (request instanceof ForwardingHttpRequest forwardingHttpRequest) {
return getUsername(forwardingHttpRequest.delegate());
}
return null;
}
}
|
0 | java-sources/am/ik/spring/opentelemetry/otel-logs-autoconfigure/0.4.0/am/ik/spring/opentelemetry/logs | java-sources/am/ik/spring/opentelemetry/otel-logs-autoconfigure/0.4.0/am/ik/spring/opentelemetry/logs/logback/LogbackAppenderInstallListener.java | /*
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.spring.opentelemetry.logs.logback;
import ch.qos.logback.classic.Logger;
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.instrumentation.logback.appender.v1_0.OpenTelemetryAppender;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
import org.springframework.boot.context.event.ApplicationFailedEvent;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.boot.context.logging.LoggingApplicationListener;
import org.springframework.boot.context.properties.bind.Binder;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.event.GenericApplicationListener;
import org.springframework.core.ResolvableType;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.util.ClassUtils;
public class LogbackAppenderInstallListener implements GenericApplicationListener {
@Override
public boolean supportsEventType(ResolvableType eventType) {
if (eventType.getRawClass() == null) {
return false;
}
return ApplicationEnvironmentPreparedEvent.class.isAssignableFrom(eventType.getRawClass())
|| ApplicationReadyEvent.class.isAssignableFrom(eventType.getRawClass());
}
@Override
public boolean supportsSourceType(Class<?> sourceType) {
return SpringApplication.class.isAssignableFrom(sourceType)
|| ApplicationContext.class.isAssignableFrom(sourceType);
}
@Override
public void onApplicationEvent(ApplicationEvent event) {
if (!ClassUtils.isPresent("ch.qos.logback.classic.LoggerContext", null)
|| !ClassUtils.isPresent("io.opentelemetry.api.OpenTelemetry", null) || !ClassUtils
.isPresent("io.opentelemetry.instrumentation.logback.appender.v1_0.OpenTelemetryAppender", null)) {
return;
}
if (event instanceof ApplicationEnvironmentPreparedEvent) {
Logger rootLogger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
OpenTelemetryAppender openTelemetryAppender = new OpenTelemetryAppender();
ConfigurableEnvironment environment = ((ApplicationEnvironmentPreparedEvent) event).getEnvironment();
Binder binder = Binder.get(environment);
boolean enabled = binder
.bind("management.opentelemetry.instrumentation.logback-appender.enabled", Boolean.class)
.orElse(true);
if (!enabled) {
return;
}
this.configureOpenTelemetryAppender(openTelemetryAppender, binder);
openTelemetryAppender.start();
rootLogger.addAppender(openTelemetryAppender);
}
else if (event instanceof ApplicationReadyEvent applicationReadyEvent) {
ConfigurableApplicationContext applicationContext = applicationReadyEvent.getApplicationContext();
ObjectProvider<OpenTelemetry> openTelemetry = applicationContext.getBeanProvider(OpenTelemetry.class);
openTelemetry.ifAvailable(OpenTelemetryAppender::install);
}
else if (event instanceof ApplicationFailedEvent applicationFailedEvent) {
ConfigurableApplicationContext applicationContext = applicationFailedEvent.getApplicationContext();
ObjectProvider<OpenTelemetry> openTelemetry = applicationContext.getBeanProvider(OpenTelemetry.class);
openTelemetry.ifAvailable(OpenTelemetryAppender::install);
}
}
void configureOpenTelemetryAppender(OpenTelemetryAppender openTelemetryAppender, Binder binder) {
boolean captureExperimentalAttributes = binder
.bind("management.opentelemetry.instrumentation.logback-appender.capture-experimental-attributes",
Boolean.class)
.orElse(false);
boolean captureCodeAttributes = binder
.bind("management.opentelemetry.instrumentation.logback-appender.capture-code-attributes", Boolean.class)
.orElse(false);
boolean captureMarkerAttribute = binder
.bind("management.opentelemetry.instrumentation.logback-appender.capture-marker-attribute", Boolean.class)
.orElse(false);
boolean captureKeyValuePairAttributes = binder
.bind("management.opentelemetry.instrumentation.logback-appender.capture-key-value-pair-attributes",
Boolean.class)
.orElse(false);
boolean captureLoggerContext = binder
.bind("management.opentelemetry.instrumentation.logback-appender.capture-logger-context", Boolean.class)
.orElse(false);
String captureMdcAttributes = binder
.bind("management.opentelemetry.instrumentation.logback-appender.capture-mdc-attributes", String.class)
.orElse(null);
int numLogsCapturedBeforeOtelInstall = binder
.bind("management.opentelemetry.instrumentation.logback-appender.num-logs-captured-before-otel-install",
Integer.class)
.orElse(1000);
openTelemetryAppender.setCaptureExperimentalAttributes(captureExperimentalAttributes);
openTelemetryAppender.setCaptureCodeAttributes(captureCodeAttributes);
openTelemetryAppender.setCaptureMarkerAttribute(captureMarkerAttribute);
openTelemetryAppender.setCaptureKeyValuePairAttributes(captureKeyValuePairAttributes);
openTelemetryAppender.setCaptureLoggerContext(captureLoggerContext);
openTelemetryAppender.setCaptureMdcAttributes(captureMdcAttributes);
openTelemetryAppender.setNumLogsCapturedBeforeOtelInstall(numLogsCapturedBeforeOtelInstall);
}
@Override
public int getOrder() {
// After org.springframework.boot.context.logging.LoggingApplicationListener
return LoggingApplicationListener.DEFAULT_ORDER + 1;
}
}
|
0 | java-sources/am/ik/spring/retryable-client-http-request-interceptor/0.7.0/am/ik/spring/http | java-sources/am/ik/spring/retryable-client-http-request-interceptor/0.7.0/am/ik/spring/http/client/LoadBalanceStrategy.java | /*
* Copyright (C) 2023-2024 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.spring.http.client;
import org.springframework.http.HttpRequest;
/**
* LoadBalance Strategy
*
* @since 0.3.0
*/
@FunctionalInterface
public interface LoadBalanceStrategy {
HttpRequest choose(HttpRequest request);
LoadBalanceStrategy NOOP = request -> request;
}
|
0 | java-sources/am/ik/spring/retryable-client-http-request-interceptor/0.7.0/am/ik/spring/http | java-sources/am/ik/spring/retryable-client-http-request-interceptor/0.7.0/am/ik/spring/http/client/RetryLifecycle.java | /*
* Copyright (C) 2023-2024 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.spring.http.client;
import org.springframework.http.HttpRequest;
import org.springframework.http.client.ClientHttpResponse;
/**
* Retry LifeCycle
*
* @since 0.3.0
*/
public interface RetryLifecycle {
default void onSuccess(HttpRequest request, ClientHttpResponse response) {
}
default void onRetry(HttpRequest request, ResponseOrException responseOrException) {
}
default void onNoLongerRetryable(HttpRequest request, ResponseOrException responseOrException) {
}
default void onFailure(HttpRequest request, ResponseOrException responseOrException) {
}
RetryLifecycle NOOP = new RetryLifecycle() {
};
class ResponseOrException {
private final ClientHttpResponse response;
private final Exception exception;
public static ResponseOrException ofResponse(ClientHttpResponse response) {
return new ResponseOrException(response, null);
}
public static ResponseOrException ofException(Exception e) {
return new ResponseOrException(null, e);
}
private ResponseOrException(ClientHttpResponse response, Exception exception) {
this.response = response;
this.exception = exception;
}
public ClientHttpResponse response() {
return this.response;
}
public Exception exception() {
return this.exception;
}
public boolean hasResponse() {
return this.response != null;
}
public boolean hasException() {
return this.exception != null;
}
@Override
public String toString() {
if (this.response != null) {
return this.response.toString();
}
else if (this.exception != null) {
return this.exception.toString();
}
return "null";
}
}
}
|
0 | java-sources/am/ik/spring/retryable-client-http-request-interceptor/0.7.0/am/ik/spring/http | java-sources/am/ik/spring/retryable-client-http-request-interceptor/0.7.0/am/ik/spring/http/client/RetryableClientHttpRequestInterceptor.java | /*
* Copyright (C) 2023-2024 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.spring.http.client;
import am.ik.spring.http.client.RetryLifecycle.ResponseOrException;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpRequest;
import org.springframework.http.client.ClientHttpRequestExecution;
import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.util.backoff.BackOff;
import org.springframework.util.backoff.BackOffExecution;
public class RetryableClientHttpRequestInterceptor implements ClientHttpRequestInterceptor {
private final BackOff backOff;
private final Set<Integer> retryableResponseStatuses;
private final Predicate<IOException> retryableIOExceptionPredicate;
private final RetryableHttpResponsePredicate retryableHttpResponsePredicate;
private final LoadBalanceStrategy loadBalanceStrategy;
private final RetryLifecycle retryLifecycle;
private final Predicate<String> sensitiveHeaderPredicate;
public static Set<Integer> DEFAULT_RETRYABLE_RESPONSE_STATUSES = Collections
.unmodifiableSet(new HashSet<>(Arrays.asList( //
408 /* Request Timeout */, //
425 /* Too Early */, //
429 /* Too Many Requests */, //
500 /* Internal Server Error */, //
502 /* Bad Gateway */, //
503 /* Service Unavailable */, //
504 /* Gateway Timeout */
)));
private static final int MAX_ATTEMPTS = 100;
private final Log log = LogFactory.getLog(RetryableClientHttpRequestInterceptor.class);
public static class Options {
private final Set<Predicate<IOException>> retryableIOExceptionPredicates = new LinkedHashSet<Predicate<IOException>>(
RetryableIOExceptionPredicate.defaults());
private RetryableHttpResponsePredicate retryableHttpResponsePredicate = null;
private LoadBalanceStrategy loadBalanceStrategy = LoadBalanceStrategy.NOOP;
private RetryLifecycle retryLifecycle = RetryLifecycle.NOOP;
public static final Set<String> DEFAULT_SENSITIVE_HEADERS = Collections.unmodifiableSet(new HashSet<>(
Arrays.asList("authorization", "proxy-authenticate", "cookie", "set-cookie", "x-amz-security-token")));
private Set<String> sensitiveHeaders = DEFAULT_SENSITIVE_HEADERS;
private Predicate<String> sensitiveHeaderPredicate = null;
/**
* Consider using
* {@code addRetryableIOException(RetryableIOExceptionPredicate.CLIENT_TIMEOUT)}
* or
* {@code removeRetryableIOException(RetryableIOExceptionPredicate.CLIENT_TIMEOUT)}
*/
@Deprecated
public Options retryClientTimeout(boolean retryClientTimeout) {
if (retryClientTimeout) {
return this.addRetryableIOException(RetryableIOExceptionPredicate.CLIENT_TIMEOUT);
}
else {
return this.removeRetryableIOException(RetryableIOExceptionPredicate.CLIENT_TIMEOUT);
}
}
/**
* Consider using
* {@code addRetryableIOException(RetryableIOExceptionPredicate.CONNECT_TIMEOUT)}
* or
* {@code removeRetryableIOException(RetryableIOExceptionPredicate.CONNECT_TIMEOUT)}
*/
@Deprecated
public Options retryConnectException(boolean retryConnectException) {
if (retryConnectException) {
return this.addRetryableIOException(RetryableIOExceptionPredicate.CONNECT_TIMEOUT);
}
else {
return this.removeRetryableIOException(RetryableIOExceptionPredicate.CONNECT_TIMEOUT);
}
}
/**
* Consider using
* {@code addRetryableIOException(RetryableIOExceptionPredicate.UNKNOWN_HOST)} or
* {@code removeRetryableIOException(RetryableIOExceptionPredicate.UNKNOWN_HOST)}
*/
@Deprecated
public Options retryUnknownHostException(boolean retryUnknownHostException) {
if (retryUnknownHostException) {
return this.addRetryableIOException(RetryableIOExceptionPredicate.UNKNOWN_HOST);
}
else {
return this.removeRetryableIOException(RetryableIOExceptionPredicate.UNKNOWN_HOST);
}
}
public Options addRetryableIOException(Predicate<IOException> retryableIOExceptionPredicate) {
this.retryableIOExceptionPredicates.add(retryableIOExceptionPredicate);
return this;
}
public Options addRetryableIOExceptions(
Collection<? extends Predicate<IOException>> retryableIOExceptionPredicates) {
this.retryableIOExceptionPredicates.addAll(retryableIOExceptionPredicates);
return this;
}
public Options addRetryableIOExceptions(Predicate<IOException>... retryableIOExceptionPredicates) {
this.addRetryableIOExceptions(Arrays.asList(retryableIOExceptionPredicates));
return this;
}
public Options removeRetryableIOException(Predicate<IOException> retryableIOExceptionPredicate) {
this.retryableIOExceptionPredicates.remove(retryableIOExceptionPredicate);
return this;
}
public Options removeRetryableIOExceptions(
Collection<? extends Predicate<IOException>> retryableIOExceptionPredicate) {
this.retryableIOExceptionPredicates.removeAll(retryableIOExceptionPredicate);
return this;
}
public Options removeRetryableIOExceptions(Predicate<IOException>... retryableIOExceptionPredicate) {
this.removeRetryableIOExceptions(Arrays.asList(retryableIOExceptionPredicate));
return this;
}
/**
* Set a custom <code>RetryableHttpResponsePredicate</code>. If this is set,
* {@link RetryableClientHttpRequestInterceptor#retryableResponseStatuses} is no
* longer respected.
*/
public Options retryableHttpResponsePredicate(RetryableHttpResponsePredicate retryableHttpResponsePredicate) {
this.retryableHttpResponsePredicate = retryableHttpResponsePredicate;
return this;
}
public Options loadBalanceStrategy(LoadBalanceStrategy loadBalanceStrategy) {
this.loadBalanceStrategy = loadBalanceStrategy;
if (loadBalanceStrategy instanceof RetryLifecycle) {
return this.retryLifecycle((RetryLifecycle) loadBalanceStrategy);
}
return this;
}
public Options retryLifecycle(RetryLifecycle retryLifecycle) {
this.retryLifecycle = retryLifecycle;
return this;
}
public Options sensitiveHeaders(Set<String> sensitiveHeaders) {
this.sensitiveHeaders = sensitiveHeaders;
return this;
}
public Options sensitiveHeaderPredicate(Predicate<String> sensitiveHeaderPredicate) {
this.sensitiveHeaderPredicate = sensitiveHeaderPredicate;
return this;
}
}
public RetryableClientHttpRequestInterceptor(BackOff backOff) {
this(backOff, DEFAULT_RETRYABLE_RESPONSE_STATUSES, __ -> {
});
}
public RetryableClientHttpRequestInterceptor(BackOff backOff, Set<Integer> retryableResponseStatuses) {
this(backOff, retryableResponseStatuses, __ -> {
});
}
public RetryableClientHttpRequestInterceptor(BackOff backOff, Consumer<Options> configurer) {
this(backOff, DEFAULT_RETRYABLE_RESPONSE_STATUSES, configurer);
}
public RetryableClientHttpRequestInterceptor(BackOff backOff, Set<Integer> retryableResponseStatuses,
Consumer<Options> configurer) {
Options options = new Options();
configurer.accept(options);
this.backOff = backOff;
this.retryableResponseStatuses = retryableResponseStatuses;
this.retryableIOExceptionPredicate = options.retryableIOExceptionPredicates.stream()
.reduce(e -> false, Predicate::or);
this.retryableHttpResponsePredicate = options.retryableHttpResponsePredicate == null
? new DefaultRetryableHttpResponsePredicate() : options.retryableHttpResponsePredicate;
this.loadBalanceStrategy = options.loadBalanceStrategy;
this.retryLifecycle = options.retryLifecycle;
this.sensitiveHeaderPredicate = options.sensitiveHeaderPredicate == null ? options.sensitiveHeaders::contains
: options.sensitiveHeaderPredicate;
}
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)
throws IOException {
final BackOffExecution backOffExecution = this.backOff.start();
for (int i = 1; i <= MAX_ATTEMPTS; i++) {
final long backOff = backOffExecution.nextBackOff();
final HttpRequest httpRequest = this.loadBalanceStrategy.choose(request);
try {
final long begin = System.currentTimeMillis();
if (log.isDebugEnabled()) {
StringBuilder message = new StringBuilder("type=req attempts=").append(i)
.append(" method=")
.append(httpRequest.getMethod())
.append(" url=\"")
.append(httpRequest.getURI())
.append("\" ");
maskHeaders(httpRequest.getHeaders())
.forEach((k, v) -> message.append(k.toLowerCase(Locale.US).replace("-", "_"))
.append("=\"")
.append(v.stream()
.map(RetryableClientHttpRequestInterceptor::escape)
.collect(Collectors.joining(",")))
.append("\" "));
log.debug(message.toString().trim());
}
ClientHttpResponse response = execution.execute(httpRequest, body);
if (log.isDebugEnabled()) {
long duration = System.currentTimeMillis() - begin;
StringBuilder message = new StringBuilder("type=res attempts=").append(i)
.append(" method=")
.append(httpRequest.getMethod())
.append(" url=\"")
.append(httpRequest.getURI())
.append("\" response_code=")
.append(response.getStatusCode().value())
.append(" duration=")
.append(duration)
.append(" ");
maskHeaders(response.getHeaders())
.forEach((k, v) -> message.append(k.toLowerCase(Locale.US).replace("-", "_"))
.append("=\"")
.append(v.stream()
.map(RetryableClientHttpRequestInterceptor::escape)
.collect(Collectors.joining(",")))
.append("\" "));
log.debug(message.toString().trim());
}
if (!this.retryableHttpResponsePredicate.isRetryableHttpResponse(response)) {
if (response.getStatusCode().isError()) {
this.retryLifecycle.onFailure(httpRequest, ResponseOrException.ofResponse(response));
}
else {
this.retryLifecycle.onSuccess(httpRequest, response);
}
return response;
}
if (backOff == BackOffExecution.STOP) {
if (log.isWarnEnabled()) {
log.warn(String.format(
"type=fin attempts=%d method=%s url=\"%s\" reason=\"No longer retryable\"", i,
httpRequest.getMethod(), httpRequest.getURI()));
}
this.retryLifecycle.onNoLongerRetryable(httpRequest, ResponseOrException.ofResponse(response));
return response;
}
this.retryLifecycle.onRetry(httpRequest, ResponseOrException.ofResponse(response));
}
catch (IOException e) {
if (!isRetryableIOException(e)) {
this.retryLifecycle.onFailure(httpRequest, ResponseOrException.ofException(e));
throw e;
}
else if (backOff == BackOffExecution.STOP) {
if (log.isWarnEnabled()) {
log.warn(String.format(
"type=fin attempts=%d method=%s url=\"%s\" reason=\"No longer retryable\"", i,
httpRequest.getMethod(), httpRequest.getURI()), e);
}
this.retryLifecycle.onNoLongerRetryable(httpRequest, ResponseOrException.ofException(e));
throw e;
}
else {
this.retryLifecycle.onRetry(httpRequest, ResponseOrException.ofException(e));
if (log.isInfoEnabled()) {
log.info(String.format(
"type=exp attempts=%d method=%s url=\"%s\" exception_class=\"%s\" exception_message=\"%s\"",
i, httpRequest.getMethod(), httpRequest.getURI(), e.getClass().getName(),
e.getMessage()));
}
}
}
if (log.isInfoEnabled()) {
log.info(String.format("type=wtg attempts=%d method=%s url=\"%s\" backoff=\"%s\"", i,
httpRequest.getMethod(), httpRequest.getURI(), backOffExecution));
}
try {
Thread.sleep(backOff);
}
catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}
}
throw new IllegalStateException("Maximum number of attempts reached!");
}
private boolean isRetryableIOException(IOException e) {
return this.retryableIOExceptionPredicate.test(e);
}
private class DefaultRetryableHttpResponsePredicate implements RetryableHttpResponsePredicate {
@Override
public boolean isRetryableHttpResponse(ClientHttpResponse response) throws IOException {
// to work with both Spring 5 (HttpStatus) and 6 (HttpStatusCode)
return isRetryableHttpStatus(response.getStatusCode().isError(), response.getStatusCode().value());
}
}
private boolean isRetryableHttpStatus(boolean isErrorStatus, int statusCode) throws IOException {
return isErrorStatus && this.retryableResponseStatuses.contains(statusCode);
}
private Map<String, List<String>> maskHeaders(HttpHeaders headers) {
return headers.entrySet().stream().map(entry -> {
if (sensitiveHeaderPredicate.test(entry.getKey().toLowerCase())) {
return new Map.Entry<String, List<String>>() {
@Override
public String getKey() {
return entry.getKey();
}
@Override
public List<String> getValue() {
return entry.getValue().stream().map(s -> "(masked)").collect(Collectors.toList());
}
@Override
public List<String> setValue(List<String> value) {
return value;
}
};
}
else {
return entry;
}
}).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
}
private static String escape(String input) {
if (input == null) {
return null;
}
StringBuilder escapedString = new StringBuilder();
for (char c : input.toCharArray()) {
switch (c) {
case '"':
escapedString.append("\\\"");
break;
case '\\':
escapedString.append("\\\\");
break;
case '\b':
escapedString.append("\\b");
break;
case '\f':
escapedString.append("\\f");
break;
case '\n':
escapedString.append("\\n");
break;
case '\r':
escapedString.append("\\r");
break;
case '\t':
escapedString.append("\\t");
break;
default:
if (c <= 0x1F) {
escapedString.append(String.format("\\u%04x", (int) c));
}
else {
escapedString.append(c);
}
break;
}
}
return escapedString.toString();
}
}
|
0 | java-sources/am/ik/spring/retryable-client-http-request-interceptor/0.7.0/am/ik/spring/http | java-sources/am/ik/spring/retryable-client-http-request-interceptor/0.7.0/am/ik/spring/http/client/RetryableHttpResponsePredicate.java | /*
* Copyright (C) 2023-2024 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.spring.http.client;
import java.io.IOException;
import org.springframework.http.client.ClientHttpResponse;
@FunctionalInterface
public interface RetryableHttpResponsePredicate {
boolean isRetryableHttpResponse(ClientHttpResponse response) throws IOException;
}
|
0 | java-sources/am/ik/spring/retryable-client-http-request-interceptor/0.7.0/am/ik/spring/http | java-sources/am/ik/spring/retryable-client-http-request-interceptor/0.7.0/am/ik/spring/http/client/RetryableIOExceptionPredicate.java | package am.ik.spring.http.client;
import java.io.IOException;
import java.net.ConnectException;
import java.net.SocketTimeoutException;
import java.net.URLConnection;
import java.net.UnknownHostException;
import java.nio.channels.UnresolvedAddressException;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.concurrent.TimeoutException;
import java.util.function.Predicate;
public enum RetryableIOExceptionPredicate implements Predicate<IOException> {
/**
* @see {@link URLConnection#setConnectTimeout(int)}
* @see {@link URLConnection#setReadTimeout(int)}
*/
CLIENT_TIMEOUT {
@Override
public boolean test(IOException e) {
return (e instanceof SocketTimeoutException || e.getCause() instanceof TimeoutException || e.getClass()
.getName()
.equals("java.net.http.HttpTimeoutException") /*
* Check class name for
* the compatibility with
* Java 8-10
*/);
}
},
CONNECT_TIMEOUT {
@Override
public boolean test(IOException e) {
return (e instanceof ConnectException || e.getClass()
.getName()
.equals("java.net.http.HttpConnectTimeoutException") /*
* Check class
* name for the
* compatibility
* with Java 8-10
*/);
}
},
UNKNOWN_HOST {
@Override
public boolean test(IOException e) {
return (e instanceof UnknownHostException
|| (e instanceof ConnectException && e.getCause() instanceof ConnectException
&& e.getCause().getCause() instanceof UnresolvedAddressException));
}
},
ANY {
@Override
public boolean test(IOException e) {
return true;
}
};
public static Set<Predicate<IOException>> defaults() {
return Collections
.unmodifiableSet(new LinkedHashSet<>(Arrays.asList(CLIENT_TIMEOUT, CONNECT_TIMEOUT, UNKNOWN_HOST)));
}
}
|
0 | java-sources/am/ik/springmvc/new-controller/0.2.0 | java-sources/am/ik/springmvc/new-controller/0.2.0/newcontroller/RouterDefinition.java | /*
* Copyright (C) 2015 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package newcontroller;
import me.geso.routes.WebRouter;
public interface RouterDefinition<T> {
void define(WebRouter<T> router);
}
|
0 | java-sources/am/ik/springmvc/new-controller/0.2.0 | java-sources/am/ik/springmvc/new-controller/0.2.0/newcontroller/RouterHandlerMapping.java | /*
* Copyright (C) 2015 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package newcontroller;
import newcontroller.support.CapturedHttpServletRequest;
import newcontroller.support.CapturedHttpServletRequestAdopter;
import me.geso.routes.RoutingResult;
import me.geso.routes.WebRouter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.HandlerAdapter;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.AbstractHandlerMapping;
import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Optional;
public class RouterHandlerMapping<T> extends AbstractHandlerMapping {
@Autowired
Optional<List<RouterDefinition<T>>> routerDefinitions;
private final static Logger log = LoggerFactory.getLogger(RouterHandlerMapping.class);
private final WebRouter<T> router = new WebRouter<>();
private final HandlerApplier<T> handlerApplier;
public RouterHandlerMapping(HandlerApplier<T> handlerApplier) {
this.handlerApplier = handlerApplier;
}
@FunctionalInterface
public static interface HandlerApplier<T> {
ModelAndView apply(T handler, HttpServletRequest request, HttpServletResponse response) throws Exception;
}
@Override
protected Object getHandlerInternal(HttpServletRequest request) throws Exception {
if (request.getRequestURI().equalsIgnoreCase("favicon.ico")) {
return null;
}
String method = request.getMethod();
String path = request.getRequestURI();
return this.router.match(method, path);
}
@PostConstruct
public void init() {
this.routerDefinitions.ifPresent(defs -> {
for (RouterDefinition<T> def : defs) {
def.define(this.router);
}
});
this.router.getPatterns().forEach(x -> log.info("Router(path={}, method={})\t->\t{}",
x.getPath(), x.getMethods(), x.getDestination()));
}
public HandlerAdapter handlerAdapter() {
return new HandlerAdapter() {
@Override
public boolean supports(Object handler) {
return RoutingResult.class.isAssignableFrom(handler.getClass());
}
@Override
@SuppressWarnings("unchecked")
public ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
RoutingResult<T> routingResult = (RoutingResult<T>) handler;
CapturedHttpServletRequest req = new CapturedHttpServletRequestAdopter(routingResult.getCaptured(), request);
return RouterHandlerMapping.this.handlerApplier.apply(routingResult.getDestination(), req, response);
}
@Override
public long getLastModified(HttpServletRequest request, Object handler) {
return -1;
}
};
}
}
|
0 | java-sources/am/ik/springmvc/new-controller/0.2.0/newcontroller | java-sources/am/ik/springmvc/new-controller/0.2.0/newcontroller/handler/Handler.java | /*
* Copyright (C) 2015 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package newcontroller.handler;
public interface Handler {
HandlerBridge handleRequest(Request request, Response response) throws Exception;
}
|
0 | java-sources/am/ik/springmvc/new-controller/0.2.0/newcontroller | java-sources/am/ik/springmvc/new-controller/0.2.0/newcontroller/handler/HandlerBridge.java | /*
* Copyright (C) 2015 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package newcontroller.handler;
public interface HandlerBridge<T> {
T bridge(Request request, Response response);
}
|
0 | java-sources/am/ik/springmvc/new-controller/0.2.0/newcontroller | java-sources/am/ik/springmvc/new-controller/0.2.0/newcontroller/handler/Request.java | /*
* Copyright (C) 2015 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package newcontroller.handler;
import java.util.List;
import java.util.Map;
import java.util.Optional;
public interface Request {
Optional<String> param(String name);
List<String> params(String name);
Map<String, List<String>> params();
<T> T params(Class<T> clazz);
<T> T body(Class<T> clazz);
Request put(String key, Object value);
<T> T get(String key, Class<T> clazz);
Map<String, ?> model();
<T> T unwrap(Class<T> clazz);
}
|
0 | java-sources/am/ik/springmvc/new-controller/0.2.0/newcontroller | java-sources/am/ik/springmvc/new-controller/0.2.0/newcontroller/handler/Response.java | /*
* Copyright (C) 2015 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package newcontroller.handler;
import org.springframework.http.MediaType;
import org.springframework.web.servlet.View;
import java.util.function.Supplier;
public interface Response {
HandlerBridge body(Object body);
Response contentType(MediaType mediaType);
MediaType contentType();
HandlerBridge view(String viewName);
HandlerBridge view(View view);
HandlerBridge with(Supplier<HandlerBridge> supplier);
<T> T unwrap(Class<T> clazz);
}
|
0 | java-sources/am/ik/springmvc/new-controller/0.2.0/newcontroller/handler | java-sources/am/ik/springmvc/new-controller/0.2.0/newcontroller/handler/impl/DefaultHandlerApplier.java | /*
* Copyright (C) 2015 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package newcontroller.handler.impl;
import newcontroller.RouterHandlerMapping;
import newcontroller.handler.Handler;
import newcontroller.handler.HandlerBridge;
import newcontroller.handler.Request;
import newcontroller.handler.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
public class DefaultHandlerApplier implements RouterHandlerMapping.HandlerApplier<Handler> {
private final List<HttpMessageConverter<?>> converters;
@Autowired
public DefaultHandlerApplier(List<HttpMessageConverter<?>> converters) {
this.converters = converters;
}
@Override
public ModelAndView apply(Handler handler, HttpServletRequest request, HttpServletResponse response) throws Exception {
Request req = new DefaultRequest(request, this.converters);
Response res = new DefaultResponse(response, this.converters);
HandlerBridge<?> handlerBridge = handler.handleRequest(req, res);
Object bridged = handlerBridge.bridge(req, res);
if (bridged instanceof ModelAndView) {
return ModelAndView.class.cast(bridged);
}
return null;
}
}
|
0 | java-sources/am/ik/springmvc/new-controller/0.2.0/newcontroller/handler | java-sources/am/ik/springmvc/new-controller/0.2.0/newcontroller/handler/impl/DefaultRequest.java | /*
* Copyright (C) 2015 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package newcontroller.handler.impl;
import newcontroller.handler.Request;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.server.ServletServerHttpRequest;
import org.springframework.web.bind.WebDataBinder;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
public class DefaultRequest implements Request {
private final HttpServletRequest request;
private final List<HttpMessageConverter<?>> converters;
public DefaultRequest(HttpServletRequest request, List<HttpMessageConverter<?>> converters) {
this.request = request;
this.converters = (converters == null ? Collections.emptyList() : converters);
}
public DefaultRequest(HttpServletRequest request) {
this(request, null);
}
@Override
public Optional<String> param(String name) {
return Optional.ofNullable(this.request.getParameter(name));
}
@Override
public List<String> params(String name) {
String[] values = this.request.getParameterValues(name);
return values == null ? Collections.emptyList() : Arrays.asList(values);
}
@Override
public Map<String, List<String>> params() {
return this.request.getParameterMap().entrySet().stream()
.collect(Collectors.toMap(Map.Entry::getKey, x -> Arrays.asList(x.getValue())));
}
@Override
public <T> T params(Class<T> clazz) {
T obj = BeanUtils.instantiate(clazz);
WebDataBinder binder = new WebDataBinder(obj);
binder.bind(new MutablePropertyValues(this.request.getParameterMap()));
return obj;
}
@Override
public <T> T body(Class<T> clazz) {
MediaType mediaType = MediaType.parseMediaType(this.request.getContentType());
HttpMessageConverter converter = HttpMessageConvertersHelper.findConverter(this.converters, clazz, mediaType);
try {
return clazz.cast(converter.read(clazz, new ServletServerHttpRequest(this.request)));
} catch (IOException e) {
throw new UncheckedIOException(e); // TODO
}
}
@Override
public Request put(String key, Object value) {
this.request.setAttribute(key, value);
return this;
}
@Override
public <T> T get(String key, Class<T> clazz) {
return clazz.cast(this.request.getAttribute(key));
}
@Override
public Map<String, ?> model() {
return Collections.list(this.request.getAttributeNames())
.stream()
.collect(Collectors.toMap(Function.identity(), this.request::getAttribute));
}
@Override
public <T> T unwrap(Class<T> clazz) {
return clazz.cast(this.request);
}
}
|
0 | java-sources/am/ik/springmvc/new-controller/0.2.0/newcontroller/handler | java-sources/am/ik/springmvc/new-controller/0.2.0/newcontroller/handler/impl/DefaultResponse.java | /*
* Copyright (C) 2015 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package newcontroller.handler.impl;
import newcontroller.handler.HandlerBridge;
import newcontroller.handler.Response;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.web.servlet.View;
import javax.servlet.http.HttpServletResponse;
import java.util.Collections;
import java.util.List;
import java.util.function.Supplier;
public class DefaultResponse implements Response {
private final HttpServletResponse response;
private final List<HttpMessageConverter<?>> converters;
private MediaType contentType;
public DefaultResponse(HttpServletResponse response,
List<HttpMessageConverter<?>> converters) {
this.response = response;
this.converters = (converters == null ? Collections.emptyList() : converters);
}
public DefaultResponse(HttpServletResponse response) {
this(response, null);
}
@Override
@SuppressWarnings("unchecked")
public HandlerBridge body(Object body) {
HttpMessageConverter converter = HttpMessageConvertersHelper.findConverter(this.converters, body.getClass(), this.contentType);
return new HttpMessageConverterHandlerBridge(body, converter);
}
@Override
public HandlerBridge view(String viewName) {
return new ModelAndViewHandlerBridge(viewName);
}
@Override
public HandlerBridge view(View view) {
return new ModelAndViewHandlerBridge(view);
}
@Override
public HandlerBridge with(Supplier<HandlerBridge> supplier) {
return supplier.get();
}
@Override
public MediaType contentType() {
return this.contentType;
}
@Override
public Response contentType(MediaType conentType) {
this.contentType = conentType;
return this;
}
@Override
public <T> T unwrap(Class<T> clazz) {
return clazz.cast(this.response);
}
}
|
0 | java-sources/am/ik/springmvc/new-controller/0.2.0/newcontroller/handler | java-sources/am/ik/springmvc/new-controller/0.2.0/newcontroller/handler/impl/HttpMessageConverterHandlerBridge.java | /*
* Copyright (C) 2015 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package newcontroller.handler.impl;
import newcontroller.handler.HandlerBridge;
import newcontroller.handler.Request;
import newcontroller.handler.Response;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.server.ServletServerHttpResponse;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
public class HttpMessageConverterHandlerBridge<T> implements HandlerBridge<Void> {
private final T body;
private final HttpMessageConverter<T> messageConverter;
public HttpMessageConverterHandlerBridge(T body, HttpMessageConverter<T> messageConverter) {
this.body = body;
this.messageConverter = messageConverter;
}
@Override
public Void bridge(Request request, Response response) {
try {
this.messageConverter.write(body, response.contentType(),
new ServletServerHttpResponse(response.unwrap(HttpServletResponse.class)));
} catch (IOException e) {
throw new IllegalStateException(e); // TODO
}
return null;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("HttpMessageConverterHandlerBridge{");
sb.append("body=").append(body);
sb.append(", messageConverter=").append(messageConverter);
sb.append('}');
return sb.toString();
}
}
|
0 | java-sources/am/ik/springmvc/new-controller/0.2.0/newcontroller/handler | java-sources/am/ik/springmvc/new-controller/0.2.0/newcontroller/handler/impl/HttpMessageConvertersHelper.java | /*
* Copyright (C) 2015 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package newcontroller.handler.impl;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import java.util.List;
class HttpMessageConvertersHelper {
static HttpMessageConverter<?> findConverter(List<HttpMessageConverter<?>> converters, Class<?> clazz, MediaType mediaType) {
return converters.stream()
.filter(converter -> converter.canWrite(clazz, mediaType))
.findFirst()
.orElseThrow(() -> new IllegalStateException("Cannot find HttpMessageConverter for clazz=" + clazz + ", mediaType=" + mediaType));
}
}
|
0 | java-sources/am/ik/springmvc/new-controller/0.2.0/newcontroller/handler | java-sources/am/ik/springmvc/new-controller/0.2.0/newcontroller/handler/impl/ModelAndViewHandlerBridge.java | /*
* Copyright (C) 2015 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package newcontroller.handler.impl;
import newcontroller.handler.HandlerBridge;
import newcontroller.handler.Request;
import newcontroller.handler.Response;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.View;
public class ModelAndViewHandlerBridge implements HandlerBridge<ModelAndView> {
private final ModelAndView modelAndView;
public ModelAndViewHandlerBridge(View view) {
this.modelAndView = new ModelAndView(view);
}
public ModelAndViewHandlerBridge(String viewName) {
this.modelAndView = new ModelAndView(viewName);
}
@Override
public ModelAndView bridge(Request request, Response response) {
this.modelAndView.addAllObjects(request.model());
return this.modelAndView;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("ModelAndViewHandlerBridge{");
sb.append("modelAndView=").append(modelAndView);
sb.append('}');
return sb.toString();
}
}
|
0 | java-sources/am/ik/springmvc/new-controller/0.2.0/newcontroller | java-sources/am/ik/springmvc/new-controller/0.2.0/newcontroller/support/CapturedHttpServletRequest.java | /*
* Copyright (C) 2015 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package newcontroller.support;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
public interface CapturedHttpServletRequest extends HttpServletRequest {
Map<String, String> pathParams();
}
|
0 | java-sources/am/ik/springmvc/new-controller/0.2.0/newcontroller | java-sources/am/ik/springmvc/new-controller/0.2.0/newcontroller/support/CapturedHttpServletRequestAdopter.java | /*
* Copyright (C) 2015 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package newcontroller.support;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import java.util.Map;
public class CapturedHttpServletRequestAdopter extends HttpServletRequestWrapper implements CapturedHttpServletRequest {
private final Map<String, String> captured;
private final HttpServletRequest request;
public CapturedHttpServletRequestAdopter(Map<String, String> captured, HttpServletRequest request) {
super(request);
this.captured = captured;
this.request = request;
}
@Override
public String getParameter(String name) {
String captured = this.captured.get(name);
return captured == null ? super.getParameter(name) : captured;
}
@Override
public Map<String, String> pathParams() {
return this.captured;
}
}
|
0 | java-sources/am/ik/template/java-lib/0.2.0/am/ik | java-sources/am/ik/template/java-lib/0.2.0/am/ik/template/Library.java | package am.ik.template;
public class Library {
public static String hello() {
return "Hello World!";
}
}
|
0 | java-sources/am/ik/timeflake/timeflake4j/1.4.0/am/ik | java-sources/am/ik/timeflake/timeflake4j/1.4.0/am/ik/timeflake/Base62.java | package am.ik.timeflake;
import java.math.BigInteger;
import java.util.function.BiFunction;
import java.util.regex.Pattern;
import java.util.stream.IntStream;
import static java.util.Objects.requireNonNull;
/**
* Base62 encoder/decoder.
* <p>
* This is free and unencumbered public domain software
* <p>
* Source: https://github.com/opencoinage/opencoinage/blob/master/src/java/org/opencoinage/util/Base62.java
*/
class Base62 {
private static final BigInteger BASE = BigInteger.valueOf(62);
private static final String DIGITS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
/**
* Encodes a number using Base62 encoding.
*
* @param number a positive integer
* @return a Base62 string
*
* @throws IllegalArgumentException if <code>number</code> is a negative integer
*/
static String encode(BigInteger number) {
if (number.compareTo(BigInteger.ZERO) < 0) {
throwIllegalArgumentException("number must not be negative");
}
StringBuilder result = new StringBuilder();
while (number.compareTo(BigInteger.ZERO) > 0) {
BigInteger[] divmod = number.divideAndRemainder(BASE);
number = divmod[0];
int digit = divmod[1].intValue();
result.insert(0, DIGITS.charAt(digit));
}
return (result.length() == 0) ? DIGITS.substring(0, 1) : result.toString();
}
private static BigInteger throwIllegalArgumentException(String format, Object... args) {
throw new IllegalArgumentException(String.format(format, args));
}
/**
* Decodes a string using Base62 encoding.
*
* @param string a Base62 string
* @return a positive integer
*
* @throws IllegalArgumentException if <code>string</code> is empty
*/
static BigInteger decode(final String string) {
return decode(string, 128);
}
static BigInteger decode(final String string, int bitLimit) {
requireNonNull(string, "Decoded string must not be null");
if (string.length() == 0) {
return throwIllegalArgumentException("String '%s' must not be empty", string);
}
if (!Pattern.matches("[" + DIGITS + "]*", string)) {
throwIllegalArgumentException("String '%s' contains illegal characters, only '%s' are allowed", string, DIGITS);
}
return IntStream.range(0, string.length())
.mapToObj(index -> BigInteger.valueOf(charAt.apply(string, index)).multiply(BASE.pow(index)))
.reduce(BigInteger.ZERO, (acc, value) -> {
BigInteger sum = acc.add(value);
if (bitLimit > 0 && sum.bitLength() > bitLimit) {
throwIllegalArgumentException("String '%s' contains more than 128bit information", string);
}
return sum;
});
}
private static BiFunction<String, Integer, Integer> charAt = (string, index) ->
DIGITS.indexOf(string.charAt(string.length() - index - 1));
} |
0 | java-sources/am/ik/timeflake/timeflake4j/1.4.0/am/ik | java-sources/am/ik/timeflake/timeflake4j/1.4.0/am/ik/timeflake/Timeflake.java | /*
* Copyright (c) 2021 Toshiaki Maki <makingx@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
package am.ik.timeflake;
import java.math.BigInteger;
import java.time.Instant;
import java.util.Objects;
import java.util.Random;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;
/**
* Timeflake is a 128-bit, roughly-ordered, URL-safe UUID. Inspired by Twitter's Snowflake, Instagram's ID and Firebase's PushID.<br>
*
* The first 48 bits are a timestamp, which both reduces the chance of collision and allows consecutively created push IDs to sort chronologically. <br>
* The timestamp is followed by 80 bits of randomness, which ensures that even two people creating Timeflakes at the exact same millisecond are extremely unlikely to generate identical IDs.
*
* @author Toshiaki Maki
* @see <a href="https://github.com/anthonynsimon/timeflake">Timeflake</a>
*/
public final class Timeflake implements java.io.Serializable, Comparable<Timeflake> {
private static final long serialVersionUID = -4856846361193249487L;
/**
* internal representation of a Snowflake
*/
private final BigInteger value;
/**
* the max value of Snowflake (2^128)
*/
static final BigInteger MAX_VALUE = new BigInteger("340282366920938463463374607431768211455");
/**
* the max value of the timestamp part (2^48)
*/
static final long MAX_TIMESTAMP = 281474976710655L;
/**
* the max value of the random part (2^60)
*/
static final BigInteger MAX_RANDOM = new BigInteger("1208925819614629174706175");
/**
* Create a Snowflake instance from a 128-bit big integer.
* @param value 128-bit internal representation of a Snowflake.
* @throws IllegalArgumentException if the given value exceeds the max value
*/
private Timeflake(BigInteger value) {
if (value == null) {
throw new IllegalArgumentException("'value' must not be null.");
}
if (value.compareTo(MAX_VALUE) > 0) {
throw new IllegalArgumentException("'value' must not be greater than " + MAX_VALUE + ".");
}
this.value = value;
}
/**
* Encode the snowflake to Base62 string
* @return base62 encoded snowflake
*/
@Override
public String toString() {
return this.base62();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Timeflake timeflake = (Timeflake) o;
return Objects.equals(value, timeflake.value);
}
@Override
public int hashCode() {
return Objects.hash(value);
}
/**
* Use {@link #valueOf(BigInteger)} instead
*/
@Deprecated
public static Timeflake of(BigInteger value) {
return valueOf(value);
}
/**
* Create a Snowflake instance from a 128-bit big integer.
* @param value 128-bit internal representation of a Snowflake.
* @return Snowflake instance
* @throws IllegalArgumentException if the given value exceeds the max value
*/
public static Timeflake valueOf(BigInteger value) {
return new Timeflake(value);
}
/**
* Use {@link #valueOf(UUID)} instead
*/
@Deprecated
public static Timeflake fromUuid(UUID uuid) {
return valueOf(uuid);
}
/**
* Create a Snowflake instance from an UUID
* @param uuid UUID
* @return Snowflake instance
* @throws IllegalArgumentException if the given value exceeds the max value
*/
public static Timeflake valueOf(UUID uuid) {
final BigInteger value = Util.uuid2BigInteger(uuid);
return new Timeflake(value);
}
/**
* Create a Snowflake instance from timestamp and random value
* @param timestampMillis 48-bit timestamp part of a snowflake
* @param random 80-bit random part of a snowflake
* @return Snowflake instance
* @throws IllegalArgumentException if the given value exceeds the max value
*/
public static Timeflake create(long timestampMillis, BigInteger random) {
if (timestampMillis > MAX_TIMESTAMP) {
throw new IllegalArgumentException("'timestampMillis' must not be greater than " + MAX_TIMESTAMP + ".");
}
if (random.compareTo(MAX_RANDOM) > 0) {
throw new IllegalArgumentException("'random' must not be greater than " + MAX_RANDOM + ".");
}
final BigInteger timestamp = BigInteger.valueOf(timestampMillis);
final BigInteger value = timestamp.shiftLeft(80).or(random);
return new Timeflake(value);
}
/**
* Create a Snowflake instance from timestamp and random value
* @param timestamp 48-bit timestamp part of a snowflake
* @param random 80-bit random part of a snowflake
* @return Snowflake instance
* @throws IllegalArgumentException if the given value exceeds the max value
*/
public static Timeflake create(Instant timestamp, BigInteger random) {
return create(timestamp.toEpochMilli(), random);
}
/**
* Use {@link #valueOf(String)} instead
*/
@Deprecated
public static Timeflake fromBase62(String base62) {
return valueOf(base62);
}
/**
* Create a Snowflake instance from a base62 encoded string
* @param base62 base62 encoded snowflake
* @return Snowflake instance
* @throws IllegalArgumentException if the given value exceeds the max value
*/
public static Timeflake valueOf(String base62) {
final BigInteger value = Base62.decode(base62);
return new Timeflake(value);
}
/**
* Generate a Snowflake instance using current timestamp and <code>ThreadLocalRandom</code>.
* @return Snowflake instance
*/
public static Timeflake generate() {
return generate(ThreadLocalRandom.current());
}
/**
* Generate a Snowflake instance using current timestamp and the given random instance.
* @return Snowflake instance
*/
public static Timeflake generate(Random random) {
return create(System.currentTimeMillis(), new BigInteger(80, random));
}
public BigInteger value() {
return this.value;
}
/**
* Convert the snowflake to UUID
* @return UUID representation of the snowflake
*/
public UUID toUuid() {
return Util.bigInteger2Uuid(this.value);
}
/**
* Return timestamp part of the snowflake as an <code>Instance</code>
* @return timestamp part of the snowflake
*/
public Instant toInstant() {
final long epochMilli = this.value.shiftRight(80).longValue();
return Instant.ofEpochMilli(epochMilli);
}
/**
* Convert the snowflake to byte[]
* @return byte[] representation of the snowflake
*/
public byte[] toByteArray() {
return this.value.toByteArray();
}
/**
* Encode the snowflake to Base62 string
* @return base62 encoded snowflake
*/
public String base62() {
return Base62.encode(this.value);
}
@Override
public int compareTo(Timeflake o) {
return Objects.compare(this.value, o.value, BigInteger::compareTo);
}
}
|
0 | java-sources/am/ik/timeflake/timeflake4j/1.4.0/am/ik | java-sources/am/ik/timeflake/timeflake4j/1.4.0/am/ik/timeflake/Util.java | package am.ik.timeflake;
import java.math.BigInteger;
import java.util.UUID;
/**
* https://gist.github.com/drmalex07/9008c611ffde6cb2ef3a2db8668bc251
*/
class Util {
public static final BigInteger HALF = BigInteger.ONE.shiftLeft(64); // 2^64
public static final BigInteger LONG_MAX = BigInteger.valueOf(Long.MAX_VALUE);
public static BigInteger uuid2BigInteger(UUID uuid) {
BigInteger lo = BigInteger.valueOf(uuid.getLeastSignificantBits());
BigInteger hi = BigInteger.valueOf(uuid.getMostSignificantBits());
// If any of lo/hi parts is negative interpret as unsigned
if (hi.signum() < 0) {
hi = hi.add(HALF);
}
if (lo.signum() < 0) {
lo = lo.add(HALF);
}
return lo.add(hi.multiply(HALF));
}
public static UUID bigInteger2Uuid(BigInteger i) {
final BigInteger[] parts = i.divideAndRemainder(HALF);
BigInteger hi = parts[0];
BigInteger lo = parts[1];
if (LONG_MAX.compareTo(lo) < 0) {
lo = lo.subtract(HALF);
}
if (LONG_MAX.compareTo(hi) < 0) {
hi = hi.subtract(HALF);
}
return new UUID(hi.longValueExact(), lo.longValueExact());
}
}
|
0 | java-sources/am/ik/timeflake/timeflake4j/1.4.0/am/ik | java-sources/am/ik/timeflake/timeflake4j/1.4.0/am/ik/timeflake/package-info.java | /*
* Copyright (c) 2021 Toshiaki Maki <makingx@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
package am.ik.timeflake;
|
0 | java-sources/am/ik/timeflake/timeflake4j/1.4.0/am/ik/timeflake | java-sources/am/ik/timeflake/timeflake4j/1.4.0/am/ik/timeflake/spring/TimeflakeIdGenerator.java | /*
* Copyright (c) 2021 Toshiaki Maki <makingx@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
package am.ik.timeflake.spring;
import java.util.Random;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;
import java.util.function.Supplier;
import am.ik.timeflake.Timeflake;
import org.springframework.util.IdGenerator;
public class TimeflakeIdGenerator implements IdGenerator {
private final Supplier<Random> randomFactory;
public TimeflakeIdGenerator(Supplier<Random> randomFactory) {
this.randomFactory = randomFactory;
}
public TimeflakeIdGenerator() {
this(ThreadLocalRandom::current);
}
@Override
public UUID generateId() {
final Random random = this.randomFactory.get();
return Timeflake.generate(random).toUuid();
}
}
|
0 | java-sources/am/ik/tsng/tsng/0.1.0/am/ik | java-sources/am/ik/tsng/tsng/0.1.0/am/ik/tsng/TypeSafeName.java | /*
* Copyright (C) 2020 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.tsng;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ ElementType.METHOD, ElementType.PARAMETER })
@Retention(RetentionPolicy.SOURCE)
public @interface TypeSafeName {
boolean getter() default true;
boolean field() default false;
}
|
0 | java-sources/am/ik/tsng/tsng/0.1.0/am/ik | java-sources/am/ik/tsng/tsng/0.1.0/am/ik/tsng/TypeSafeProperties.java | /*
* Copyright (C) 2020 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.tsng;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ ElementType.CONSTRUCTOR, ElementType.METHOD })
@Retention(RetentionPolicy.SOURCE)
public @interface TypeSafeProperties {
}
|
0 | java-sources/am/ik/tsng/tsng/0.1.0/am/ik | java-sources/am/ik/tsng/tsng/0.1.0/am/ik/tsng/package-info.java | /*
* Copyright (C) 2020 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.tsng;
|
0 | java-sources/am/ik/tsng/tsng/0.1.0/am/ik/tsng | java-sources/am/ik/tsng/tsng/0.1.0/am/ik/tsng/processor/Pair.java | /*
* Copyright (C) 2020 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.tsng.processor;
import java.util.Objects;
final class Pair<F, S> {
private final F first;
private final S second;
public Pair(F first, S second) {
this.first = first;
this.second = second;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
Pair<?, ?> pair = (Pair<?, ?>) o;
return Objects.equals(first, pair.first) && Objects.equals(second, pair.second);
}
public F first() {
return this.first;
}
@Override
public int hashCode() {
return Objects.hash(first, second);
}
public S second() {
return this.second;
}
@Override
public String toString() {
return "Pair{" + "first=" + first + ", second=" + second + '}';
}
}
|
0 | java-sources/am/ik/tsng/tsng/0.1.0/am/ik/tsng | java-sources/am/ik/tsng/tsng/0.1.0/am/ik/tsng/processor/TypeSafeNameProcessor.java | /*
* Copyright (C) 2020 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.tsng.processor;
import am.ik.tsng.TypeSafeName;
import am.ik.tsng.TypeSafeProperties;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.*;
import javax.lang.model.type.TypeMirror;
import javax.tools.JavaFileObject;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UncheckedIOException;
import java.nio.CharBuffer;
import java.time.OffsetDateTime;
import java.util.*;
import java.util.function.BiConsumer;
import static am.ik.tsng.processor.TypeSafeNameTemplate.template;
import static java.util.stream.Collectors.groupingBy;
import static java.util.stream.Collectors.toList;
import static javax.lang.model.element.ElementKind.*;
import static javax.lang.model.type.TypeKind.BOOLEAN;
@SupportedAnnotationTypes({ "am.ik.tsng.TypeSafeName", "am.ik.tsng.TypeSafeProperties" })
public class TypeSafeNameProcessor extends AbstractProcessor {
@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latest();
}
@Override
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) {
for (TypeElement typeElement : annotations) {
final Name qualifiedName = typeElement.getQualifiedName();
if (qualifiedName.contentEquals(TypeSafeName.class.getName())) {
this.processTypeSafeName(typeElement, roundEnv);
}
if (qualifiedName.contentEquals(TypeSafeProperties.class.getName())) {
this.processTypeSafeProperties(typeElement, roundEnv);
}
}
return true;
}
private void processTypeSafeName(TypeElement typeElement, RoundEnvironment roundEnv) {
final Set<? extends Element> elementsAnnotatedWith = roundEnv
.getElementsAnnotatedWith(typeElement);
final Map<String, List<Pair<Element, Integer>>> elementsMap = elementsAnnotatedWith
.stream()
.filter(x -> !(x instanceof ExecutableElement)
|| ((ExecutableElement) x).getTypeParameters().isEmpty())
.map(x -> new Pair<Element, Integer>(x, -1)).collect(groupingBy(k -> {
String className = "****";
final Element element = k.first();
if (element instanceof VariableElement) {
className = element.getEnclosingElement().getEnclosingElement()
.toString();
}
else if (element instanceof ExecutableElement) {
className = element.getEnclosingElement().toString();
}
return className;
}, toList()));
if (elementsMap.isEmpty()) {
return;
}
elementsMap.forEach(this::writeTypeSafeNameFile);
}
private void processTypeSafeProperties(TypeElement typeElement,
RoundEnvironment roundEnv) {
final Set<? extends Element> elementsAnnotatedWith = roundEnv
.getElementsAnnotatedWith(typeElement);
for (Element element : elementsAnnotatedWith) {
final List<Element> parameters = new ArrayList<>(
((ExecutableElement) element).getParameters());
String className = element.getEnclosingElement().toString();
if (element.getKind() == METHOD) {
parameters.add(0, element.getEnclosingElement());
className = className + upperCamel(element.getSimpleName().toString());
}
final List<Pair<Element, Integer>> pairs = parameters.stream()
.map(x -> new Pair<>(x, parameters.indexOf(x))).collect(toList());
this.writeTypeSafePropertiesFile(className, pairs);
}
}
private void writeTypeSafeNameFile(String className,
List<Pair<Element, Integer>> elements) {
this.writeFile(className + "Name", elements, (pair, metas) -> {
final Element element = pair.first();
final TypeSafeName typeSafeName = element.getAnnotation(TypeSafeName.class);
final ElementKind kind = element.getKind();
final String name = element.getSimpleName().toString();
if (kind == METHOD) {
final TypeMirror type = ((ExecutableElement) element).getReturnType();
final String target = lowerCamel(typeSafeName.getter()
? name.replaceFirst("^" + getterPrefix(type), "")
: name);
metas.put(target, template(target));
}
else if (kind == PARAMETER) {
metas.put(name, template(name));
}
});
}
private void writeTypeSafePropertiesFile(String className,
List<Pair<Element, Integer>> elements) {
this.writeFile(className + "Properties", elements, (pair, metas) -> {
final Element element = pair.first();
final String name = element.getSimpleName().toString();
metas.put(name, TypeSafeNameTemplate
.template(element.getKind() == CLASS ? lowerCamel(name) : name));
});
}
private void writeFile(String className, List<Pair<Element, Integer>> elements,
BiConsumer<Pair<Element, Integer>, Map<String, String>> processElement) {
final Pair<String, String> pair = splitClassName(className);
final String packageName = pair.first();
final String simpleClassName = pair.second();
final String metaSimpleClassName = "_" + simpleClassName.replace('.', '_');
final String metaClassName = packageName + "." + metaSimpleClassName;
try {
final JavaFileObject builderFile = super.processingEnv.getFiler()
.createSourceFile(metaClassName);
// try (final PrintWriter out = new PrintWriter(System.out)) {
try (final PrintWriter out = new PrintWriter(builderFile.openWriter())) {
if (!packageName.isEmpty()) {
out.print("package ");
out.print(packageName);
out.println(";");
out.println();
}
out.println("// Generated at " + OffsetDateTime.now());
out.print("public class ");
out.print(metaSimpleClassName);
out.println(" {");
final Map<String, String> metas = new LinkedHashMap<>();
for (Pair<Element, Integer> element : elements) {
processElement.accept(element, metas);
}
metas.forEach((k, v) -> out.println(" " + v));
out.println("}");
}
}
catch (IOException e) {
throw new UncheckedIOException(e);
}
}
static Pair<String, String> splitClassName(String className) {
String packageName = "";
final int p = firstUpperPosition(className);
if (p > 0) {
packageName = className.substring(0, p - 1);
}
final String simpleClassName = className.substring(p);
return new Pair<>(packageName, simpleClassName);
}
static int firstUpperPosition(String s) {
final String lower = s.toLowerCase();
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) != lower.charAt(i)) {
return i;
}
}
return -1;
}
static String getterPrefix(TypeMirror type) {
return type.getKind() == BOOLEAN ? "is" : "get";
}
static String lowerCamel(String s) {
if (s.length() >= 2) {
final String firstTwo = s.substring(0, 2);
if (firstTwo.equals(firstTwo.toUpperCase())) {
return s;
}
}
return s.substring(0, 1).toLowerCase() + s.substring(1);
}
static String upperCamel(String s) {
if (s.length() >= 2) {
final String firstTwo = s.substring(0, 2);
if (firstTwo.equals(firstTwo.toUpperCase())) {
return s;
}
}
return s.substring(0, 1).toUpperCase() + s.substring(1);
}
static String lowerUnderscore(String text) {
if (text == null || text.isEmpty()) {
return text;
}
final StringBuilder s = new StringBuilder();
final CharBuffer buffer = CharBuffer.wrap(text);
while (buffer.hasRemaining()) {
final char c = buffer.get();
s.append(Character.toLowerCase(c));
buffer.mark();
if (buffer.hasRemaining()) {
final char c2 = buffer.get();
if (Character.isLowerCase(c) && Character.isUpperCase(c2)) {
s.append("_");
}
buffer.reset();
}
}
return s.toString();
}
}
|
0 | java-sources/am/ik/tsng/tsng/0.1.0/am/ik/tsng | java-sources/am/ik/tsng/tsng/0.1.0/am/ik/tsng/processor/TypeSafeNameTemplate.java | /*
* Copyright (C) 2020 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.tsng.processor;
import static am.ik.tsng.processor.TypeSafeNameProcessor.*;
final class TypeSafeNameTemplate {
static String template(String target) {
final String lowerCamel = lowerCamel(target);
final String upperCamel = upperCamel(target);
final String lowerUnderscore = lowerUnderscore(lowerCamel);
final String upperUnderscore = lowerUnderscore.toUpperCase();
return String.format("\tpublic static final class %s {\n" + //
"\t\tpublic static final String LOWER_CAMEL = \"%s\";\n" + //
"\t\tpublic static final String UPPER_CAMEL = \"%s\";\n" + //
"\t\tpublic static final String LOWER_UNDERSCORE = \"%s\";\n" + //
"\t\tpublic static final String UPPER_UNDERSCORE = \"%s\";\n" + //
"\t}\n", upperCamel, lowerCamel, upperCamel, lowerUnderscore,
upperUnderscore);
}
}
|
0 | java-sources/am/ik/tsng/tsng/0.1.0/am/ik/tsng | java-sources/am/ik/tsng/tsng/0.1.0/am/ik/tsng/processor/package-info.java | /*
* Copyright (C) 2020 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.tsng.processor;
|
0 | java-sources/am/ik/util/database-url-parser/0.1.3/am/ik | java-sources/am/ik/util/database-url-parser/0.1.3/am/ik/utils/DatabaseUrlParser.java | package am.ik.utils;
import java.net.URI;
import java.util.Objects;
public class DatabaseUrlParser {
private final String scheme;
private final String host;
private final int port;
private final String database;
private final String username;
private final String password;
private final String query;
public DatabaseUrlParser(String databaseUrl) {
final URI uri = URI.create(Objects.requireNonNull(databaseUrl, "'databaseUrl' must not be null."));
this.scheme = uri.getScheme();
this.host = uri.getHost();
this.port = uri.getPort();
final String path = uri.getPath();
this.database = path.startsWith("/") ? path.substring(1) : path;
final String[] userInfo = uri.getUserInfo().split(":");
this.username = userInfo[0];
this.password = userInfo[1];
this.query = uri.getQuery();
}
public String getScheme() {
return scheme;
}
public String getHost() {
return host;
}
public int getPort() {
return port;
}
public String getDatabase() {
return database;
}
public String getUsername() {
return username;
}
public String getPassword() {
return password;
}
public String getQuery() {
return query;
}
public String getJdbcScheme() {
if (this.scheme.equals("postgres")) {
return "postgresql";
}
return this.scheme;
}
public String getJdbcUrl() {
final StringBuilder url = new StringBuilder();
url.append("jdbc:").append(this.getJdbcScheme()).append("://").append(this.host);
if (this.port > 0) {
url.append(":").append(this.port);
}
url.append("/").append(this.database);
if (this.query != null && !this.query.isBlank()) {
url.append("?").append(this.query);
}
return url.toString();
}
}
|
0 | java-sources/am/ik/util/database-url-parser/0.1.3/am/ik/utils | java-sources/am/ik/util/database-url-parser/0.1.3/am/ik/utils/spring/DatabaseUrlEnvironmentPostProcessor.java | package am.ik.utils.spring;
import java.util.Map;
import java.util.TreeMap;
import java.util.logging.Logger;
import am.ik.utils.DatabaseUrlParser;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor;
import org.springframework.boot.env.EnvironmentPostProcessor;
import org.springframework.core.Ordered;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.MapPropertySource;
import org.springframework.core.env.MutablePropertySources;
import static org.springframework.core.env.StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME;
public class DatabaseUrlEnvironmentPostProcessor implements EnvironmentPostProcessor, Ordered {
public static final String DATABASE_URL_KEY = "DATABASE_URL";
public static final String SOURCE_NAME = "databaseUrlProperties";
private final Logger log = Logger.getLogger(DatabaseUrlEnvironmentPostProcessor.class.getName());
@Override
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
final String databaseUrl = (String) environment.getSystemEnvironment().get(DATABASE_URL_KEY);
if (databaseUrl == null) {
return;
}
log.info(() -> "Detect '%s' environment variable".formatted(DATABASE_URL_KEY));
final DatabaseUrlParser urlParser = new DatabaseUrlParser(databaseUrl);
final Map<String, Object> properties = new TreeMap<>();
properties.put("spring.datasource.url", urlParser.getJdbcUrl());
properties.put("spring.datasource.username", urlParser.getUsername());
properties.put("spring.datasource.password", urlParser.getPassword());
final MapPropertySource propertySource = new MapPropertySource(SOURCE_NAME, properties);
final MutablePropertySources propertySources = environment.getPropertySources();
if (propertySources.contains(SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME)) {
propertySources.addBefore(SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, propertySource);
}
else {
propertySources.addFirst(propertySource);
}
}
@Override
public int getOrder() {
return ConfigDataEnvironmentPostProcessor.ORDER - 1;
}
}
|
0 | java-sources/am/ik/voicetext/voicetext4j/1.0.0/am/ik | java-sources/am/ik/voicetext/voicetext4j/1.0.0/am/ik/voicetext4j/Emotion.java | /*
* Copyright (C) 2014-2016 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Copyright (C) 2014 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.voicetext4j;
public enum Emotion {
HAPPINESS,
ANGER,
SADNESS;
public static enum Level {
NORMAL(1), HIGH(2);
private final int value;
Level(int value) {
this.value = value;
}
public int value() {
return value;
}
}
}
|
0 | java-sources/am/ik/voicetext/voicetext4j/1.0.0/am/ik | java-sources/am/ik/voicetext/voicetext4j/1.0.0/am/ik/voicetext4j/EmotionalSpeaker.java | /*
* Copyright (C) 2014-2016 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Copyright (C) 2014 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.voicetext4j;
public enum EmotionalSpeaker implements Speakable<EmotionalVoiceContext> {
HARUKA, HIKARI, TAKERU, SANTA, BEAR;
@Override
public EmotionalVoiceContext ready() {
return new EmotionalVoiceContext(this.name().toLowerCase());
}
}
|
0 | java-sources/am/ik/voicetext/voicetext4j/1.0.0/am/ik | java-sources/am/ik/voicetext/voicetext4j/1.0.0/am/ik/voicetext4j/EmotionalVoiceContext.java | /*
* Copyright (C) 2014-2016 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Copyright (C) 2014 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.voicetext4j;
import am.ik.voicetext4j.http.VoiceTextFields;
public class EmotionalVoiceContext extends VoiceContext<EmotionalVoiceContext> {
Emotion emotion;
Emotion.Level emotionLevel = Emotion.Level.NORMAL;
public EmotionalVoiceContext(String speaker) {
super(speaker);
}
public EmotionalVoiceContext emotion(Emotion emotion, Emotion.Level level) {
this.emotion = emotion;
this.emotionLevel = level;
return this;
}
public EmotionalVoiceContext emotion(Emotion emotion) {
this.emotion = emotion;
return this;
}
@Override
protected VoiceTextFields build() {
VoiceTextFields fields = super.build();
if (emotion != null) {
fields.put("emotion", emotion.name().toLowerCase())
.put("emotion_level", String.valueOf(emotionLevel.value()));
}
return fields;
}
public EmotionContext very() {
return new EmotionContext(this, Emotion.Level.HIGH);
}
public EmotionalVoiceContext angry() {
if (this.emotion != null) {
throw new IllegalArgumentException("'emotion' is already set.");
}
return new EmotionContext(this).angry();
}
public EmotionalVoiceContext happy() {
if (this.emotion != null) {
throw new IllegalArgumentException("'emotion' is already set.");
}
return new EmotionContext(this).happy();
}
public EmotionalVoiceContext sad() {
if (this.emotion != null) {
throw new IllegalArgumentException("'emotion' is already set.");
}
return new EmotionContext(this).sad();
}
public class EmotionContext {
final EmotionalVoiceContext voiceContext;
public EmotionContext(EmotionalVoiceContext voiceContext, Emotion.Level emotionLevel) {
this.voiceContext = voiceContext;
voiceContext.emotionLevel = emotionLevel;
}
public EmotionContext(EmotionalVoiceContext voiceContext) {
this(voiceContext, Emotion.Level.NORMAL);
}
public EmotionalVoiceContext angry() {
voiceContext.emotion = Emotion.ANGER;
return voiceContext;
}
public EmotionalVoiceContext happy() {
voiceContext.emotion = Emotion.HAPPINESS;
return voiceContext;
}
public EmotionalVoiceContext sad() {
voiceContext.emotion = Emotion.SADNESS;
return voiceContext;
}
}
}
|
0 | java-sources/am/ik/voicetext/voicetext4j/1.0.0/am/ik | java-sources/am/ik/voicetext/voicetext4j/1.0.0/am/ik/voicetext4j/NormalVoiceContext.java | /*
* Copyright (C) 2014-2016 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Copyright (C) 2014 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.voicetext4j;
public class NormalVoiceContext extends VoiceContext<NormalVoiceContext> {
public NormalVoiceContext(String speaker) {
super(speaker);
}
}
|
0 | java-sources/am/ik/voicetext/voicetext4j/1.0.0/am/ik | java-sources/am/ik/voicetext/voicetext4j/1.0.0/am/ik/voicetext4j/Speakable.java | /*
* Copyright (C) 2014-2016 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Copyright (C) 2014 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.voicetext4j;
public interface Speakable<T extends VoiceContext> {
T ready();
}
|
0 | java-sources/am/ik/voicetext/voicetext4j/1.0.0/am/ik | java-sources/am/ik/voicetext/voicetext4j/1.0.0/am/ik/voicetext4j/Speaker.java | /*
* Copyright (C) 2014-2016 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Copyright (C) 2014 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.voicetext4j;
public enum Speaker implements Speakable<NormalVoiceContext> {
SHOW;
@Override
public NormalVoiceContext ready() {
return new NormalVoiceContext(this.name().toLowerCase());
}
}
|
0 | java-sources/am/ik/voicetext/voicetext4j/1.0.0/am/ik | java-sources/am/ik/voicetext/voicetext4j/1.0.0/am/ik/voicetext4j/VoiceContext.java | /*
* Copyright (C) 2014-2016 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Copyright (C) 2014 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.voicetext4j;
import am.ik.voicetext4j.http.VoiceTextFields;
import am.ik.voicetext4j.http.VoiceTextResponse;
import am.ik.voicetext4j.http.VoiceTextUrlConnectionClient;
import java.io.Serializable;
import java.util.concurrent.CompletableFuture;
@SuppressWarnings("unchecked")
public abstract class VoiceContext<T extends VoiceContext> implements Serializable {
final String speaker;
int pitch = 100;
int speed = 100;
int volume = 100;
public VoiceContext(String speaker) {
this.speaker = speaker;
}
public T pitch(int pitch) {
if (pitch < 50 || pitch > 200) {
throw new IllegalArgumentException("'pitch' must be between 50 and 200.");
}
this.pitch = pitch;
return (T) this;
}
public T speed(int speed) {
if (speed < 50 || speed > 400) {
throw new IllegalArgumentException("'speed' must be between 50 and 400.");
}
this.speed = speed;
return (T) this;
}
public T volume(int volume) {
if (volume < 50 || volume > 200) {
throw new IllegalArgumentException("'volume' must be between 50 and 200.");
}
this.volume = volume;
return (T) this;
}
protected VoiceTextFields build() {
return new VoiceTextFields()
.put("speaker", speaker)
.put("pitch", String.valueOf(pitch))
.put("speed", String.valueOf(speed))
.put("volume", String.valueOf(volume));
}
public VoiceTextResponse getResponse(String text, String apiKey) {
if (text == null || text.length() < 1 || text.length() > 200) {
throw new IllegalArgumentException("the length of 'text' must be between 1 and 200.");
}
if (apiKey == null || apiKey.isEmpty()) {
throw new IllegalArgumentException("'apiKey' is required.");
}
VoiceTextFields fields = build().put("text", text);
return new VoiceTextUrlConnectionClient()
.execute(fields, apiKey);
}
public VoiceTextResponse getResponse(String text) {
return getResponse(text, System.getProperty("voicetext.apikey"));
}
public CompletableFuture<Void> speak(String text, String apiKey) throws InterruptedException {
return getResponse(text, apiKey).play();
}
public CompletableFuture<Void> speak(String text) {
return getResponse(text).play();
}
}
|
0 | java-sources/am/ik/voicetext/voicetext4j/1.0.0/am/ik/voicetext4j | java-sources/am/ik/voicetext/voicetext4j/1.0.0/am/ik/voicetext4j/http/VoiceTextApiCallException.java | /*
* Copyright (C) 2014-2016 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Copyright (C) 2014 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.voicetext4j.http;
public class VoiceTextApiCallException extends RuntimeException {
public VoiceTextApiCallException(int status, String reason) {
super(status + " " + reason);
}
}
|
0 | java-sources/am/ik/voicetext/voicetext4j/1.0.0/am/ik/voicetext4j | java-sources/am/ik/voicetext/voicetext4j/1.0.0/am/ik/voicetext4j/http/VoiceTextFields.java | /*
* Copyright (C) 2014-2016 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Copyright (C) 2014 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.voicetext4j.http;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.URLEncoder;
public class VoiceTextFields {
final ByteArrayOutputStream content = new ByteArrayOutputStream();
public VoiceTextFields put(String name, String value) {
if (content.size() > 0) {
content.write('&');
}
try {
name = URLEncoder.encode(name, "UTF-8");
value = URLEncoder.encode(value, "UTF-8");
content.write(name.getBytes("UTF-8"));
content.write('=');
content.write(value.getBytes("UTF-8"));
} catch (IOException e) {
throw new RuntimeException(e);
}
return this;
}
public byte[] getBody() {
return content.toByteArray();
}
}
|
0 | java-sources/am/ik/voicetext/voicetext4j/1.0.0/am/ik/voicetext4j | java-sources/am/ik/voicetext/voicetext4j/1.0.0/am/ik/voicetext4j/http/VoiceTextIllegalStateException.java | /*
* Copyright (C) 2014-2016 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Copyright (C) 2014 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.voicetext4j.http;
public class VoiceTextIllegalStateException extends RuntimeException {
public VoiceTextIllegalStateException(Exception e) {
super(e);
}
}
|
0 | java-sources/am/ik/voicetext/voicetext4j/1.0.0/am/ik/voicetext4j | java-sources/am/ik/voicetext/voicetext4j/1.0.0/am/ik/voicetext4j/http/VoiceTextResponse.java | /*
* Copyright (C) 2014-2016 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Copyright (C) 2014 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.voicetext4j.http;
import javax.sound.sampled.*;
import java.io.IOException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CountDownLatch;
public class VoiceTextResponse {
final AudioInputStream audioInputStream;
public VoiceTextResponse(AudioInputStream audioInputStream) {
this.audioInputStream = audioInputStream;
}
public AudioInputStream audioInputStream() {
return audioInputStream;
}
public Clip clip() {
AudioFormat format = audioInputStream.getFormat();
DataLine.Info info = new DataLine.Info(Clip.class, format);
try {
Clip clip = (Clip) AudioSystem.getLine(info);
clip.open(audioInputStream);
return clip;
} catch (LineUnavailableException | IOException e) {
throw new VoiceTextIllegalStateException(e);
}
}
public CompletableFuture<Void> play() {
Clip clip = clip();
CompletableFuture<Void> future = new CompletableFuture<Void>()
.whenComplete((x, e) -> clip.close());
clip.addLineListener(event -> {
if (event.getType() == LineEvent.Type.STOP) {
future.complete(null);
}
});
clip.start();
return future;
}
}
|
0 | java-sources/am/ik/voicetext/voicetext4j/1.0.0/am/ik/voicetext4j | java-sources/am/ik/voicetext/voicetext4j/1.0.0/am/ik/voicetext4j/http/VoiceTextUrlConnectionClient.java | /*
* Copyright (C) 2014-2016 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Copyright (C) 2014 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.voicetext4j.http;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;
import javax.xml.bind.DatatypeConverter;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
public class VoiceTextUrlConnectionClient {
static final int CONNECT_TIMEOUT_MILLIS = 15 * 1000; // 15s
static final int READ_TIMEOUT_MILLIS = 20 * 1000; // 20s
static final int CHUNK_SIZE = 4096;
static final String API_ENDPOINT = System.getProperty("voicetext.endpoint", "https://api.voicetext.jp/v1/tts");
HttpURLConnection openConnection() throws IOException {
HttpURLConnection connection = (HttpURLConnection) new URL(API_ENDPOINT).openConnection();
connection.setConnectTimeout(CONNECT_TIMEOUT_MILLIS);
connection.setReadTimeout(READ_TIMEOUT_MILLIS);
return connection;
}
void prepareRequest(HttpURLConnection connection, VoiceTextFields fieldsBuilder) throws IOException {
connection.setRequestMethod("POST");
connection.setChunkedStreamingMode(CHUNK_SIZE);
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
connection.setRequestProperty("User-Agent", "VoiceText4J");
connection.setDoOutput(true);
connection.getOutputStream().write(fieldsBuilder.getBody());
}
AudioInputStream readResponse(HttpURLConnection connection) throws IOException {
int status = connection.getResponseCode();
String reason = connection.getResponseMessage();
if (reason == null) reason = ""; // HttpURLConnection treats empty reason as null.
InputStream stream;
if (status >= 400) {
throw new VoiceTextApiCallException(status, reason);
} else {
stream = connection.getInputStream();
}
try {
return AudioSystem.getAudioInputStream(new BufferedInputStream(stream));
} catch (UnsupportedAudioFileException e) {
throw new VoiceTextIllegalStateException(e);
}
}
public VoiceTextResponse execute(VoiceTextFields fields, String apiKey) {
try {
HttpURLConnection connection = openConnection();
connection.setRequestProperty("Authorization", "Basic " + DatatypeConverter.printBase64Binary((apiKey + ":").getBytes()));
prepareRequest(connection, fields);
return new VoiceTextResponse(readResponse(connection));
} catch (IOException e) {
throw new VoiceTextIllegalStateException(e);
}
}
}
|
0 | java-sources/am/ik/webhook/webhook-verifier/0.1.2/am/ik | java-sources/am/ik/webhook/webhook-verifier/0.1.2/am/ik/webhook/Hex.java | package am.ik.webhook;
class Hex {
public static String encodeHex(byte[] data) {
final StringBuilder sb = new StringBuilder();
for (byte datum : data) {
sb.append(toHex(datum));
}
return sb.toString();
}
static String toHex(byte b) {
final char[] hex = new char[2];
hex[0] = Character.forDigit((b >> 4) & 0xF, 16);
hex[1] = Character.forDigit((b & 0xF), 16);
return new String(hex).toLowerCase();
}
}
|
0 | java-sources/am/ik/webhook/webhook-verifier/0.1.2/am/ik | java-sources/am/ik/webhook/webhook-verifier/0.1.2/am/ik/webhook/HmacWebhookSigner.java | package am.ik.webhook;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import static java.util.Objects.requireNonNull;
public final class HmacWebhookSigner implements WebhookSigner {
private final Mac hmac;
private final String algorithmName;
public HmacWebhookSigner(String algorithmName, String secret) {
final String hmacAlgorithmName = "Hmac"
+ requireNonNull(algorithmName, "'algorithmName' must not be null").toUpperCase();
try {
final SecretKeySpec signingKey = new SecretKeySpec(
requireNonNull(secret, "'secret' must not be null").getBytes(), hmacAlgorithmName);
this.hmac = Mac.getInstance(hmacAlgorithmName);
this.hmac.init(signingKey);
}
catch (NoSuchAlgorithmException | InvalidKeyException e) {
throw new IllegalArgumentException(e);
}
this.algorithmName = algorithmName.toLowerCase();
}
@Override
public String sign(byte[] payload, Encoder encoder) {
final byte[] sig = this.hmac.doFinal(requireNonNull(payload, "'payload' must not be null"));
return this.algorithmName + "=" + encoder.encode(sig);
}
}
|
0 | java-sources/am/ik/webhook/webhook-verifier/0.1.2/am/ik | java-sources/am/ik/webhook/webhook-verifier/0.1.2/am/ik/webhook/WebhookAuthenticationException.java | package am.ik.webhook;
/**
* Exception raised when a github webhook message is received but its HMAC signature does
* not match the one computed with the shared secret.
*/
public class WebhookAuthenticationException extends RuntimeException {
public WebhookAuthenticationException(String actual) {
super(String.format("Could not verify signature: '%s'", actual));
}
} |
0 | java-sources/am/ik/webhook/webhook-verifier/0.1.2/am/ik | java-sources/am/ik/webhook/webhook-verifier/0.1.2/am/ik/webhook/WebhookHttpHeaders.java | package am.ik.webhook;
public class WebhookHttpHeaders {
public static final String X_HUB_SIGNATURE = "X-Hub-Signature";
public static final String X_HUB_SIGNATURE_256 = "X-Hub-Signature-256";
}
|
0 | java-sources/am/ik/webhook/webhook-verifier/0.1.2/am/ik | java-sources/am/ik/webhook/webhook-verifier/0.1.2/am/ik/webhook/WebhookSigner.java | package am.ik.webhook;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.Objects;
@FunctionalInterface
public interface WebhookSigner {
default String sign(String payload, Encoder encoder) {
return this.sign(Objects.requireNonNull(payload, "'payload' must not be null").getBytes(StandardCharsets.UTF_8),
encoder);
}
String sign(byte[] payload, Encoder encoder);
static WebhookSigner hmacSha1(String secret) {
return new HmacWebhookSigner("SHA1", secret);
}
static WebhookSigner hmacSha256(String secret) {
return new HmacWebhookSigner("SHA256", secret);
}
static WebhookSigner hmacSha512(String secret) {
return new HmacWebhookSigner("SHA512", secret);
}
@FunctionalInterface
interface Encoder {
String encode(byte[] data);
Encoder HEX = Hex::encodeHex;
Encoder BASE64 = data -> Base64.getEncoder().encodeToString(data);
}
}
|
0 | java-sources/am/ik/webhook/webhook-verifier/0.1.2/am/ik | java-sources/am/ik/webhook/webhook-verifier/0.1.2/am/ik/webhook/WebhookVerifier.java | package am.ik.webhook;
import java.nio.charset.StandardCharsets;
import java.util.function.Supplier;
import java.util.logging.Logger;
import am.ik.webhook.WebhookSigner.Encoder;
public final class WebhookVerifier {
private final Logger log = Logger.getLogger(WebhookVerifier.class.getName());
private final WebhookSigner signer;
private final Encoder encoder;
public WebhookVerifier(WebhookSigner signer, Encoder encoder) {
this.signer = signer;
this.encoder = encoder;
}
public void verify(String payload, String signature) {
String computedSignature = this.sign(payload);
this.verifySignature(computedSignature, signature, () -> payload);
}
public void verify(byte[] payload, String signature) {
String computedSignature = this.sign(payload);
this.verifySignature(computedSignature, signature, () -> new String(payload, StandardCharsets.UTF_8));
}
private void verifySignature(String computedSignature, String signature, Supplier<String> payloadSupplier) {
if (!computedSignature.equalsIgnoreCase(signature)) {
log.warning(() -> "Failed to verify payload (payload=%s, computedSignature=%s, signature=%s)"
.formatted(payloadSupplier.get(), computedSignature, signature));
throw new WebhookAuthenticationException(signature);
}
}
public String sign(String payload) {
return this.signer.sign(payload, this.encoder);
}
public String sign(byte[] payload) {
return this.signer.sign(payload, this.encoder);
}
public static WebhookVerifier gitHubSha1(String secret) {
return new WebhookVerifier(WebhookSigner.hmacSha1(secret), Encoder.HEX);
}
public static WebhookVerifier gitHubSha256(String secret) {
return new WebhookVerifier(WebhookSigner.hmacSha256(secret), Encoder.HEX);
}
}
|
0 | java-sources/am/ik/webhook/webhook-verifier/0.1.2/am/ik/webhook | java-sources/am/ik/webhook/webhook-verifier/0.1.2/am/ik/webhook/annotation/WebhookPayload.java | package am.ik.webhook.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface WebhookPayload {
}
|
0 | java-sources/am/ik/webhook/webhook-verifier/0.1.2/am/ik/webhook | java-sources/am/ik/webhook/webhook-verifier/0.1.2/am/ik/webhook/spring/WebhookVerifierRequestBodyAdvice.java | package am.ik.webhook.spring;
import java.lang.reflect.Type;
import java.util.function.Function;
import java.util.logging.Logger;
import am.ik.webhook.WebhookAuthenticationException;
import am.ik.webhook.WebhookHttpHeaders;
import am.ik.webhook.WebhookVerifier;
import am.ik.webhook.annotation.WebhookPayload;
import org.springframework.core.MethodParameter;
import org.springframework.http.HttpInputMessage;
import org.springframework.http.HttpStatus;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.server.ResponseStatusException;
import org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdviceAdapter;
@ControllerAdvice
public class WebhookVerifierRequestBodyAdvice extends RequestBodyAdviceAdapter {
private final WebhookVerifier webhookVerifier;
private final String signatureHeaderName;
private final Logger log = Logger.getLogger(WebhookVerifierRequestBodyAdvice.class.getName());
public static WebhookVerifierRequestBodyAdvice githubSha1(String secret) {
return new WebhookVerifierRequestBodyAdvice(WebhookVerifier::gitHubSha1, secret,
WebhookHttpHeaders.X_HUB_SIGNATURE);
}
public static WebhookVerifierRequestBodyAdvice githubSha256(String secret) {
return new WebhookVerifierRequestBodyAdvice(WebhookVerifier::gitHubSha256, secret,
WebhookHttpHeaders.X_HUB_SIGNATURE_256);
}
public WebhookVerifierRequestBodyAdvice(Function<String, WebhookVerifier> webhookVerifierFactory, String secret,
String signatureHeaderName) {
this.signatureHeaderName = signatureHeaderName;
this.webhookVerifier = webhookVerifierFactory.apply(secret);
}
@Override
public boolean supports(MethodParameter methodParameter, Type targetType,
Class<? extends HttpMessageConverter<?>> converterType) {
final boolean hasWebhookPayload = methodParameter.hasParameterAnnotation(WebhookPayload.class);
if (hasWebhookPayload) {
if (String.class.equals(targetType) || byte[].class.equals(targetType)) {
return true;
}
else {
log.warning(
() -> "@WebhookPayload is found but the type (%s) is not supported. Only String and byte[] are supported as a payload type."
.formatted(targetType));
}
}
return false;
}
@Override
public Object afterBodyRead(Object body, HttpInputMessage inputMessage, MethodParameter parameter, Type targetType,
Class<? extends HttpMessageConverter<?>> converterType) {
final String signature = inputMessage.getHeaders().getFirst(this.signatureHeaderName);
if (!StringUtils.hasLength(signature)) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST,
"The signature header '%s' is missing or blank.".formatted(this.signatureHeaderName));
}
log.info(() -> "Verify if the payload signature is '%s'".formatted(signature));
try {
if (body instanceof final String payload) {
this.webhookVerifier.verify(payload, signature);
}
else if (body instanceof final byte[] payload) {
this.webhookVerifier.verify(payload, signature);
}
else {
throw new IllegalStateException("Only String and byte[] are supported as a payload type.");
}
}
catch (WebhookAuthenticationException e) {
throw new ResponseStatusException(HttpStatus.FORBIDDEN, e.getMessage(), e);
}
return body;
}
}
|
0 | java-sources/am/ik/woothee/woothee-spring/1.0.0/am/ik | java-sources/am/ik/woothee/woothee-spring/1.0.0/am/ik/woothee/Woothee.java | /*
*Copyright (C) 2014 Toshiaki Maki <makingx@gmail.com>
*
*Licensed under the Apache License, Version 2.0 (the "License");
*you may not use this file except in compliance with the License.
*You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*Unless required by applicable law or agreed to in writing, software
*distributed under the License is distributed on an "AS IS" BASIS,
*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*See the License for the specific language governing permissions and
*limitations under the License.
*/
package am.ik.woothee;
import java.io.Serializable;
/**
* The class stores information from {@link is.tagomor.woothee.Classifier#parse(java.lang.String)} and User-Agent.
*/
public class Woothee implements Serializable {
private final String category;
private final String name;
private final String version;
private final String os;
private final String vendor;
private final String osVersion;
private final String userAgent;
public Woothee(String category, String name, String version, String os, String vendor, String osVersion, String userAgent) {
this.category = category;
this.name = name;
this.version = version;
this.os = os;
this.vendor = vendor;
this.osVersion = osVersion;
this.userAgent = userAgent;
}
public String getCategory() {
return category;
}
public String getName() {
return name;
}
public String getVersion() {
return version;
}
public String getOs() {
return os;
}
public String getVendor() {
return vendor;
}
public String getOsVersion() {
return osVersion;
}
public String getUserAgent() {
return userAgent;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("WootheeData{");
sb.append("category='").append(category).append('\'');
sb.append(", name='").append(name).append('\'');
sb.append(", version='").append(version).append('\'');
sb.append(", os='").append(os).append('\'');
sb.append(", vendor=").append(vendor);
sb.append(", osVersion=").append(osVersion);
sb.append('}');
return sb.toString();
}
}
|
0 | java-sources/am/ik/woothee/woothee-spring/1.0.0/am/ik/woothee | java-sources/am/ik/woothee/woothee-spring/1.0.0/am/ik/woothee/spring/WootheeMethodArgumentResolver.java | /*
*Copyright (C) 2014 Toshiaki Maki <makingx@gmail.com>
*
*Licensed under the Apache License, Version 2.0 (the "License");
*you may not use this file except in compliance with the License.
*You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*Unless required by applicable law or agreed to in writing, software
*distributed under the License is distributed on an "AS IS" BASIS,
*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*See the License for the specific language governing permissions and
*limitations under the License.
*/
package am.ik.woothee.spring;
import am.ik.woothee.Woothee;
import is.tagomor.woothee.Classifier;
import org.springframework.core.MethodParameter;
import org.springframework.web.bind.support.WebDataBinderFactory;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.method.support.ModelAndViewContainer;
import java.util.Map;
/**
* Resolves {@link am.ik.woothee.Woothee} method arguments.
*/
public class WootheeMethodArgumentResolver implements HandlerMethodArgumentResolver {
@Override
public boolean supportsParameter(MethodParameter parameter) {
Class<?> paramType = parameter.getParameterType();
return Woothee.class.isAssignableFrom(paramType);
}
@Override
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
String userAgent = webRequest.getHeader("User-Agent");
Map<String, String> result = Classifier.parse(userAgent);
String category = result.get("category");
String name = result.get("name");
String version = result.get("version");
String os = result.get("os");
String vendor = result.get("vendor");
String osVersion = result.get("os_version");
return new Woothee(category, name, version, os, vendor, osVersion, userAgent);
}
}
|
0 | java-sources/am/ik/wws/wws-java/0.1.2/am/ik | java-sources/am/ik/wws/wws-java/0.1.2/am/ik/wws/Cache.java | /*
* Copyright (C) 2023 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.wws;
import java.util.Collections;
import java.util.Map;
import java.util.Optional;
import am.ik.json.JsonObject;
public final class Cache {
private final Map<String, String> cache;
Cache(Map<String, String> cache) {
this.cache = cache;
}
public Optional<String> get(String key) {
return Optional.ofNullable(this.cache.get(key));
}
public Cache put(String key, String value) {
this.cache.put(key, value);
return this;
}
public Cache remove(String key) {
this.cache.remove(key);
return this;
}
public int size() {
return this.cache.size();
}
public Map<String, String> asMap() {
return Collections.unmodifiableMap(this.cache);
}
public JsonObject toJson() {
return Worker.mapToObject(this.cache);
}
@Override
public String toString() {
return "Cache{" + cache + '}';
}
}
|
0 | java-sources/am/ik/wws/wws-java/0.1.2/am/ik | java-sources/am/ik/wws/wws-java/0.1.2/am/ik/wws/Request.java | /*
* Copyright (C) 2023 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.wws;
import java.net.URI;
import java.util.Collections;
import java.util.Map;
import java.util.Optional;
import am.ik.json.JsonObject;
public class Request {
public enum Method {
GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS
}
private final URI url;
private final Method method;
private final Map<String, String> headers;
private final String body;
private final Map<String, String> routeParams;
public Request(URI url, Method method, Map<String, String> headers, String body, Map<String, String> routeParams) {
this.url = url;
this.method = method;
this.headers = headers;
this.body = body;
this.routeParams = routeParams;
}
public static Request fromJson(JsonObject json) {
final JsonObject headers = json.get("headers").asObject();
final JsonObject params = json.get("params").asObject();
final String url = json.get("url").asString();
final String method = json.get("method").asString();
return new Request(URI.create(url == null ? "" : url), method == null ? null : Method.valueOf(method),
Collections.unmodifiableMap(Worker.objectToMap(headers)), json.get("body").asString(),
Collections.unmodifiableMap(Worker.objectToMap(params)));
}
public URI url() {
return this.url;
}
public Method method() {
return this.method;
}
public Map<String, String> headers() {
return this.headers;
}
public Optional<String> header(String name) {
return Optional.ofNullable(this.headers.get(name));
}
public String body() {
return this.body;
}
public Map<String, String> routeParams() {
return this.routeParams;
}
public Optional<String> routeParam(String name) {
return Optional.ofNullable(this.routeParams.get(name));
}
@Override
public String toString() {
return "Request{" + "url='" + url + '\'' + ", method='" + method + '\'' + ", headers=" + headers + ", body='"
+ body + '\'' + ", params=" + routeParams + '}';
}
}
|
0 | java-sources/am/ik/wws/wws-java/0.1.2/am/ik | java-sources/am/ik/wws/wws-java/0.1.2/am/ik/wws/Response.java | /*
* Copyright (C) 2023 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.wws;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import am.ik.json.JsonObject;
public class Response {
private final String data;
private final Map<String, String> headers;
private final int status;
private final boolean base64;
public static Builder status(int status) {
return new Builder(status);
}
public Response(String data, Map<String, String> headers, int status, boolean base64) {
this.data = data == null ? "" : data;
this.headers = headers == null ? Collections.emptyMap() : headers;
this.status = status;
this.base64 = base64;
}
private JsonObject toJsonPartial() {
return new JsonObject().put("data", this.data)
.put("status", this.status)
.put("base64", this.base64)
.put("headers", Worker.mapToObject(this.headers));
}
public JsonObject toJson() {
return this.toJsonPartial().put("kv", new JsonObject());
}
public JsonObject toJson(Cache cache) {
return this.toJsonPartial().put("kv", cache.toJson());
}
@Override
public String toString() {
return "Response{" + "data='" + data + '\'' + ", headers=" + headers + ", status=" + status + ", base64="
+ base64 + '}';
}
public static class Builder {
private String data;
private Map<String, String> headers;
private final int status;
private boolean base64;
public Builder(int status) {
this.status = status;
}
public Builder data(String data) {
this.data = data;
return this;
}
public Builder data(byte[] data) {
// TODO base64 encode when data is not UTF-8
return this.data(new String(data, StandardCharsets.UTF_8));
}
public Builder headers(Map<String, String> headers) {
this.headers = headers;
return this;
}
public Builder header(String name, String value) {
if (this.headers == null) {
this.headers = new LinkedHashMap<>();
}
this.headers.put(name, value);
return this;
}
public Builder base64(boolean base64) {
this.base64 = base64;
return this;
}
public Response build() {
return new Response(this.data, this.headers, this.status, this.base64);
}
}
}
|
0 | java-sources/am/ik/wws/wws-java/0.1.2/am/ik | java-sources/am/ik/wws/wws-java/0.1.2/am/ik/wws/Worker.java | /*
* Copyright (C) 2023 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.wws;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.function.BiFunction;
import java.util.function.Function;
import am.ik.json.Json;
import am.ik.json.JsonObject;
public class Worker {
private final InputStream in;
private final PrintStream out;
public Worker(InputStream in, PrintStream out) {
this.in = in;
this.out = out;
}
public static void serve(Function<Request, Response> handler) {
final Worker worker = new Worker(System.in, System.out);
worker.doServe(handler);
}
public static void serve(BiFunction<Request, Cache, Response> handler) {
final Worker worker = new Worker(System.in, System.out);
worker.doServe(handler);
}
public void doServe(Function<Request, Response> handler) {
final JsonObject json = Json.parse(copyToString(this.in)).asObject();
final Request request = Request.fromJson(json);
final Response response = handler.apply(request);
this.out.println(Json.stringify(response.toJson()));
}
public void doServe(BiFunction<Request, Cache, Response> handler) {
final JsonObject json = Json.parse(copyToString(this.in)).asObject();
final Request request = Request.fromJson(json);
final Cache cache = new Cache(objectToMap(json.get("kv").asObject()));
final Response response = handler.apply(request, cache);
this.out.println(Json.stringify(response.toJson(cache)));
}
private static String copyToString(InputStream in) {
if (in == null) {
return "";
}
final StringBuilder out = new StringBuilder();
final InputStreamReader reader = new InputStreamReader(in, StandardCharsets.UTF_8);
final char[] buffer = new char[256];
int charsRead;
try {
while ((charsRead = reader.read(buffer)) != -1) {
out.append(buffer, 0, charsRead);
}
}
catch (IOException e) {
throw new RuntimeException(e);
}
return out.toString();
}
// utilities
static Map<String, String> objectToMap(JsonObject object) {
if (object == null) {
return new LinkedHashMap<>();
}
final Map<String, String> map = new HashMap<>();
object.asMap().forEach((k, v) -> map.put(k, v.asString()));
return map;
}
static JsonObject mapToObject(Map<String, String> map) {
if (map == null) {
return new JsonObject();
}
final JsonObject object = new JsonObject();
map.forEach(object::put);
return object;
}
}
|
0 | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi/arguments/Arguments.java | /*
* Copyright (C) 2018-2025 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.yavi.arguments;
import am.ik.yavi.jsr305.Nullable;
/**
* Generated by https://github.com/making/yavi/blob/develop/scripts/generate-args.sh
*
* @since 0.3.0
*/
public final class Arguments {
public static <A1> Arguments1<A1> of(@Nullable A1 arg1) {
return new Arguments1<>(arg1);
}
public static <A1, A2> Arguments2<A1, A2> of(@Nullable A1 arg1, @Nullable A2 arg2) {
return new Arguments2<>(arg1, arg2);
}
public static <A1, A2, A3> Arguments3<A1, A2, A3> of(@Nullable A1 arg1, @Nullable A2 arg2, @Nullable A3 arg3) {
return new Arguments3<>(arg1, arg2, arg3);
}
public static <A1, A2, A3, A4> Arguments4<A1, A2, A3, A4> of(@Nullable A1 arg1, @Nullable A2 arg2,
@Nullable A3 arg3, @Nullable A4 arg4) {
return new Arguments4<>(arg1, arg2, arg3, arg4);
}
public static <A1, A2, A3, A4, A5> Arguments5<A1, A2, A3, A4, A5> of(@Nullable A1 arg1, @Nullable A2 arg2,
@Nullable A3 arg3, @Nullable A4 arg4, @Nullable A5 arg5) {
return new Arguments5<>(arg1, arg2, arg3, arg4, arg5);
}
public static <A1, A2, A3, A4, A5, A6> Arguments6<A1, A2, A3, A4, A5, A6> of(@Nullable A1 arg1, @Nullable A2 arg2,
@Nullable A3 arg3, @Nullable A4 arg4, @Nullable A5 arg5, @Nullable A6 arg6) {
return new Arguments6<>(arg1, arg2, arg3, arg4, arg5, arg6);
}
public static <A1, A2, A3, A4, A5, A6, A7> Arguments7<A1, A2, A3, A4, A5, A6, A7> of(@Nullable A1 arg1,
@Nullable A2 arg2, @Nullable A3 arg3, @Nullable A4 arg4, @Nullable A5 arg5, @Nullable A6 arg6,
@Nullable A7 arg7) {
return new Arguments7<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7);
}
public static <A1, A2, A3, A4, A5, A6, A7, A8> Arguments8<A1, A2, A3, A4, A5, A6, A7, A8> of(@Nullable A1 arg1,
@Nullable A2 arg2, @Nullable A3 arg3, @Nullable A4 arg4, @Nullable A5 arg5, @Nullable A6 arg6,
@Nullable A7 arg7, @Nullable A8 arg8) {
return new Arguments8<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
}
public static <A1, A2, A3, A4, A5, A6, A7, A8, A9> Arguments9<A1, A2, A3, A4, A5, A6, A7, A8, A9> of(
@Nullable A1 arg1, @Nullable A2 arg2, @Nullable A3 arg3, @Nullable A4 arg4, @Nullable A5 arg5,
@Nullable A6 arg6, @Nullable A7 arg7, @Nullable A8 arg8, @Nullable A9 arg9) {
return new Arguments9<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
}
public static <A1, A2, A3, A4, A5, A6, A7, A8, A9, A10> Arguments10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10> of(
@Nullable A1 arg1, @Nullable A2 arg2, @Nullable A3 arg3, @Nullable A4 arg4, @Nullable A5 arg5,
@Nullable A6 arg6, @Nullable A7 arg7, @Nullable A8 arg8, @Nullable A9 arg9, @Nullable A10 arg10) {
return new Arguments10<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
}
public static <A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11> Arguments11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11> of(
@Nullable A1 arg1, @Nullable A2 arg2, @Nullable A3 arg3, @Nullable A4 arg4, @Nullable A5 arg5,
@Nullable A6 arg6, @Nullable A7 arg7, @Nullable A8 arg8, @Nullable A9 arg9, @Nullable A10 arg10,
@Nullable A11 arg11) {
return new Arguments11<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11);
}
public static <A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12> Arguments12<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12> of(
@Nullable A1 arg1, @Nullable A2 arg2, @Nullable A3 arg3, @Nullable A4 arg4, @Nullable A5 arg5,
@Nullable A6 arg6, @Nullable A7 arg7, @Nullable A8 arg8, @Nullable A9 arg9, @Nullable A10 arg10,
@Nullable A11 arg11, @Nullable A12 arg12) {
return new Arguments12<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12);
}
public static <A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13> Arguments13<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13> of(
@Nullable A1 arg1, @Nullable A2 arg2, @Nullable A3 arg3, @Nullable A4 arg4, @Nullable A5 arg5,
@Nullable A6 arg6, @Nullable A7 arg7, @Nullable A8 arg8, @Nullable A9 arg9, @Nullable A10 arg10,
@Nullable A11 arg11, @Nullable A12 arg12, @Nullable A13 arg13) {
return new Arguments13<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13);
}
public static <A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14> Arguments14<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14> of(
@Nullable A1 arg1, @Nullable A2 arg2, @Nullable A3 arg3, @Nullable A4 arg4, @Nullable A5 arg5,
@Nullable A6 arg6, @Nullable A7 arg7, @Nullable A8 arg8, @Nullable A9 arg9, @Nullable A10 arg10,
@Nullable A11 arg11, @Nullable A12 arg12, @Nullable A13 arg13, @Nullable A14 arg14) {
return new Arguments14<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13,
arg14);
}
public static <A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15> Arguments15<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15> of(
@Nullable A1 arg1, @Nullable A2 arg2, @Nullable A3 arg3, @Nullable A4 arg4, @Nullable A5 arg5,
@Nullable A6 arg6, @Nullable A7 arg7, @Nullable A8 arg8, @Nullable A9 arg9, @Nullable A10 arg10,
@Nullable A11 arg11, @Nullable A12 arg12, @Nullable A13 arg13, @Nullable A14 arg14, @Nullable A15 arg15) {
return new Arguments15<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13,
arg14, arg15);
}
public static <A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16> Arguments16<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16> of(
@Nullable A1 arg1, @Nullable A2 arg2, @Nullable A3 arg3, @Nullable A4 arg4, @Nullable A5 arg5,
@Nullable A6 arg6, @Nullable A7 arg7, @Nullable A8 arg8, @Nullable A9 arg9, @Nullable A10 arg10,
@Nullable A11 arg11, @Nullable A12 arg12, @Nullable A13 arg13, @Nullable A14 arg14, @Nullable A15 arg15,
@Nullable A16 arg16) {
return new Arguments16<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13,
arg14, arg15, arg16);
}
}
|
0 | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi/arguments/Arguments1.java | /*
* Copyright (C) 2018-2025 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.yavi.arguments;
import java.util.Objects;
import am.ik.yavi.fn.Function1;
import am.ik.yavi.jsr305.Nullable;
/**
* A container class that holds 1 arguments, providing type-safe access to each argument
* and mapping functionality to transform these arguments.
*
* Generated by https://github.com/making/yavi/blob/develop/scripts/generate-args.sh
*
* @param <A1> the type of argument at position 1
* @since 0.3.0
*/
public final class Arguments1<A1> {
private final A1 arg1;
/**
* Creates a new Arguments1 instance with the provided arguments.
* @param arg1 the argument at position 1
*/
Arguments1(@Nullable A1 arg1) {
this.arg1 = arg1;
}
/**
* Returns the argument at position 1.
* @return the argument at position 1
*/
@Nullable
public A1 arg1() {
return this.arg1;
}
/**
* Applies the provided mapping function to all arguments contained in this instance.
* @param <X> the type of the result
* @param mapper the function to apply to the arguments
* @return the result of applying the mapper function to the arguments
*/
public <X> X map(Function1<? super A1, ? extends X> mapper) {
return mapper.apply(arg1);
}
/**
* Appends an additional argument to create a new, larger Arguments instance.
* @param <B> the type of the argument to append
* @param arg the argument to append
* @return a new Arguments2 instance with the additional argument
* @since 0.16.0
*/
public <B> Arguments2<A1, B> append(@Nullable B arg) {
return new Arguments2<>(this.arg1, arg);
}
/**
* Prepends an additional argument to create a new, larger Arguments instance.
* @param <B> the type of the argument to prepend
* @param arg the argument to prepend
* @return a new Arguments2 instance with the additional argument
* @since 0.16.0
*/
public <B> Arguments2<B, A1> prepend(@Nullable B arg) {
return new Arguments2<>(arg, this.arg1);
}
/**
* Indicates whether some other object is "equal to" this one.
* @param obj the reference object with which to compare
* @return true if this object is the same as the obj argument; false otherwise
*/
@Override
@SuppressWarnings("unchecked")
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
Arguments1<A1> that = (Arguments1<A1>) obj;
return Objects.equals(this.arg1, that.arg1);
}
/**
* Returns a hash code value for the object.
* @return a hash code value for this object
*/
@Override
public int hashCode() {
return Objects.hash(this.arg1);
}
/**
* Returns a string representation of the object.
* @return a string representation of the object
*/
@Override
public String toString() {
return "Arguments1{" + "arg1=" + this.arg1 + "}";
}
}
|
0 | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi/arguments/Arguments10.java | /*
* Copyright (C) 2018-2025 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.yavi.arguments;
import java.util.Objects;
import am.ik.yavi.fn.Function10;
import am.ik.yavi.jsr305.Nullable;
/**
* A container class that holds 10 arguments, providing type-safe access to each argument
* and mapping functionality to transform these arguments.
*
* Generated by https://github.com/making/yavi/blob/develop/scripts/generate-args.sh
*
* @param <A1> the type of argument at position 1
* @param <A2> the type of argument at position 2
* @param <A3> the type of argument at position 3
* @param <A4> the type of argument at position 4
* @param <A5> the type of argument at position 5
* @param <A6> the type of argument at position 6
* @param <A7> the type of argument at position 7
* @param <A8> the type of argument at position 8
* @param <A9> the type of argument at position 9
* @param <A10> the type of argument at position 10
* @since 0.3.0
*/
public final class Arguments10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10> {
private final A1 arg1;
private final A2 arg2;
private final A3 arg3;
private final A4 arg4;
private final A5 arg5;
private final A6 arg6;
private final A7 arg7;
private final A8 arg8;
private final A9 arg9;
private final A10 arg10;
/**
* Creates a new Arguments10 instance with the provided arguments.
* @param arg1 the argument at position 1, arg2 the argument at position 2, arg3 the
* argument at position 3, arg4 the argument at position 4, arg5 the argument at
* position 5, arg6 the argument at position 6, arg7 the argument at position 7, arg8
* the argument at position 8, arg9 the argument at position 9, arg10 the argument at
* position 10
*/
Arguments10(@Nullable A1 arg1, @Nullable A2 arg2, @Nullable A3 arg3, @Nullable A4 arg4, @Nullable A5 arg5,
@Nullable A6 arg6, @Nullable A7 arg7, @Nullable A8 arg8, @Nullable A9 arg9, @Nullable A10 arg10) {
this.arg1 = arg1;
this.arg2 = arg2;
this.arg3 = arg3;
this.arg4 = arg4;
this.arg5 = arg5;
this.arg6 = arg6;
this.arg7 = arg7;
this.arg8 = arg8;
this.arg9 = arg9;
this.arg10 = arg10;
}
/**
* Returns the argument at position 1.
* @return the argument at position 1
*/
@Nullable
public A1 arg1() {
return this.arg1;
}
/**
* Returns the argument at position 2.
* @return the argument at position 2
*/
@Nullable
public A2 arg2() {
return this.arg2;
}
/**
* Returns the argument at position 3.
* @return the argument at position 3
*/
@Nullable
public A3 arg3() {
return this.arg3;
}
/**
* Returns the argument at position 4.
* @return the argument at position 4
*/
@Nullable
public A4 arg4() {
return this.arg4;
}
/**
* Returns the argument at position 5.
* @return the argument at position 5
*/
@Nullable
public A5 arg5() {
return this.arg5;
}
/**
* Returns the argument at position 6.
* @return the argument at position 6
*/
@Nullable
public A6 arg6() {
return this.arg6;
}
/**
* Returns the argument at position 7.
* @return the argument at position 7
*/
@Nullable
public A7 arg7() {
return this.arg7;
}
/**
* Returns the argument at position 8.
* @return the argument at position 8
*/
@Nullable
public A8 arg8() {
return this.arg8;
}
/**
* Returns the argument at position 9.
* @return the argument at position 9
*/
@Nullable
public A9 arg9() {
return this.arg9;
}
/**
* Returns the argument at position 10.
* @return the argument at position 10
*/
@Nullable
public A10 arg10() {
return this.arg10;
}
/**
* Applies the provided mapping function to all arguments contained in this instance.
* @param <X> the type of the result
* @param mapper the function to apply to the arguments
* @return the result of applying the mapper function to the arguments
*/
public <X> X map(
Function10<? super A1, ? super A2, ? super A3, ? super A4, ? super A5, ? super A6, ? super A7, ? super A8, ? super A9, ? super A10, ? extends X> mapper) {
return mapper.apply(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
}
/**
* Returns a new Arguments1 instance containing only the first 1 arguments.
* @return an Arguments1 instance with arguments from arg1 to arg1
* @since 0.16.0
*/
public Arguments1<A1> first1() {
return new Arguments1<>(arg1);
}
/**
* Returns a new Arguments2 instance containing only the first 2 arguments.
* @return an Arguments2 instance with arguments from arg1 to arg2
* @since 0.16.0
*/
public Arguments2<A1, A2> first2() {
return new Arguments2<>(arg1, arg2);
}
/**
* Returns a new Arguments3 instance containing only the first 3 arguments.
* @return an Arguments3 instance with arguments from arg1 to arg3
* @since 0.16.0
*/
public Arguments3<A1, A2, A3> first3() {
return new Arguments3<>(arg1, arg2, arg3);
}
/**
* Returns a new Arguments4 instance containing only the first 4 arguments.
* @return an Arguments4 instance with arguments from arg1 to arg4
* @since 0.16.0
*/
public Arguments4<A1, A2, A3, A4> first4() {
return new Arguments4<>(arg1, arg2, arg3, arg4);
}
/**
* Returns a new Arguments5 instance containing only the first 5 arguments.
* @return an Arguments5 instance with arguments from arg1 to arg5
* @since 0.16.0
*/
public Arguments5<A1, A2, A3, A4, A5> first5() {
return new Arguments5<>(arg1, arg2, arg3, arg4, arg5);
}
/**
* Returns a new Arguments6 instance containing only the first 6 arguments.
* @return an Arguments6 instance with arguments from arg1 to arg6
* @since 0.16.0
*/
public Arguments6<A1, A2, A3, A4, A5, A6> first6() {
return new Arguments6<>(arg1, arg2, arg3, arg4, arg5, arg6);
}
/**
* Returns a new Arguments7 instance containing only the first 7 arguments.
* @return an Arguments7 instance with arguments from arg1 to arg7
* @since 0.16.0
*/
public Arguments7<A1, A2, A3, A4, A5, A6, A7> first7() {
return new Arguments7<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7);
}
/**
* Returns a new Arguments8 instance containing only the first 8 arguments.
* @return an Arguments8 instance with arguments from arg1 to arg8
* @since 0.16.0
*/
public Arguments8<A1, A2, A3, A4, A5, A6, A7, A8> first8() {
return new Arguments8<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
}
/**
* Returns a new Arguments9 instance containing only the first 9 arguments.
* @return an Arguments9 instance with arguments from arg1 to arg9
* @since 0.16.0
*/
public Arguments9<A1, A2, A3, A4, A5, A6, A7, A8, A9> first9() {
return new Arguments9<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
}
/**
* Returns a new Arguments1 instance containing only the last 1 arguments.
* @return an Arguments1 instance with arguments from arg10 to arg10
* @since 0.16.0
*/
public Arguments1<A10> last1() {
return new Arguments1<>(arg10);
}
/**
* Returns a new Arguments2 instance containing only the last 2 arguments.
* @return an Arguments2 instance with arguments from arg9 to arg10
* @since 0.16.0
*/
public Arguments2<A9, A10> last2() {
return new Arguments2<>(arg9, arg10);
}
/**
* Returns a new Arguments3 instance containing only the last 3 arguments.
* @return an Arguments3 instance with arguments from arg8 to arg10
* @since 0.16.0
*/
public Arguments3<A8, A9, A10> last3() {
return new Arguments3<>(arg8, arg9, arg10);
}
/**
* Returns a new Arguments4 instance containing only the last 4 arguments.
* @return an Arguments4 instance with arguments from arg7 to arg10
* @since 0.16.0
*/
public Arguments4<A7, A8, A9, A10> last4() {
return new Arguments4<>(arg7, arg8, arg9, arg10);
}
/**
* Returns a new Arguments5 instance containing only the last 5 arguments.
* @return an Arguments5 instance with arguments from arg6 to arg10
* @since 0.16.0
*/
public Arguments5<A6, A7, A8, A9, A10> last5() {
return new Arguments5<>(arg6, arg7, arg8, arg9, arg10);
}
/**
* Returns a new Arguments6 instance containing only the last 6 arguments.
* @return an Arguments6 instance with arguments from arg5 to arg10
* @since 0.16.0
*/
public Arguments6<A5, A6, A7, A8, A9, A10> last6() {
return new Arguments6<>(arg5, arg6, arg7, arg8, arg9, arg10);
}
/**
* Returns a new Arguments7 instance containing only the last 7 arguments.
* @return an Arguments7 instance with arguments from arg4 to arg10
* @since 0.16.0
*/
public Arguments7<A4, A5, A6, A7, A8, A9, A10> last7() {
return new Arguments7<>(arg4, arg5, arg6, arg7, arg8, arg9, arg10);
}
/**
* Returns a new Arguments8 instance containing only the last 8 arguments.
* @return an Arguments8 instance with arguments from arg3 to arg10
* @since 0.16.0
*/
public Arguments8<A3, A4, A5, A6, A7, A8, A9, A10> last8() {
return new Arguments8<>(arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
}
/**
* Returns a new Arguments9 instance containing only the last 9 arguments.
* @return an Arguments9 instance with arguments from arg2 to arg10
* @since 0.16.0
*/
public Arguments9<A2, A3, A4, A5, A6, A7, A8, A9, A10> last9() {
return new Arguments9<>(arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
}
/**
* Appends an additional argument to create a new, larger Arguments instance.
* @param <B> the type of the argument to append
* @param arg the argument to append
* @return a new Arguments11 instance with the additional argument
* @since 0.16.0
*/
public <B> Arguments11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, B> append(@Nullable B arg) {
return new Arguments11<>(this.arg1, this.arg2, this.arg3, this.arg4, this.arg5, this.arg6, this.arg7, this.arg8,
this.arg9, this.arg10, arg);
}
/**
* Prepends an additional argument to create a new, larger Arguments instance.
* @param <B> the type of the argument to prepend
* @param arg the argument to prepend
* @return a new Arguments11 instance with the additional argument
* @since 0.16.0
*/
public <B> Arguments11<B, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10> prepend(@Nullable B arg) {
return new Arguments11<>(arg, this.arg1, this.arg2, this.arg3, this.arg4, this.arg5, this.arg6, this.arg7,
this.arg8, this.arg9, this.arg10);
}
/**
* Returns a new Arguments10 instance with the arguments in reverse order.
* @return an Arguments10 instance with arguments in reverse order
* @since 0.16.0
*/
public Arguments10<A10, A9, A8, A7, A6, A5, A4, A3, A2, A1> reverse() {
return new Arguments10<>(arg10, arg9, arg8, arg7, arg6, arg5, arg4, arg3, arg2, arg1);
}
/**
* Indicates whether some other object is "equal to" this one.
* @param obj the reference object with which to compare
* @return true if this object is the same as the obj argument; false otherwise
*/
@Override
@SuppressWarnings("unchecked")
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
Arguments10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10> that = (Arguments10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>) obj;
return Objects.equals(this.arg1, that.arg1) && Objects.equals(this.arg2, that.arg2)
&& Objects.equals(this.arg3, that.arg3) && Objects.equals(this.arg4, that.arg4)
&& Objects.equals(this.arg5, that.arg5) && Objects.equals(this.arg6, that.arg6)
&& Objects.equals(this.arg7, that.arg7) && Objects.equals(this.arg8, that.arg8)
&& Objects.equals(this.arg9, that.arg9) && Objects.equals(this.arg10, that.arg10);
}
/**
* Returns a hash code value for the object.
* @return a hash code value for this object
*/
@Override
public int hashCode() {
return Objects.hash(this.arg1, this.arg2, this.arg3, this.arg4, this.arg5, this.arg6, this.arg7, this.arg8,
this.arg9, this.arg10);
}
/**
* Returns a string representation of the object.
* @return a string representation of the object
*/
@Override
public String toString() {
return "Arguments10{" + "arg1=" + this.arg1 + ", " + "arg2=" + this.arg2 + ", " + "arg3=" + this.arg3 + ", "
+ "arg4=" + this.arg4 + ", " + "arg5=" + this.arg5 + ", " + "arg6=" + this.arg6 + ", " + "arg7="
+ this.arg7 + ", " + "arg8=" + this.arg8 + ", " + "arg9=" + this.arg9 + ", " + "arg10=" + this.arg10
+ "}";
}
}
|
0 | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi/arguments/Arguments10Combining.java | /*
* Copyright (C) 2018-2025 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.yavi.arguments;
import am.ik.yavi.core.ConstraintContext;
import am.ik.yavi.core.Validated;
import am.ik.yavi.core.ValueValidator;
import am.ik.yavi.fn.Function10;
import am.ik.yavi.fn.Validations;
import java.util.Locale;
import java.util.function.Supplier;
/**
* Generated by https://github.com/making/yavi/blob/develop/scripts/generate-args.sh
*
* @since 0.7.0
*/
public class Arguments10Combining<A, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10> {
protected final ValueValidator<? super A, ? extends R1> v1;
protected final ValueValidator<? super A, ? extends R2> v2;
protected final ValueValidator<? super A, ? extends R3> v3;
protected final ValueValidator<? super A, ? extends R4> v4;
protected final ValueValidator<? super A, ? extends R5> v5;
protected final ValueValidator<? super A, ? extends R6> v6;
protected final ValueValidator<? super A, ? extends R7> v7;
protected final ValueValidator<? super A, ? extends R8> v8;
protected final ValueValidator<? super A, ? extends R9> v9;
protected final ValueValidator<? super A, ? extends R10> v10;
public Arguments10Combining(ValueValidator<? super A, ? extends R1> v1, ValueValidator<? super A, ? extends R2> v2,
ValueValidator<? super A, ? extends R3> v3, ValueValidator<? super A, ? extends R4> v4,
ValueValidator<? super A, ? extends R5> v5, ValueValidator<? super A, ? extends R6> v6,
ValueValidator<? super A, ? extends R7> v7, ValueValidator<? super A, ? extends R8> v8,
ValueValidator<? super A, ? extends R9> v9, ValueValidator<? super A, ? extends R10> v10) {
this.v1 = v1;
this.v2 = v2;
this.v3 = v3;
this.v4 = v4;
this.v5 = v5;
this.v6 = v6;
this.v7 = v7;
this.v8 = v8;
this.v9 = v9;
this.v10 = v10;
}
public <X> Arguments1Validator<A, X> apply(
Function10<? super R1, ? super R2, ? super R3, ? super R4, ? super R5, ? super R6, ? super R7, ? super R8, ? super R9, ? super R10, ? extends X> f) {
return new Arguments1Validator<A, X>() {
@Override
public Validated<X> validate(A a, Locale locale, ConstraintContext constraintContext) {
return Validations.apply(f::apply, Arguments10Combining.this.v1.validate(a, locale, constraintContext),
Arguments10Combining.this.v2.validate(a, locale, constraintContext),
Arguments10Combining.this.v3.validate(a, locale, constraintContext),
Arguments10Combining.this.v4.validate(a, locale, constraintContext),
Arguments10Combining.this.v5.validate(a, locale, constraintContext),
Arguments10Combining.this.v6.validate(a, locale, constraintContext),
Arguments10Combining.this.v7.validate(a, locale, constraintContext),
Arguments10Combining.this.v8.validate(a, locale, constraintContext),
Arguments10Combining.this.v9.validate(a, locale, constraintContext),
Arguments10Combining.this.v10.validate(a, locale, constraintContext));
}
@Override
public Arguments1Validator<A, Supplier<X>> lazy() {
return (a, locale, constraintContext) -> Validations.apply(
(r1, r2, r3, r4, r5, r6, r7, r8, r9,
r10) -> () -> f.apply(r1, r2, r3, r4, r5, r6, r7, r8, r9, r10),
Arguments10Combining.this.v1.validate(a, locale, constraintContext),
Arguments10Combining.this.v2.validate(a, locale, constraintContext),
Arguments10Combining.this.v3.validate(a, locale, constraintContext),
Arguments10Combining.this.v4.validate(a, locale, constraintContext),
Arguments10Combining.this.v5.validate(a, locale, constraintContext),
Arguments10Combining.this.v6.validate(a, locale, constraintContext),
Arguments10Combining.this.v7.validate(a, locale, constraintContext),
Arguments10Combining.this.v8.validate(a, locale, constraintContext),
Arguments10Combining.this.v9.validate(a, locale, constraintContext),
Arguments10Combining.this.v10.validate(a, locale, constraintContext));
}
};
}
public <R11> Arguments11Combining<A, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11> combine(
ValueValidator<? super A, ? extends R11> v11) {
return new Arguments11Combining<>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11);
}
}
|
0 | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi/arguments/Arguments10Splitting.java | /*
* Copyright (C) 2018-2025 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.yavi.arguments;
import java.util.Locale;
import java.util.function.Supplier;
import am.ik.yavi.core.ConstraintContext;
import am.ik.yavi.core.Validated;
import am.ik.yavi.core.ValueValidator;
import am.ik.yavi.fn.Function10;
import am.ik.yavi.fn.Validations;
import am.ik.yavi.jsr305.Nullable;
/**
* Generated by https://github.com/making/yavi/blob/develop/scripts/generate-args.sh
*
* @since 0.7.0
*/
public class Arguments10Splitting<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10> {
protected final ValueValidator<? super A1, ? extends R1> v1;
protected final ValueValidator<? super A2, ? extends R2> v2;
protected final ValueValidator<? super A3, ? extends R3> v3;
protected final ValueValidator<? super A4, ? extends R4> v4;
protected final ValueValidator<? super A5, ? extends R5> v5;
protected final ValueValidator<? super A6, ? extends R6> v6;
protected final ValueValidator<? super A7, ? extends R7> v7;
protected final ValueValidator<? super A8, ? extends R8> v8;
protected final ValueValidator<? super A9, ? extends R9> v9;
protected final ValueValidator<? super A10, ? extends R10> v10;
public Arguments10Splitting(ValueValidator<? super A1, ? extends R1> v1,
ValueValidator<? super A2, ? extends R2> v2, ValueValidator<? super A3, ? extends R3> v3,
ValueValidator<? super A4, ? extends R4> v4, ValueValidator<? super A5, ? extends R5> v5,
ValueValidator<? super A6, ? extends R6> v6, ValueValidator<? super A7, ? extends R7> v7,
ValueValidator<? super A8, ? extends R8> v8, ValueValidator<? super A9, ? extends R9> v9,
ValueValidator<? super A10, ? extends R10> v10) {
this.v1 = v1;
this.v2 = v2;
this.v3 = v3;
this.v4 = v4;
this.v5 = v5;
this.v6 = v6;
this.v7 = v7;
this.v8 = v8;
this.v9 = v9;
this.v10 = v10;
}
public <X> Arguments10Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, X> apply(
Function10<? super R1, ? super R2, ? super R3, ? super R4, ? super R5, ? super R6, ? super R7, ? super R8, ? super R9, ? super R10, ? extends X> f) {
return new Arguments10Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, X>() {
@Override
public Arguments10Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, Supplier<X>> lazy() {
return ((a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, locale, constraintContext) -> Validations.apply(
(r1, r2, r3, r4, r5, r6, r7, r8, r9,
r10) -> () -> f.apply(r1, r2, r3, r4, r5, r6, r7, r8, r9, r10),
v1.validate(a1, locale, constraintContext), v2.validate(a2, locale, constraintContext),
v3.validate(a3, locale, constraintContext), v4.validate(a4, locale, constraintContext),
v5.validate(a5, locale, constraintContext), v6.validate(a6, locale, constraintContext),
v7.validate(a7, locale, constraintContext), v8.validate(a8, locale, constraintContext),
v9.validate(a9, locale, constraintContext), v10.validate(a10, locale, constraintContext)));
}
@Override
public Validated<X> validate(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4,
@Nullable A5 a5, @Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9,
@Nullable A10 a10, Locale locale, ConstraintContext constraintContext) {
return Validations.apply(f::apply, v1.validate(a1, locale, constraintContext),
v2.validate(a2, locale, constraintContext), v3.validate(a3, locale, constraintContext),
v4.validate(a4, locale, constraintContext), v5.validate(a5, locale, constraintContext),
v6.validate(a6, locale, constraintContext), v7.validate(a7, locale, constraintContext),
v8.validate(a8, locale, constraintContext), v9.validate(a9, locale, constraintContext),
v10.validate(a10, locale, constraintContext));
}
};
}
public <A11, R11> Arguments11Splitting<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11> split(
ValueValidator<? super A11, ? extends R11> v11) {
return new Arguments11Splitting<>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11);
}
}
|
0 | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi/arguments/Arguments10Validator.java | /*
* Copyright (C) 2018-2025 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.yavi.arguments;
import java.util.Locale;
import java.util.Objects;
import java.util.function.Function;
import java.util.function.Supplier;
import am.ik.yavi.core.ConstraintContext;
import am.ik.yavi.core.ConstraintGroup;
import am.ik.yavi.core.ConstraintViolationsException;
import am.ik.yavi.core.Validated;
import am.ik.yavi.core.ValueValidator;
import am.ik.yavi.jsr305.Nullable;
/**
* Generated by https://github.com/making/yavi/blob/develop/scripts/generate-args.sh
*
* @since 0.3.0
*/
@FunctionalInterface
public interface Arguments10Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, X> {
/**
* Convert an Arguments1Validator that validates Arguments10 to an
* Arguments10Validator
* @param validator validator for Arguments10
* @param <A1> type of first argument
* @param <A2> type of argument at position 2
* @param <A3> type of argument at position 3
* @param <A4> type of argument at position 4
* @param <A5> type of argument at position 5
* @param <A6> type of argument at position 6
* @param <A7> type of argument at position 7
* @param <A8> type of argument at position 8
* @param <A9> type of argument at position 9
* @param <A10> type of argument at position 10
* @param <X> target result type
* @return arguments10 validator that takes arguments directly
* @since 0.16.0
*/
static <A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, X> Arguments10Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, X> unwrap(
Arguments1Validator<Arguments10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>, X> validator) {
return new Arguments10Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, X>() {
@Override
public Validated<X> validate(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4,
@Nullable A5 a5, @Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9,
@Nullable A10 a10, Locale locale, ConstraintContext constraintContext) {
return validator.validate(Arguments.of(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10), locale,
constraintContext);
}
@Override
public Arguments10Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, Supplier<X>> lazy() {
return Arguments10Validator.unwrap(validator.lazy());
}
};
}
Validated<X> validate(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4, @Nullable A5 a5,
@Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9, @Nullable A10 a10, Locale locale,
ConstraintContext constraintContext);
/**
* Convert this validator to one that validates Arguments10 as a single object.
* @return a validator that takes an Arguments10
* @since 0.16.0
*/
default Arguments1Validator<Arguments10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>, X> wrap() {
return new Arguments1Validator<Arguments10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>, X>() {
@Override
public Validated<X> validate(Arguments10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10> args, Locale locale,
ConstraintContext constraintContext) {
final Arguments10<? extends A1, ? extends A2, ? extends A3, ? extends A4, ? extends A5, ? extends A6, ? extends A7, ? extends A8, ? extends A9, ? extends A10> nonNullArgs = Objects
.requireNonNull(args);
return Arguments10Validator.this.validate(nonNullArgs.arg1(), nonNullArgs.arg2(), nonNullArgs.arg3(),
nonNullArgs.arg4(), nonNullArgs.arg5(), nonNullArgs.arg6(), nonNullArgs.arg7(),
nonNullArgs.arg8(), nonNullArgs.arg9(), nonNullArgs.arg10(), locale, constraintContext);
}
@Override
public Arguments1Validator<Arguments10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>, Supplier<X>> lazy() {
return Arguments10Validator.this.lazy().wrap();
}
};
}
/**
* @since 0.7.0
*/
default <X2> Arguments10Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, X2> andThen(
Function<? super X, ? extends X2> mapper) {
return new Arguments10Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, X2>() {
@Override
public Validated<X2> validate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10,
Locale locale, ConstraintContext constraintContext) {
return Arguments10Validator.this
.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, locale, constraintContext)
.map(mapper);
}
@Override
public Arguments10Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, Supplier<X2>> lazy() {
return Arguments10Validator.this.lazy()
.andThen((Function<Supplier<X>, Supplier<X2>>) xSupplier -> () -> mapper.apply(xSupplier.get()));
}
};
}
/**
* @since 0.11.0
*/
default <X2> Arguments10Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, X2> andThen(
ValueValidator<? super X, X2> validator) {
return new Arguments10Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, X2>() {
@Override
public Validated<X2> validate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10,
Locale locale, ConstraintContext constraintContext) {
return Arguments10Validator.this
.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, locale, constraintContext)
.flatMap(v -> validator.validate(v, locale, constraintContext));
}
@Override
public Arguments10Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, Supplier<X2>> lazy() {
return Arguments10Validator.this.lazy()
.andThen((xSupplier, locale, constraintContext) -> validator
.validate(Objects.requireNonNull(xSupplier).get(), locale, constraintContext)
.map(x2 -> () -> x2));
}
};
}
/**
* @since 0.7.0
*/
default <A> Arguments1Validator<A, X> compose(
Function<? super A, ? extends Arguments10<? extends A1, ? extends A2, ? extends A3, ? extends A4, ? extends A5, ? extends A6, ? extends A7, ? extends A8, ? extends A9, ? extends A10>> mapper) {
return new Arguments1Validator<A, X>() {
@Override
public Validated<X> validate(A a, Locale locale, ConstraintContext constraintContext) {
final Arguments10<? extends A1, ? extends A2, ? extends A3, ? extends A4, ? extends A5, ? extends A6, ? extends A7, ? extends A8, ? extends A9, ? extends A10> args = mapper
.apply(a);
return Arguments10Validator.this.validate(args.arg1(), args.arg2(), args.arg3(), args.arg4(),
args.arg5(), args.arg6(), args.arg7(), args.arg8(), args.arg9(), args.arg10(), locale,
constraintContext);
}
@Override
public Arguments1Validator<A, Supplier<X>> lazy() {
return Arguments10Validator.this.lazy().compose(mapper);
}
};
}
/**
* @since 0.10.0
*/
default Arguments10Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, Supplier<X>> lazy() {
throw new UnsupportedOperationException("lazy is not implemented!");
}
default Validated<X> validate(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4, @Nullable A5 a5,
@Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9, @Nullable A10 a10) {
return this.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, Locale.getDefault(), ConstraintGroup.DEFAULT);
}
default Validated<X> validate(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4, @Nullable A5 a5,
@Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9, @Nullable A10 a10,
ConstraintContext constraintContext) {
return this.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, Locale.getDefault(), constraintContext);
}
default Validated<X> validate(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4, @Nullable A5 a5,
@Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9, @Nullable A10 a10, Locale locale) {
return this.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, locale, ConstraintGroup.DEFAULT);
}
default X validated(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4, @Nullable A5 a5,
@Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9, @Nullable A10 a10)
throws ConstraintViolationsException {
return this.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10).orElseThrow(ConstraintViolationsException::new);
}
default X validated(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4, @Nullable A5 a5,
@Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9, @Nullable A10 a10,
ConstraintContext constraintContext) throws ConstraintViolationsException {
return this.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, constraintContext)
.orElseThrow(ConstraintViolationsException::new);
}
default X validated(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4, @Nullable A5 a5,
@Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9, @Nullable A10 a10, Locale locale)
throws ConstraintViolationsException {
return this.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, locale)
.orElseThrow(ConstraintViolationsException::new);
}
default X validated(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4, @Nullable A5 a5,
@Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9, @Nullable A10 a10, Locale locale,
ConstraintContext constraintContext) throws ConstraintViolationsException {
return this.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, locale, constraintContext)
.orElseThrow(ConstraintViolationsException::new);
}
}
|
0 | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi/arguments/Arguments11.java | /*
* Copyright (C) 2018-2025 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.yavi.arguments;
import java.util.Objects;
import am.ik.yavi.fn.Function11;
import am.ik.yavi.jsr305.Nullable;
/**
* A container class that holds 11 arguments, providing type-safe access to each argument
* and mapping functionality to transform these arguments.
*
* Generated by https://github.com/making/yavi/blob/develop/scripts/generate-args.sh
*
* @param <A1> the type of argument at position 1
* @param <A2> the type of argument at position 2
* @param <A3> the type of argument at position 3
* @param <A4> the type of argument at position 4
* @param <A5> the type of argument at position 5
* @param <A6> the type of argument at position 6
* @param <A7> the type of argument at position 7
* @param <A8> the type of argument at position 8
* @param <A9> the type of argument at position 9
* @param <A10> the type of argument at position 10
* @param <A11> the type of argument at position 11
* @since 0.3.0
*/
public final class Arguments11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11> {
private final A1 arg1;
private final A2 arg2;
private final A3 arg3;
private final A4 arg4;
private final A5 arg5;
private final A6 arg6;
private final A7 arg7;
private final A8 arg8;
private final A9 arg9;
private final A10 arg10;
private final A11 arg11;
/**
* Creates a new Arguments11 instance with the provided arguments.
* @param arg1 the argument at position 1, arg2 the argument at position 2, arg3 the
* argument at position 3, arg4 the argument at position 4, arg5 the argument at
* position 5, arg6 the argument at position 6, arg7 the argument at position 7, arg8
* the argument at position 8, arg9 the argument at position 9, arg10 the argument at
* position 10, arg11 the argument at position 11
*/
Arguments11(@Nullable A1 arg1, @Nullable A2 arg2, @Nullable A3 arg3, @Nullable A4 arg4, @Nullable A5 arg5,
@Nullable A6 arg6, @Nullable A7 arg7, @Nullable A8 arg8, @Nullable A9 arg9, @Nullable A10 arg10,
@Nullable A11 arg11) {
this.arg1 = arg1;
this.arg2 = arg2;
this.arg3 = arg3;
this.arg4 = arg4;
this.arg5 = arg5;
this.arg6 = arg6;
this.arg7 = arg7;
this.arg8 = arg8;
this.arg9 = arg9;
this.arg10 = arg10;
this.arg11 = arg11;
}
/**
* Returns the argument at position 1.
* @return the argument at position 1
*/
@Nullable
public A1 arg1() {
return this.arg1;
}
/**
* Returns the argument at position 2.
* @return the argument at position 2
*/
@Nullable
public A2 arg2() {
return this.arg2;
}
/**
* Returns the argument at position 3.
* @return the argument at position 3
*/
@Nullable
public A3 arg3() {
return this.arg3;
}
/**
* Returns the argument at position 4.
* @return the argument at position 4
*/
@Nullable
public A4 arg4() {
return this.arg4;
}
/**
* Returns the argument at position 5.
* @return the argument at position 5
*/
@Nullable
public A5 arg5() {
return this.arg5;
}
/**
* Returns the argument at position 6.
* @return the argument at position 6
*/
@Nullable
public A6 arg6() {
return this.arg6;
}
/**
* Returns the argument at position 7.
* @return the argument at position 7
*/
@Nullable
public A7 arg7() {
return this.arg7;
}
/**
* Returns the argument at position 8.
* @return the argument at position 8
*/
@Nullable
public A8 arg8() {
return this.arg8;
}
/**
* Returns the argument at position 9.
* @return the argument at position 9
*/
@Nullable
public A9 arg9() {
return this.arg9;
}
/**
* Returns the argument at position 10.
* @return the argument at position 10
*/
@Nullable
public A10 arg10() {
return this.arg10;
}
/**
* Returns the argument at position 11.
* @return the argument at position 11
*/
@Nullable
public A11 arg11() {
return this.arg11;
}
/**
* Applies the provided mapping function to all arguments contained in this instance.
* @param <X> the type of the result
* @param mapper the function to apply to the arguments
* @return the result of applying the mapper function to the arguments
*/
public <X> X map(
Function11<? super A1, ? super A2, ? super A3, ? super A4, ? super A5, ? super A6, ? super A7, ? super A8, ? super A9, ? super A10, ? super A11, ? extends X> mapper) {
return mapper.apply(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11);
}
/**
* Returns a new Arguments1 instance containing only the first 1 arguments.
* @return an Arguments1 instance with arguments from arg1 to arg1
* @since 0.16.0
*/
public Arguments1<A1> first1() {
return new Arguments1<>(arg1);
}
/**
* Returns a new Arguments2 instance containing only the first 2 arguments.
* @return an Arguments2 instance with arguments from arg1 to arg2
* @since 0.16.0
*/
public Arguments2<A1, A2> first2() {
return new Arguments2<>(arg1, arg2);
}
/**
* Returns a new Arguments3 instance containing only the first 3 arguments.
* @return an Arguments3 instance with arguments from arg1 to arg3
* @since 0.16.0
*/
public Arguments3<A1, A2, A3> first3() {
return new Arguments3<>(arg1, arg2, arg3);
}
/**
* Returns a new Arguments4 instance containing only the first 4 arguments.
* @return an Arguments4 instance with arguments from arg1 to arg4
* @since 0.16.0
*/
public Arguments4<A1, A2, A3, A4> first4() {
return new Arguments4<>(arg1, arg2, arg3, arg4);
}
/**
* Returns a new Arguments5 instance containing only the first 5 arguments.
* @return an Arguments5 instance with arguments from arg1 to arg5
* @since 0.16.0
*/
public Arguments5<A1, A2, A3, A4, A5> first5() {
return new Arguments5<>(arg1, arg2, arg3, arg4, arg5);
}
/**
* Returns a new Arguments6 instance containing only the first 6 arguments.
* @return an Arguments6 instance with arguments from arg1 to arg6
* @since 0.16.0
*/
public Arguments6<A1, A2, A3, A4, A5, A6> first6() {
return new Arguments6<>(arg1, arg2, arg3, arg4, arg5, arg6);
}
/**
* Returns a new Arguments7 instance containing only the first 7 arguments.
* @return an Arguments7 instance with arguments from arg1 to arg7
* @since 0.16.0
*/
public Arguments7<A1, A2, A3, A4, A5, A6, A7> first7() {
return new Arguments7<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7);
}
/**
* Returns a new Arguments8 instance containing only the first 8 arguments.
* @return an Arguments8 instance with arguments from arg1 to arg8
* @since 0.16.0
*/
public Arguments8<A1, A2, A3, A4, A5, A6, A7, A8> first8() {
return new Arguments8<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
}
/**
* Returns a new Arguments9 instance containing only the first 9 arguments.
* @return an Arguments9 instance with arguments from arg1 to arg9
* @since 0.16.0
*/
public Arguments9<A1, A2, A3, A4, A5, A6, A7, A8, A9> first9() {
return new Arguments9<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
}
/**
* Returns a new Arguments10 instance containing only the first 10 arguments.
* @return an Arguments10 instance with arguments from arg1 to arg10
* @since 0.16.0
*/
public Arguments10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10> first10() {
return new Arguments10<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
}
/**
* Returns a new Arguments1 instance containing only the last 1 arguments.
* @return an Arguments1 instance with arguments from arg11 to arg11
* @since 0.16.0
*/
public Arguments1<A11> last1() {
return new Arguments1<>(arg11);
}
/**
* Returns a new Arguments2 instance containing only the last 2 arguments.
* @return an Arguments2 instance with arguments from arg10 to arg11
* @since 0.16.0
*/
public Arguments2<A10, A11> last2() {
return new Arguments2<>(arg10, arg11);
}
/**
* Returns a new Arguments3 instance containing only the last 3 arguments.
* @return an Arguments3 instance with arguments from arg9 to arg11
* @since 0.16.0
*/
public Arguments3<A9, A10, A11> last3() {
return new Arguments3<>(arg9, arg10, arg11);
}
/**
* Returns a new Arguments4 instance containing only the last 4 arguments.
* @return an Arguments4 instance with arguments from arg8 to arg11
* @since 0.16.0
*/
public Arguments4<A8, A9, A10, A11> last4() {
return new Arguments4<>(arg8, arg9, arg10, arg11);
}
/**
* Returns a new Arguments5 instance containing only the last 5 arguments.
* @return an Arguments5 instance with arguments from arg7 to arg11
* @since 0.16.0
*/
public Arguments5<A7, A8, A9, A10, A11> last5() {
return new Arguments5<>(arg7, arg8, arg9, arg10, arg11);
}
/**
* Returns a new Arguments6 instance containing only the last 6 arguments.
* @return an Arguments6 instance with arguments from arg6 to arg11
* @since 0.16.0
*/
public Arguments6<A6, A7, A8, A9, A10, A11> last6() {
return new Arguments6<>(arg6, arg7, arg8, arg9, arg10, arg11);
}
/**
* Returns a new Arguments7 instance containing only the last 7 arguments.
* @return an Arguments7 instance with arguments from arg5 to arg11
* @since 0.16.0
*/
public Arguments7<A5, A6, A7, A8, A9, A10, A11> last7() {
return new Arguments7<>(arg5, arg6, arg7, arg8, arg9, arg10, arg11);
}
/**
* Returns a new Arguments8 instance containing only the last 8 arguments.
* @return an Arguments8 instance with arguments from arg4 to arg11
* @since 0.16.0
*/
public Arguments8<A4, A5, A6, A7, A8, A9, A10, A11> last8() {
return new Arguments8<>(arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11);
}
/**
* Returns a new Arguments9 instance containing only the last 9 arguments.
* @return an Arguments9 instance with arguments from arg3 to arg11
* @since 0.16.0
*/
public Arguments9<A3, A4, A5, A6, A7, A8, A9, A10, A11> last9() {
return new Arguments9<>(arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11);
}
/**
* Returns a new Arguments10 instance containing only the last 10 arguments.
* @return an Arguments10 instance with arguments from arg2 to arg11
* @since 0.16.0
*/
public Arguments10<A2, A3, A4, A5, A6, A7, A8, A9, A10, A11> last10() {
return new Arguments10<>(arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11);
}
/**
* Appends an additional argument to create a new, larger Arguments instance.
* @param <B> the type of the argument to append
* @param arg the argument to append
* @return a new Arguments12 instance with the additional argument
* @since 0.16.0
*/
public <B> Arguments12<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, B> append(@Nullable B arg) {
return new Arguments12<>(this.arg1, this.arg2, this.arg3, this.arg4, this.arg5, this.arg6, this.arg7, this.arg8,
this.arg9, this.arg10, this.arg11, arg);
}
/**
* Prepends an additional argument to create a new, larger Arguments instance.
* @param <B> the type of the argument to prepend
* @param arg the argument to prepend
* @return a new Arguments12 instance with the additional argument
* @since 0.16.0
*/
public <B> Arguments12<B, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11> prepend(@Nullable B arg) {
return new Arguments12<>(arg, this.arg1, this.arg2, this.arg3, this.arg4, this.arg5, this.arg6, this.arg7,
this.arg8, this.arg9, this.arg10, this.arg11);
}
/**
* Returns a new Arguments11 instance with the arguments in reverse order.
* @return an Arguments11 instance with arguments in reverse order
* @since 0.16.0
*/
public Arguments11<A11, A10, A9, A8, A7, A6, A5, A4, A3, A2, A1> reverse() {
return new Arguments11<>(arg11, arg10, arg9, arg8, arg7, arg6, arg5, arg4, arg3, arg2, arg1);
}
/**
* Indicates whether some other object is "equal to" this one.
* @param obj the reference object with which to compare
* @return true if this object is the same as the obj argument; false otherwise
*/
@Override
@SuppressWarnings("unchecked")
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
Arguments11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11> that = (Arguments11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>) obj;
return Objects.equals(this.arg1, that.arg1) && Objects.equals(this.arg2, that.arg2)
&& Objects.equals(this.arg3, that.arg3) && Objects.equals(this.arg4, that.arg4)
&& Objects.equals(this.arg5, that.arg5) && Objects.equals(this.arg6, that.arg6)
&& Objects.equals(this.arg7, that.arg7) && Objects.equals(this.arg8, that.arg8)
&& Objects.equals(this.arg9, that.arg9) && Objects.equals(this.arg10, that.arg10)
&& Objects.equals(this.arg11, that.arg11);
}
/**
* Returns a hash code value for the object.
* @return a hash code value for this object
*/
@Override
public int hashCode() {
return Objects.hash(this.arg1, this.arg2, this.arg3, this.arg4, this.arg5, this.arg6, this.arg7, this.arg8,
this.arg9, this.arg10, this.arg11);
}
/**
* Returns a string representation of the object.
* @return a string representation of the object
*/
@Override
public String toString() {
return "Arguments11{" + "arg1=" + this.arg1 + ", " + "arg2=" + this.arg2 + ", " + "arg3=" + this.arg3 + ", "
+ "arg4=" + this.arg4 + ", " + "arg5=" + this.arg5 + ", " + "arg6=" + this.arg6 + ", " + "arg7="
+ this.arg7 + ", " + "arg8=" + this.arg8 + ", " + "arg9=" + this.arg9 + ", " + "arg10=" + this.arg10
+ ", " + "arg11=" + this.arg11 + "}";
}
}
|
0 | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi/arguments/Arguments11Combining.java | /*
* Copyright (C) 2018-2025 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.yavi.arguments;
import am.ik.yavi.core.ConstraintContext;
import am.ik.yavi.core.Validated;
import am.ik.yavi.core.ValueValidator;
import am.ik.yavi.fn.Function11;
import am.ik.yavi.fn.Validations;
import java.util.Locale;
import java.util.function.Supplier;
/**
* Generated by https://github.com/making/yavi/blob/develop/scripts/generate-args.sh
*
* @since 0.7.0
*/
public class Arguments11Combining<A, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11> {
protected final ValueValidator<? super A, ? extends R1> v1;
protected final ValueValidator<? super A, ? extends R2> v2;
protected final ValueValidator<? super A, ? extends R3> v3;
protected final ValueValidator<? super A, ? extends R4> v4;
protected final ValueValidator<? super A, ? extends R5> v5;
protected final ValueValidator<? super A, ? extends R6> v6;
protected final ValueValidator<? super A, ? extends R7> v7;
protected final ValueValidator<? super A, ? extends R8> v8;
protected final ValueValidator<? super A, ? extends R9> v9;
protected final ValueValidator<? super A, ? extends R10> v10;
protected final ValueValidator<? super A, ? extends R11> v11;
public Arguments11Combining(ValueValidator<? super A, ? extends R1> v1, ValueValidator<? super A, ? extends R2> v2,
ValueValidator<? super A, ? extends R3> v3, ValueValidator<? super A, ? extends R4> v4,
ValueValidator<? super A, ? extends R5> v5, ValueValidator<? super A, ? extends R6> v6,
ValueValidator<? super A, ? extends R7> v7, ValueValidator<? super A, ? extends R8> v8,
ValueValidator<? super A, ? extends R9> v9, ValueValidator<? super A, ? extends R10> v10,
ValueValidator<? super A, ? extends R11> v11) {
this.v1 = v1;
this.v2 = v2;
this.v3 = v3;
this.v4 = v4;
this.v5 = v5;
this.v6 = v6;
this.v7 = v7;
this.v8 = v8;
this.v9 = v9;
this.v10 = v10;
this.v11 = v11;
}
public <X> Arguments1Validator<A, X> apply(
Function11<? super R1, ? super R2, ? super R3, ? super R4, ? super R5, ? super R6, ? super R7, ? super R8, ? super R9, ? super R10, ? super R11, ? extends X> f) {
return new Arguments1Validator<A, X>() {
@Override
public Validated<X> validate(A a, Locale locale, ConstraintContext constraintContext) {
return Validations.apply(f::apply, Arguments11Combining.this.v1.validate(a, locale, constraintContext),
Arguments11Combining.this.v2.validate(a, locale, constraintContext),
Arguments11Combining.this.v3.validate(a, locale, constraintContext),
Arguments11Combining.this.v4.validate(a, locale, constraintContext),
Arguments11Combining.this.v5.validate(a, locale, constraintContext),
Arguments11Combining.this.v6.validate(a, locale, constraintContext),
Arguments11Combining.this.v7.validate(a, locale, constraintContext),
Arguments11Combining.this.v8.validate(a, locale, constraintContext),
Arguments11Combining.this.v9.validate(a, locale, constraintContext),
Arguments11Combining.this.v10.validate(a, locale, constraintContext),
Arguments11Combining.this.v11.validate(a, locale, constraintContext));
}
@Override
public Arguments1Validator<A, Supplier<X>> lazy() {
return (a, locale, constraintContext) -> Validations.apply(
(r1, r2, r3, r4, r5, r6, r7, r8, r9, r10,
r11) -> () -> f.apply(r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11),
Arguments11Combining.this.v1.validate(a, locale, constraintContext),
Arguments11Combining.this.v2.validate(a, locale, constraintContext),
Arguments11Combining.this.v3.validate(a, locale, constraintContext),
Arguments11Combining.this.v4.validate(a, locale, constraintContext),
Arguments11Combining.this.v5.validate(a, locale, constraintContext),
Arguments11Combining.this.v6.validate(a, locale, constraintContext),
Arguments11Combining.this.v7.validate(a, locale, constraintContext),
Arguments11Combining.this.v8.validate(a, locale, constraintContext),
Arguments11Combining.this.v9.validate(a, locale, constraintContext),
Arguments11Combining.this.v10.validate(a, locale, constraintContext),
Arguments11Combining.this.v11.validate(a, locale, constraintContext));
}
};
}
public <R12> Arguments12Combining<A, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12> combine(
ValueValidator<? super A, ? extends R12> v12) {
return new Arguments12Combining<>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12);
}
}
|
0 | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi/arguments/Arguments11Splitting.java | /*
* Copyright (C) 2018-2025 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.yavi.arguments;
import java.util.Locale;
import java.util.function.Supplier;
import am.ik.yavi.core.ConstraintContext;
import am.ik.yavi.core.Validated;
import am.ik.yavi.core.ValueValidator;
import am.ik.yavi.fn.Function11;
import am.ik.yavi.fn.Validations;
import am.ik.yavi.jsr305.Nullable;
/**
* Generated by https://github.com/making/yavi/blob/develop/scripts/generate-args.sh
*
* @since 0.7.0
*/
public class Arguments11Splitting<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11> {
protected final ValueValidator<? super A1, ? extends R1> v1;
protected final ValueValidator<? super A2, ? extends R2> v2;
protected final ValueValidator<? super A3, ? extends R3> v3;
protected final ValueValidator<? super A4, ? extends R4> v4;
protected final ValueValidator<? super A5, ? extends R5> v5;
protected final ValueValidator<? super A6, ? extends R6> v6;
protected final ValueValidator<? super A7, ? extends R7> v7;
protected final ValueValidator<? super A8, ? extends R8> v8;
protected final ValueValidator<? super A9, ? extends R9> v9;
protected final ValueValidator<? super A10, ? extends R10> v10;
protected final ValueValidator<? super A11, ? extends R11> v11;
public Arguments11Splitting(ValueValidator<? super A1, ? extends R1> v1,
ValueValidator<? super A2, ? extends R2> v2, ValueValidator<? super A3, ? extends R3> v3,
ValueValidator<? super A4, ? extends R4> v4, ValueValidator<? super A5, ? extends R5> v5,
ValueValidator<? super A6, ? extends R6> v6, ValueValidator<? super A7, ? extends R7> v7,
ValueValidator<? super A8, ? extends R8> v8, ValueValidator<? super A9, ? extends R9> v9,
ValueValidator<? super A10, ? extends R10> v10, ValueValidator<? super A11, ? extends R11> v11) {
this.v1 = v1;
this.v2 = v2;
this.v3 = v3;
this.v4 = v4;
this.v5 = v5;
this.v6 = v6;
this.v7 = v7;
this.v8 = v8;
this.v9 = v9;
this.v10 = v10;
this.v11 = v11;
}
public <X> Arguments11Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, X> apply(
Function11<? super R1, ? super R2, ? super R3, ? super R4, ? super R5, ? super R6, ? super R7, ? super R8, ? super R9, ? super R10, ? super R11, ? extends X> f) {
return new Arguments11Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, X>() {
@Override
public Arguments11Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, Supplier<X>> lazy() {
return ((a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, locale, constraintContext) -> Validations.apply(
(r1, r2, r3, r4, r5, r6, r7, r8, r9, r10,
r11) -> () -> f.apply(r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11),
v1.validate(a1, locale, constraintContext), v2.validate(a2, locale, constraintContext),
v3.validate(a3, locale, constraintContext), v4.validate(a4, locale, constraintContext),
v5.validate(a5, locale, constraintContext), v6.validate(a6, locale, constraintContext),
v7.validate(a7, locale, constraintContext), v8.validate(a8, locale, constraintContext),
v9.validate(a9, locale, constraintContext), v10.validate(a10, locale, constraintContext),
v11.validate(a11, locale, constraintContext)));
}
@Override
public Validated<X> validate(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4,
@Nullable A5 a5, @Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9,
@Nullable A10 a10, @Nullable A11 a11, Locale locale, ConstraintContext constraintContext) {
return Validations.apply(f::apply, v1.validate(a1, locale, constraintContext),
v2.validate(a2, locale, constraintContext), v3.validate(a3, locale, constraintContext),
v4.validate(a4, locale, constraintContext), v5.validate(a5, locale, constraintContext),
v6.validate(a6, locale, constraintContext), v7.validate(a7, locale, constraintContext),
v8.validate(a8, locale, constraintContext), v9.validate(a9, locale, constraintContext),
v10.validate(a10, locale, constraintContext), v11.validate(a11, locale, constraintContext));
}
};
}
public <A12, R12> Arguments12Splitting<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12> split(
ValueValidator<? super A12, ? extends R12> v12) {
return new Arguments12Splitting<>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12);
}
}
|
0 | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi/arguments/Arguments11Validator.java | /*
* Copyright (C) 2018-2025 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.yavi.arguments;
import java.util.Locale;
import java.util.Objects;
import java.util.function.Function;
import java.util.function.Supplier;
import am.ik.yavi.core.ConstraintContext;
import am.ik.yavi.core.ConstraintGroup;
import am.ik.yavi.core.ConstraintViolationsException;
import am.ik.yavi.core.Validated;
import am.ik.yavi.core.ValueValidator;
import am.ik.yavi.jsr305.Nullable;
/**
* Generated by https://github.com/making/yavi/blob/develop/scripts/generate-args.sh
*
* @since 0.3.0
*/
@FunctionalInterface
public interface Arguments11Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, X> {
/**
* Convert an Arguments1Validator that validates Arguments11 to an
* Arguments11Validator
* @param validator validator for Arguments11
* @param <A1> type of first argument
* @param <A2> type of argument at position 2
* @param <A3> type of argument at position 3
* @param <A4> type of argument at position 4
* @param <A5> type of argument at position 5
* @param <A6> type of argument at position 6
* @param <A7> type of argument at position 7
* @param <A8> type of argument at position 8
* @param <A9> type of argument at position 9
* @param <A10> type of argument at position 10
* @param <A11> type of argument at position 11
* @param <X> target result type
* @return arguments11 validator that takes arguments directly
* @since 0.16.0
*/
static <A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, X> Arguments11Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, X> unwrap(
Arguments1Validator<Arguments11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>, X> validator) {
return new Arguments11Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, X>() {
@Override
public Validated<X> validate(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4,
@Nullable A5 a5, @Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9,
@Nullable A10 a10, @Nullable A11 a11, Locale locale, ConstraintContext constraintContext) {
return validator.validate(Arguments.of(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11), locale,
constraintContext);
}
@Override
public Arguments11Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, Supplier<X>> lazy() {
return Arguments11Validator.unwrap(validator.lazy());
}
};
}
Validated<X> validate(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4, @Nullable A5 a5,
@Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9, @Nullable A10 a10, @Nullable A11 a11,
Locale locale, ConstraintContext constraintContext);
/**
* Convert this validator to one that validates Arguments11 as a single object.
* @return a validator that takes an Arguments11
* @since 0.16.0
*/
default Arguments1Validator<Arguments11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>, X> wrap() {
return new Arguments1Validator<Arguments11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>, X>() {
@Override
public Validated<X> validate(Arguments11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11> args, Locale locale,
ConstraintContext constraintContext) {
final Arguments11<? extends A1, ? extends A2, ? extends A3, ? extends A4, ? extends A5, ? extends A6, ? extends A7, ? extends A8, ? extends A9, ? extends A10, ? extends A11> nonNullArgs = Objects
.requireNonNull(args);
return Arguments11Validator.this.validate(nonNullArgs.arg1(), nonNullArgs.arg2(), nonNullArgs.arg3(),
nonNullArgs.arg4(), nonNullArgs.arg5(), nonNullArgs.arg6(), nonNullArgs.arg7(),
nonNullArgs.arg8(), nonNullArgs.arg9(), nonNullArgs.arg10(), nonNullArgs.arg11(), locale,
constraintContext);
}
@Override
public Arguments1Validator<Arguments11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>, Supplier<X>> lazy() {
return Arguments11Validator.this.lazy().wrap();
}
};
}
/**
* @since 0.7.0
*/
default <X2> Arguments11Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, X2> andThen(
Function<? super X, ? extends X2> mapper) {
return new Arguments11Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, X2>() {
@Override
public Validated<X2> validate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10,
A11 a11, Locale locale, ConstraintContext constraintContext) {
return Arguments11Validator.this
.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, locale, constraintContext)
.map(mapper);
}
@Override
public Arguments11Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, Supplier<X2>> lazy() {
return Arguments11Validator.this.lazy()
.andThen((Function<Supplier<X>, Supplier<X2>>) xSupplier -> () -> mapper.apply(xSupplier.get()));
}
};
}
/**
* @since 0.11.0
*/
default <X2> Arguments11Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, X2> andThen(
ValueValidator<? super X, X2> validator) {
return new Arguments11Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, X2>() {
@Override
public Validated<X2> validate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10,
A11 a11, Locale locale, ConstraintContext constraintContext) {
return Arguments11Validator.this
.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, locale, constraintContext)
.flatMap(v -> validator.validate(v, locale, constraintContext));
}
@Override
public Arguments11Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, Supplier<X2>> lazy() {
return Arguments11Validator.this.lazy()
.andThen((xSupplier, locale, constraintContext) -> validator
.validate(Objects.requireNonNull(xSupplier).get(), locale, constraintContext)
.map(x2 -> () -> x2));
}
};
}
/**
* @since 0.7.0
*/
default <A> Arguments1Validator<A, X> compose(
Function<? super A, ? extends Arguments11<? extends A1, ? extends A2, ? extends A3, ? extends A4, ? extends A5, ? extends A6, ? extends A7, ? extends A8, ? extends A9, ? extends A10, ? extends A11>> mapper) {
return new Arguments1Validator<A, X>() {
@Override
public Validated<X> validate(A a, Locale locale, ConstraintContext constraintContext) {
final Arguments11<? extends A1, ? extends A2, ? extends A3, ? extends A4, ? extends A5, ? extends A6, ? extends A7, ? extends A8, ? extends A9, ? extends A10, ? extends A11> args = mapper
.apply(a);
return Arguments11Validator.this.validate(args.arg1(), args.arg2(), args.arg3(), args.arg4(),
args.arg5(), args.arg6(), args.arg7(), args.arg8(), args.arg9(), args.arg10(), args.arg11(),
locale, constraintContext);
}
@Override
public Arguments1Validator<A, Supplier<X>> lazy() {
return Arguments11Validator.this.lazy().compose(mapper);
}
};
}
/**
* @since 0.10.0
*/
default Arguments11Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, Supplier<X>> lazy() {
throw new UnsupportedOperationException("lazy is not implemented!");
}
default Validated<X> validate(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4, @Nullable A5 a5,
@Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9, @Nullable A10 a10, @Nullable A11 a11) {
return this.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, Locale.getDefault(),
ConstraintGroup.DEFAULT);
}
default Validated<X> validate(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4, @Nullable A5 a5,
@Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9, @Nullable A10 a10, @Nullable A11 a11,
ConstraintContext constraintContext) {
return this.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, Locale.getDefault(), constraintContext);
}
default Validated<X> validate(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4, @Nullable A5 a5,
@Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9, @Nullable A10 a10, @Nullable A11 a11,
Locale locale) {
return this.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, locale, ConstraintGroup.DEFAULT);
}
default X validated(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4, @Nullable A5 a5,
@Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9, @Nullable A10 a10, @Nullable A11 a11)
throws ConstraintViolationsException {
return this.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11)
.orElseThrow(ConstraintViolationsException::new);
}
default X validated(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4, @Nullable A5 a5,
@Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9, @Nullable A10 a10, @Nullable A11 a11,
ConstraintContext constraintContext) throws ConstraintViolationsException {
return this.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, constraintContext)
.orElseThrow(ConstraintViolationsException::new);
}
default X validated(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4, @Nullable A5 a5,
@Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9, @Nullable A10 a10, @Nullable A11 a11,
Locale locale) throws ConstraintViolationsException {
return this.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, locale)
.orElseThrow(ConstraintViolationsException::new);
}
default X validated(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4, @Nullable A5 a5,
@Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9, @Nullable A10 a10, @Nullable A11 a11,
Locale locale, ConstraintContext constraintContext) throws ConstraintViolationsException {
return this.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, locale, constraintContext)
.orElseThrow(ConstraintViolationsException::new);
}
}
|
0 | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi/arguments/Arguments12.java | /*
* Copyright (C) 2018-2025 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.yavi.arguments;
import java.util.Objects;
import am.ik.yavi.fn.Function12;
import am.ik.yavi.jsr305.Nullable;
/**
* A container class that holds 12 arguments, providing type-safe access to each argument
* and mapping functionality to transform these arguments.
*
* Generated by https://github.com/making/yavi/blob/develop/scripts/generate-args.sh
*
* @param <A1> the type of argument at position 1
* @param <A2> the type of argument at position 2
* @param <A3> the type of argument at position 3
* @param <A4> the type of argument at position 4
* @param <A5> the type of argument at position 5
* @param <A6> the type of argument at position 6
* @param <A7> the type of argument at position 7
* @param <A8> the type of argument at position 8
* @param <A9> the type of argument at position 9
* @param <A10> the type of argument at position 10
* @param <A11> the type of argument at position 11
* @param <A12> the type of argument at position 12
* @since 0.3.0
*/
public final class Arguments12<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12> {
private final A1 arg1;
private final A2 arg2;
private final A3 arg3;
private final A4 arg4;
private final A5 arg5;
private final A6 arg6;
private final A7 arg7;
private final A8 arg8;
private final A9 arg9;
private final A10 arg10;
private final A11 arg11;
private final A12 arg12;
/**
* Creates a new Arguments12 instance with the provided arguments.
* @param arg1 the argument at position 1, arg2 the argument at position 2, arg3 the
* argument at position 3, arg4 the argument at position 4, arg5 the argument at
* position 5, arg6 the argument at position 6, arg7 the argument at position 7, arg8
* the argument at position 8, arg9 the argument at position 9, arg10 the argument at
* position 10, arg11 the argument at position 11, arg12 the argument at position 12
*/
Arguments12(@Nullable A1 arg1, @Nullable A2 arg2, @Nullable A3 arg3, @Nullable A4 arg4, @Nullable A5 arg5,
@Nullable A6 arg6, @Nullable A7 arg7, @Nullable A8 arg8, @Nullable A9 arg9, @Nullable A10 arg10,
@Nullable A11 arg11, @Nullable A12 arg12) {
this.arg1 = arg1;
this.arg2 = arg2;
this.arg3 = arg3;
this.arg4 = arg4;
this.arg5 = arg5;
this.arg6 = arg6;
this.arg7 = arg7;
this.arg8 = arg8;
this.arg9 = arg9;
this.arg10 = arg10;
this.arg11 = arg11;
this.arg12 = arg12;
}
/**
* Returns the argument at position 1.
* @return the argument at position 1
*/
@Nullable
public A1 arg1() {
return this.arg1;
}
/**
* Returns the argument at position 2.
* @return the argument at position 2
*/
@Nullable
public A2 arg2() {
return this.arg2;
}
/**
* Returns the argument at position 3.
* @return the argument at position 3
*/
@Nullable
public A3 arg3() {
return this.arg3;
}
/**
* Returns the argument at position 4.
* @return the argument at position 4
*/
@Nullable
public A4 arg4() {
return this.arg4;
}
/**
* Returns the argument at position 5.
* @return the argument at position 5
*/
@Nullable
public A5 arg5() {
return this.arg5;
}
/**
* Returns the argument at position 6.
* @return the argument at position 6
*/
@Nullable
public A6 arg6() {
return this.arg6;
}
/**
* Returns the argument at position 7.
* @return the argument at position 7
*/
@Nullable
public A7 arg7() {
return this.arg7;
}
/**
* Returns the argument at position 8.
* @return the argument at position 8
*/
@Nullable
public A8 arg8() {
return this.arg8;
}
/**
* Returns the argument at position 9.
* @return the argument at position 9
*/
@Nullable
public A9 arg9() {
return this.arg9;
}
/**
* Returns the argument at position 10.
* @return the argument at position 10
*/
@Nullable
public A10 arg10() {
return this.arg10;
}
/**
* Returns the argument at position 11.
* @return the argument at position 11
*/
@Nullable
public A11 arg11() {
return this.arg11;
}
/**
* Returns the argument at position 12.
* @return the argument at position 12
*/
@Nullable
public A12 arg12() {
return this.arg12;
}
/**
* Applies the provided mapping function to all arguments contained in this instance.
* @param <X> the type of the result
* @param mapper the function to apply to the arguments
* @return the result of applying the mapper function to the arguments
*/
public <X> X map(
Function12<? super A1, ? super A2, ? super A3, ? super A4, ? super A5, ? super A6, ? super A7, ? super A8, ? super A9, ? super A10, ? super A11, ? super A12, ? extends X> mapper) {
return mapper.apply(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12);
}
/**
* Returns a new Arguments1 instance containing only the first 1 arguments.
* @return an Arguments1 instance with arguments from arg1 to arg1
* @since 0.16.0
*/
public Arguments1<A1> first1() {
return new Arguments1<>(arg1);
}
/**
* Returns a new Arguments2 instance containing only the first 2 arguments.
* @return an Arguments2 instance with arguments from arg1 to arg2
* @since 0.16.0
*/
public Arguments2<A1, A2> first2() {
return new Arguments2<>(arg1, arg2);
}
/**
* Returns a new Arguments3 instance containing only the first 3 arguments.
* @return an Arguments3 instance with arguments from arg1 to arg3
* @since 0.16.0
*/
public Arguments3<A1, A2, A3> first3() {
return new Arguments3<>(arg1, arg2, arg3);
}
/**
* Returns a new Arguments4 instance containing only the first 4 arguments.
* @return an Arguments4 instance with arguments from arg1 to arg4
* @since 0.16.0
*/
public Arguments4<A1, A2, A3, A4> first4() {
return new Arguments4<>(arg1, arg2, arg3, arg4);
}
/**
* Returns a new Arguments5 instance containing only the first 5 arguments.
* @return an Arguments5 instance with arguments from arg1 to arg5
* @since 0.16.0
*/
public Arguments5<A1, A2, A3, A4, A5> first5() {
return new Arguments5<>(arg1, arg2, arg3, arg4, arg5);
}
/**
* Returns a new Arguments6 instance containing only the first 6 arguments.
* @return an Arguments6 instance with arguments from arg1 to arg6
* @since 0.16.0
*/
public Arguments6<A1, A2, A3, A4, A5, A6> first6() {
return new Arguments6<>(arg1, arg2, arg3, arg4, arg5, arg6);
}
/**
* Returns a new Arguments7 instance containing only the first 7 arguments.
* @return an Arguments7 instance with arguments from arg1 to arg7
* @since 0.16.0
*/
public Arguments7<A1, A2, A3, A4, A5, A6, A7> first7() {
return new Arguments7<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7);
}
/**
* Returns a new Arguments8 instance containing only the first 8 arguments.
* @return an Arguments8 instance with arguments from arg1 to arg8
* @since 0.16.0
*/
public Arguments8<A1, A2, A3, A4, A5, A6, A7, A8> first8() {
return new Arguments8<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
}
/**
* Returns a new Arguments9 instance containing only the first 9 arguments.
* @return an Arguments9 instance with arguments from arg1 to arg9
* @since 0.16.0
*/
public Arguments9<A1, A2, A3, A4, A5, A6, A7, A8, A9> first9() {
return new Arguments9<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
}
/**
* Returns a new Arguments10 instance containing only the first 10 arguments.
* @return an Arguments10 instance with arguments from arg1 to arg10
* @since 0.16.0
*/
public Arguments10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10> first10() {
return new Arguments10<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
}
/**
* Returns a new Arguments11 instance containing only the first 11 arguments.
* @return an Arguments11 instance with arguments from arg1 to arg11
* @since 0.16.0
*/
public Arguments11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11> first11() {
return new Arguments11<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11);
}
/**
* Returns a new Arguments1 instance containing only the last 1 arguments.
* @return an Arguments1 instance with arguments from arg12 to arg12
* @since 0.16.0
*/
public Arguments1<A12> last1() {
return new Arguments1<>(arg12);
}
/**
* Returns a new Arguments2 instance containing only the last 2 arguments.
* @return an Arguments2 instance with arguments from arg11 to arg12
* @since 0.16.0
*/
public Arguments2<A11, A12> last2() {
return new Arguments2<>(arg11, arg12);
}
/**
* Returns a new Arguments3 instance containing only the last 3 arguments.
* @return an Arguments3 instance with arguments from arg10 to arg12
* @since 0.16.0
*/
public Arguments3<A10, A11, A12> last3() {
return new Arguments3<>(arg10, arg11, arg12);
}
/**
* Returns a new Arguments4 instance containing only the last 4 arguments.
* @return an Arguments4 instance with arguments from arg9 to arg12
* @since 0.16.0
*/
public Arguments4<A9, A10, A11, A12> last4() {
return new Arguments4<>(arg9, arg10, arg11, arg12);
}
/**
* Returns a new Arguments5 instance containing only the last 5 arguments.
* @return an Arguments5 instance with arguments from arg8 to arg12
* @since 0.16.0
*/
public Arguments5<A8, A9, A10, A11, A12> last5() {
return new Arguments5<>(arg8, arg9, arg10, arg11, arg12);
}
/**
* Returns a new Arguments6 instance containing only the last 6 arguments.
* @return an Arguments6 instance with arguments from arg7 to arg12
* @since 0.16.0
*/
public Arguments6<A7, A8, A9, A10, A11, A12> last6() {
return new Arguments6<>(arg7, arg8, arg9, arg10, arg11, arg12);
}
/**
* Returns a new Arguments7 instance containing only the last 7 arguments.
* @return an Arguments7 instance with arguments from arg6 to arg12
* @since 0.16.0
*/
public Arguments7<A6, A7, A8, A9, A10, A11, A12> last7() {
return new Arguments7<>(arg6, arg7, arg8, arg9, arg10, arg11, arg12);
}
/**
* Returns a new Arguments8 instance containing only the last 8 arguments.
* @return an Arguments8 instance with arguments from arg5 to arg12
* @since 0.16.0
*/
public Arguments8<A5, A6, A7, A8, A9, A10, A11, A12> last8() {
return new Arguments8<>(arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12);
}
/**
* Returns a new Arguments9 instance containing only the last 9 arguments.
* @return an Arguments9 instance with arguments from arg4 to arg12
* @since 0.16.0
*/
public Arguments9<A4, A5, A6, A7, A8, A9, A10, A11, A12> last9() {
return new Arguments9<>(arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12);
}
/**
* Returns a new Arguments10 instance containing only the last 10 arguments.
* @return an Arguments10 instance with arguments from arg3 to arg12
* @since 0.16.0
*/
public Arguments10<A3, A4, A5, A6, A7, A8, A9, A10, A11, A12> last10() {
return new Arguments10<>(arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12);
}
/**
* Returns a new Arguments11 instance containing only the last 11 arguments.
* @return an Arguments11 instance with arguments from arg2 to arg12
* @since 0.16.0
*/
public Arguments11<A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12> last11() {
return new Arguments11<>(arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12);
}
/**
* Appends an additional argument to create a new, larger Arguments instance.
* @param <B> the type of the argument to append
* @param arg the argument to append
* @return a new Arguments13 instance with the additional argument
* @since 0.16.0
*/
public <B> Arguments13<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, B> append(@Nullable B arg) {
return new Arguments13<>(this.arg1, this.arg2, this.arg3, this.arg4, this.arg5, this.arg6, this.arg7, this.arg8,
this.arg9, this.arg10, this.arg11, this.arg12, arg);
}
/**
* Prepends an additional argument to create a new, larger Arguments instance.
* @param <B> the type of the argument to prepend
* @param arg the argument to prepend
* @return a new Arguments13 instance with the additional argument
* @since 0.16.0
*/
public <B> Arguments13<B, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12> prepend(@Nullable B arg) {
return new Arguments13<>(arg, this.arg1, this.arg2, this.arg3, this.arg4, this.arg5, this.arg6, this.arg7,
this.arg8, this.arg9, this.arg10, this.arg11, this.arg12);
}
/**
* Returns a new Arguments12 instance with the arguments in reverse order.
* @return an Arguments12 instance with arguments in reverse order
* @since 0.16.0
*/
public Arguments12<A12, A11, A10, A9, A8, A7, A6, A5, A4, A3, A2, A1> reverse() {
return new Arguments12<>(arg12, arg11, arg10, arg9, arg8, arg7, arg6, arg5, arg4, arg3, arg2, arg1);
}
/**
* Indicates whether some other object is "equal to" this one.
* @param obj the reference object with which to compare
* @return true if this object is the same as the obj argument; false otherwise
*/
@Override
@SuppressWarnings("unchecked")
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
Arguments12<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12> that = (Arguments12<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12>) obj;
return Objects.equals(this.arg1, that.arg1) && Objects.equals(this.arg2, that.arg2)
&& Objects.equals(this.arg3, that.arg3) && Objects.equals(this.arg4, that.arg4)
&& Objects.equals(this.arg5, that.arg5) && Objects.equals(this.arg6, that.arg6)
&& Objects.equals(this.arg7, that.arg7) && Objects.equals(this.arg8, that.arg8)
&& Objects.equals(this.arg9, that.arg9) && Objects.equals(this.arg10, that.arg10)
&& Objects.equals(this.arg11, that.arg11) && Objects.equals(this.arg12, that.arg12);
}
/**
* Returns a hash code value for the object.
* @return a hash code value for this object
*/
@Override
public int hashCode() {
return Objects.hash(this.arg1, this.arg2, this.arg3, this.arg4, this.arg5, this.arg6, this.arg7, this.arg8,
this.arg9, this.arg10, this.arg11, this.arg12);
}
/**
* Returns a string representation of the object.
* @return a string representation of the object
*/
@Override
public String toString() {
return "Arguments12{" + "arg1=" + this.arg1 + ", " + "arg2=" + this.arg2 + ", " + "arg3=" + this.arg3 + ", "
+ "arg4=" + this.arg4 + ", " + "arg5=" + this.arg5 + ", " + "arg6=" + this.arg6 + ", " + "arg7="
+ this.arg7 + ", " + "arg8=" + this.arg8 + ", " + "arg9=" + this.arg9 + ", " + "arg10=" + this.arg10
+ ", " + "arg11=" + this.arg11 + ", " + "arg12=" + this.arg12 + "}";
}
}
|
0 | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi/arguments/Arguments12Combining.java | /*
* Copyright (C) 2018-2025 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.yavi.arguments;
import am.ik.yavi.core.ConstraintContext;
import am.ik.yavi.core.Validated;
import am.ik.yavi.core.ValueValidator;
import am.ik.yavi.fn.Function12;
import am.ik.yavi.fn.Validations;
import java.util.Locale;
import java.util.function.Supplier;
/**
* Generated by https://github.com/making/yavi/blob/develop/scripts/generate-args.sh
*
* @since 0.7.0
*/
public class Arguments12Combining<A, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12> {
protected final ValueValidator<? super A, ? extends R1> v1;
protected final ValueValidator<? super A, ? extends R2> v2;
protected final ValueValidator<? super A, ? extends R3> v3;
protected final ValueValidator<? super A, ? extends R4> v4;
protected final ValueValidator<? super A, ? extends R5> v5;
protected final ValueValidator<? super A, ? extends R6> v6;
protected final ValueValidator<? super A, ? extends R7> v7;
protected final ValueValidator<? super A, ? extends R8> v8;
protected final ValueValidator<? super A, ? extends R9> v9;
protected final ValueValidator<? super A, ? extends R10> v10;
protected final ValueValidator<? super A, ? extends R11> v11;
protected final ValueValidator<? super A, ? extends R12> v12;
public Arguments12Combining(ValueValidator<? super A, ? extends R1> v1, ValueValidator<? super A, ? extends R2> v2,
ValueValidator<? super A, ? extends R3> v3, ValueValidator<? super A, ? extends R4> v4,
ValueValidator<? super A, ? extends R5> v5, ValueValidator<? super A, ? extends R6> v6,
ValueValidator<? super A, ? extends R7> v7, ValueValidator<? super A, ? extends R8> v8,
ValueValidator<? super A, ? extends R9> v9, ValueValidator<? super A, ? extends R10> v10,
ValueValidator<? super A, ? extends R11> v11, ValueValidator<? super A, ? extends R12> v12) {
this.v1 = v1;
this.v2 = v2;
this.v3 = v3;
this.v4 = v4;
this.v5 = v5;
this.v6 = v6;
this.v7 = v7;
this.v8 = v8;
this.v9 = v9;
this.v10 = v10;
this.v11 = v11;
this.v12 = v12;
}
public <X> Arguments1Validator<A, X> apply(
Function12<? super R1, ? super R2, ? super R3, ? super R4, ? super R5, ? super R6, ? super R7, ? super R8, ? super R9, ? super R10, ? super R11, ? super R12, ? extends X> f) {
return new Arguments1Validator<A, X>() {
@Override
public Validated<X> validate(A a, Locale locale, ConstraintContext constraintContext) {
return Validations.apply(f::apply, Arguments12Combining.this.v1.validate(a, locale, constraintContext),
Arguments12Combining.this.v2.validate(a, locale, constraintContext),
Arguments12Combining.this.v3.validate(a, locale, constraintContext),
Arguments12Combining.this.v4.validate(a, locale, constraintContext),
Arguments12Combining.this.v5.validate(a, locale, constraintContext),
Arguments12Combining.this.v6.validate(a, locale, constraintContext),
Arguments12Combining.this.v7.validate(a, locale, constraintContext),
Arguments12Combining.this.v8.validate(a, locale, constraintContext),
Arguments12Combining.this.v9.validate(a, locale, constraintContext),
Arguments12Combining.this.v10.validate(a, locale, constraintContext),
Arguments12Combining.this.v11.validate(a, locale, constraintContext),
Arguments12Combining.this.v12.validate(a, locale, constraintContext));
}
@Override
public Arguments1Validator<A, Supplier<X>> lazy() {
return (a, locale, constraintContext) -> Validations.apply(
(r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11,
r12) -> () -> f.apply(r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12),
Arguments12Combining.this.v1.validate(a, locale, constraintContext),
Arguments12Combining.this.v2.validate(a, locale, constraintContext),
Arguments12Combining.this.v3.validate(a, locale, constraintContext),
Arguments12Combining.this.v4.validate(a, locale, constraintContext),
Arguments12Combining.this.v5.validate(a, locale, constraintContext),
Arguments12Combining.this.v6.validate(a, locale, constraintContext),
Arguments12Combining.this.v7.validate(a, locale, constraintContext),
Arguments12Combining.this.v8.validate(a, locale, constraintContext),
Arguments12Combining.this.v9.validate(a, locale, constraintContext),
Arguments12Combining.this.v10.validate(a, locale, constraintContext),
Arguments12Combining.this.v11.validate(a, locale, constraintContext),
Arguments12Combining.this.v12.validate(a, locale, constraintContext));
}
};
}
public <R13> Arguments13Combining<A, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13> combine(
ValueValidator<? super A, ? extends R13> v13) {
return new Arguments13Combining<>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13);
}
}
|
0 | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi/arguments/Arguments12Splitting.java | /*
* Copyright (C) 2018-2025 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.yavi.arguments;
import java.util.Locale;
import java.util.function.Supplier;
import am.ik.yavi.core.ConstraintContext;
import am.ik.yavi.core.Validated;
import am.ik.yavi.core.ValueValidator;
import am.ik.yavi.fn.Function12;
import am.ik.yavi.fn.Validations;
import am.ik.yavi.jsr305.Nullable;
/**
* Generated by https://github.com/making/yavi/blob/develop/scripts/generate-args.sh
*
* @since 0.7.0
*/
public class Arguments12Splitting<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12> {
protected final ValueValidator<? super A1, ? extends R1> v1;
protected final ValueValidator<? super A2, ? extends R2> v2;
protected final ValueValidator<? super A3, ? extends R3> v3;
protected final ValueValidator<? super A4, ? extends R4> v4;
protected final ValueValidator<? super A5, ? extends R5> v5;
protected final ValueValidator<? super A6, ? extends R6> v6;
protected final ValueValidator<? super A7, ? extends R7> v7;
protected final ValueValidator<? super A8, ? extends R8> v8;
protected final ValueValidator<? super A9, ? extends R9> v9;
protected final ValueValidator<? super A10, ? extends R10> v10;
protected final ValueValidator<? super A11, ? extends R11> v11;
protected final ValueValidator<? super A12, ? extends R12> v12;
public Arguments12Splitting(ValueValidator<? super A1, ? extends R1> v1,
ValueValidator<? super A2, ? extends R2> v2, ValueValidator<? super A3, ? extends R3> v3,
ValueValidator<? super A4, ? extends R4> v4, ValueValidator<? super A5, ? extends R5> v5,
ValueValidator<? super A6, ? extends R6> v6, ValueValidator<? super A7, ? extends R7> v7,
ValueValidator<? super A8, ? extends R8> v8, ValueValidator<? super A9, ? extends R9> v9,
ValueValidator<? super A10, ? extends R10> v10, ValueValidator<? super A11, ? extends R11> v11,
ValueValidator<? super A12, ? extends R12> v12) {
this.v1 = v1;
this.v2 = v2;
this.v3 = v3;
this.v4 = v4;
this.v5 = v5;
this.v6 = v6;
this.v7 = v7;
this.v8 = v8;
this.v9 = v9;
this.v10 = v10;
this.v11 = v11;
this.v12 = v12;
}
public <X> Arguments12Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, X> apply(
Function12<? super R1, ? super R2, ? super R3, ? super R4, ? super R5, ? super R6, ? super R7, ? super R8, ? super R9, ? super R10, ? super R11, ? super R12, ? extends X> f) {
return new Arguments12Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, X>() {
@Override
public Arguments12Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, Supplier<X>> lazy() {
return ((a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, locale,
constraintContext) -> Validations.apply(
(r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11,
r12) -> () -> f.apply(r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12),
v1.validate(a1, locale, constraintContext), v2.validate(a2, locale, constraintContext),
v3.validate(a3, locale, constraintContext), v4.validate(a4, locale, constraintContext),
v5.validate(a5, locale, constraintContext), v6.validate(a6, locale, constraintContext),
v7.validate(a7, locale, constraintContext), v8.validate(a8, locale, constraintContext),
v9.validate(a9, locale, constraintContext),
v10.validate(a10, locale, constraintContext),
v11.validate(a11, locale, constraintContext),
v12.validate(a12, locale, constraintContext)));
}
@Override
public Validated<X> validate(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4,
@Nullable A5 a5, @Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9,
@Nullable A10 a10, @Nullable A11 a11, @Nullable A12 a12, Locale locale,
ConstraintContext constraintContext) {
return Validations.apply(f::apply, v1.validate(a1, locale, constraintContext),
v2.validate(a2, locale, constraintContext), v3.validate(a3, locale, constraintContext),
v4.validate(a4, locale, constraintContext), v5.validate(a5, locale, constraintContext),
v6.validate(a6, locale, constraintContext), v7.validate(a7, locale, constraintContext),
v8.validate(a8, locale, constraintContext), v9.validate(a9, locale, constraintContext),
v10.validate(a10, locale, constraintContext), v11.validate(a11, locale, constraintContext),
v12.validate(a12, locale, constraintContext));
}
};
}
public <A13, R13> Arguments13Splitting<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13> split(
ValueValidator<? super A13, ? extends R13> v13) {
return new Arguments13Splitting<>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13);
}
}
|
0 | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi/arguments/Arguments12Validator.java | /*
* Copyright (C) 2018-2025 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.yavi.arguments;
import java.util.Locale;
import java.util.Objects;
import java.util.function.Function;
import java.util.function.Supplier;
import am.ik.yavi.core.ConstraintContext;
import am.ik.yavi.core.ConstraintGroup;
import am.ik.yavi.core.ConstraintViolationsException;
import am.ik.yavi.core.Validated;
import am.ik.yavi.core.ValueValidator;
import am.ik.yavi.jsr305.Nullable;
/**
* Generated by https://github.com/making/yavi/blob/develop/scripts/generate-args.sh
*
* @since 0.3.0
*/
@FunctionalInterface
public interface Arguments12Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, X> {
/**
* Convert an Arguments1Validator that validates Arguments12 to an
* Arguments12Validator
* @param validator validator for Arguments12
* @param <A1> type of first argument
* @param <A2> type of argument at position 2
* @param <A3> type of argument at position 3
* @param <A4> type of argument at position 4
* @param <A5> type of argument at position 5
* @param <A6> type of argument at position 6
* @param <A7> type of argument at position 7
* @param <A8> type of argument at position 8
* @param <A9> type of argument at position 9
* @param <A10> type of argument at position 10
* @param <A11> type of argument at position 11
* @param <A12> type of argument at position 12
* @param <X> target result type
* @return arguments12 validator that takes arguments directly
* @since 0.16.0
*/
static <A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, X> Arguments12Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, X> unwrap(
Arguments1Validator<Arguments12<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12>, X> validator) {
return new Arguments12Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, X>() {
@Override
public Validated<X> validate(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4,
@Nullable A5 a5, @Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9,
@Nullable A10 a10, @Nullable A11 a11, @Nullable A12 a12, Locale locale,
ConstraintContext constraintContext) {
return validator.validate(Arguments.of(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12), locale,
constraintContext);
}
@Override
public Arguments12Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, Supplier<X>> lazy() {
return Arguments12Validator.unwrap(validator.lazy());
}
};
}
Validated<X> validate(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4, @Nullable A5 a5,
@Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9, @Nullable A10 a10, @Nullable A11 a11,
@Nullable A12 a12, Locale locale, ConstraintContext constraintContext);
/**
* Convert this validator to one that validates Arguments12 as a single object.
* @return a validator that takes an Arguments12
* @since 0.16.0
*/
default Arguments1Validator<Arguments12<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12>, X> wrap() {
return new Arguments1Validator<Arguments12<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12>, X>() {
@Override
public Validated<X> validate(Arguments12<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12> args,
Locale locale, ConstraintContext constraintContext) {
final Arguments12<? extends A1, ? extends A2, ? extends A3, ? extends A4, ? extends A5, ? extends A6, ? extends A7, ? extends A8, ? extends A9, ? extends A10, ? extends A11, ? extends A12> nonNullArgs = Objects
.requireNonNull(args);
return Arguments12Validator.this.validate(nonNullArgs.arg1(), nonNullArgs.arg2(), nonNullArgs.arg3(),
nonNullArgs.arg4(), nonNullArgs.arg5(), nonNullArgs.arg6(), nonNullArgs.arg7(),
nonNullArgs.arg8(), nonNullArgs.arg9(), nonNullArgs.arg10(), nonNullArgs.arg11(),
nonNullArgs.arg12(), locale, constraintContext);
}
@Override
public Arguments1Validator<Arguments12<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12>, Supplier<X>> lazy() {
return Arguments12Validator.this.lazy().wrap();
}
};
}
/**
* @since 0.7.0
*/
default <X2> Arguments12Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, X2> andThen(
Function<? super X, ? extends X2> mapper) {
return new Arguments12Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, X2>() {
@Override
public Validated<X2> validate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10,
A11 a11, A12 a12, Locale locale, ConstraintContext constraintContext) {
return Arguments12Validator.this
.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, locale, constraintContext)
.map(mapper);
}
@Override
public Arguments12Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, Supplier<X2>> lazy() {
return Arguments12Validator.this.lazy()
.andThen((Function<Supplier<X>, Supplier<X2>>) xSupplier -> () -> mapper.apply(xSupplier.get()));
}
};
}
/**
* @since 0.11.0
*/
default <X2> Arguments12Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, X2> andThen(
ValueValidator<? super X, X2> validator) {
return new Arguments12Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, X2>() {
@Override
public Validated<X2> validate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10,
A11 a11, A12 a12, Locale locale, ConstraintContext constraintContext) {
return Arguments12Validator.this
.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, locale, constraintContext)
.flatMap(v -> validator.validate(v, locale, constraintContext));
}
@Override
public Arguments12Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, Supplier<X2>> lazy() {
return Arguments12Validator.this.lazy()
.andThen((xSupplier, locale, constraintContext) -> validator
.validate(Objects.requireNonNull(xSupplier).get(), locale, constraintContext)
.map(x2 -> () -> x2));
}
};
}
/**
* @since 0.7.0
*/
default <A> Arguments1Validator<A, X> compose(
Function<? super A, ? extends Arguments12<? extends A1, ? extends A2, ? extends A3, ? extends A4, ? extends A5, ? extends A6, ? extends A7, ? extends A8, ? extends A9, ? extends A10, ? extends A11, ? extends A12>> mapper) {
return new Arguments1Validator<A, X>() {
@Override
public Validated<X> validate(A a, Locale locale, ConstraintContext constraintContext) {
final Arguments12<? extends A1, ? extends A2, ? extends A3, ? extends A4, ? extends A5, ? extends A6, ? extends A7, ? extends A8, ? extends A9, ? extends A10, ? extends A11, ? extends A12> args = mapper
.apply(a);
return Arguments12Validator.this.validate(args.arg1(), args.arg2(), args.arg3(), args.arg4(),
args.arg5(), args.arg6(), args.arg7(), args.arg8(), args.arg9(), args.arg10(), args.arg11(),
args.arg12(), locale, constraintContext);
}
@Override
public Arguments1Validator<A, Supplier<X>> lazy() {
return Arguments12Validator.this.lazy().compose(mapper);
}
};
}
/**
* @since 0.10.0
*/
default Arguments12Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, Supplier<X>> lazy() {
throw new UnsupportedOperationException("lazy is not implemented!");
}
default Validated<X> validate(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4, @Nullable A5 a5,
@Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9, @Nullable A10 a10, @Nullable A11 a11,
@Nullable A12 a12) {
return this.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, Locale.getDefault(),
ConstraintGroup.DEFAULT);
}
default Validated<X> validate(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4, @Nullable A5 a5,
@Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9, @Nullable A10 a10, @Nullable A11 a11,
@Nullable A12 a12, ConstraintContext constraintContext) {
return this.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, Locale.getDefault(), constraintContext);
}
default Validated<X> validate(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4, @Nullable A5 a5,
@Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9, @Nullable A10 a10, @Nullable A11 a11,
@Nullable A12 a12, Locale locale) {
return this.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, locale, ConstraintGroup.DEFAULT);
}
default X validated(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4, @Nullable A5 a5,
@Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9, @Nullable A10 a10, @Nullable A11 a11,
@Nullable A12 a12) throws ConstraintViolationsException {
return this.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12)
.orElseThrow(ConstraintViolationsException::new);
}
default X validated(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4, @Nullable A5 a5,
@Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9, @Nullable A10 a10, @Nullable A11 a11,
@Nullable A12 a12, ConstraintContext constraintContext) throws ConstraintViolationsException {
return this.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, constraintContext)
.orElseThrow(ConstraintViolationsException::new);
}
default X validated(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4, @Nullable A5 a5,
@Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9, @Nullable A10 a10, @Nullable A11 a11,
@Nullable A12 a12, Locale locale) throws ConstraintViolationsException {
return this.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, locale)
.orElseThrow(ConstraintViolationsException::new);
}
default X validated(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4, @Nullable A5 a5,
@Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9, @Nullable A10 a10, @Nullable A11 a11,
@Nullable A12 a12, Locale locale, ConstraintContext constraintContext)
throws ConstraintViolationsException {
return this.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, locale, constraintContext)
.orElseThrow(ConstraintViolationsException::new);
}
}
|
0 | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi/arguments/Arguments13.java | /*
* Copyright (C) 2018-2025 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.yavi.arguments;
import java.util.Objects;
import am.ik.yavi.fn.Function13;
import am.ik.yavi.jsr305.Nullable;
/**
* A container class that holds 13 arguments, providing type-safe access to each argument
* and mapping functionality to transform these arguments.
*
* Generated by https://github.com/making/yavi/blob/develop/scripts/generate-args.sh
*
* @param <A1> the type of argument at position 1
* @param <A2> the type of argument at position 2
* @param <A3> the type of argument at position 3
* @param <A4> the type of argument at position 4
* @param <A5> the type of argument at position 5
* @param <A6> the type of argument at position 6
* @param <A7> the type of argument at position 7
* @param <A8> the type of argument at position 8
* @param <A9> the type of argument at position 9
* @param <A10> the type of argument at position 10
* @param <A11> the type of argument at position 11
* @param <A12> the type of argument at position 12
* @param <A13> the type of argument at position 13
* @since 0.3.0
*/
public final class Arguments13<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13> {
private final A1 arg1;
private final A2 arg2;
private final A3 arg3;
private final A4 arg4;
private final A5 arg5;
private final A6 arg6;
private final A7 arg7;
private final A8 arg8;
private final A9 arg9;
private final A10 arg10;
private final A11 arg11;
private final A12 arg12;
private final A13 arg13;
/**
* Creates a new Arguments13 instance with the provided arguments.
* @param arg1 the argument at position 1, arg2 the argument at position 2, arg3 the
* argument at position 3, arg4 the argument at position 4, arg5 the argument at
* position 5, arg6 the argument at position 6, arg7 the argument at position 7, arg8
* the argument at position 8, arg9 the argument at position 9, arg10 the argument at
* position 10, arg11 the argument at position 11, arg12 the argument at position 12,
* arg13 the argument at position 13
*/
Arguments13(@Nullable A1 arg1, @Nullable A2 arg2, @Nullable A3 arg3, @Nullable A4 arg4, @Nullable A5 arg5,
@Nullable A6 arg6, @Nullable A7 arg7, @Nullable A8 arg8, @Nullable A9 arg9, @Nullable A10 arg10,
@Nullable A11 arg11, @Nullable A12 arg12, @Nullable A13 arg13) {
this.arg1 = arg1;
this.arg2 = arg2;
this.arg3 = arg3;
this.arg4 = arg4;
this.arg5 = arg5;
this.arg6 = arg6;
this.arg7 = arg7;
this.arg8 = arg8;
this.arg9 = arg9;
this.arg10 = arg10;
this.arg11 = arg11;
this.arg12 = arg12;
this.arg13 = arg13;
}
/**
* Returns the argument at position 1.
* @return the argument at position 1
*/
@Nullable
public A1 arg1() {
return this.arg1;
}
/**
* Returns the argument at position 2.
* @return the argument at position 2
*/
@Nullable
public A2 arg2() {
return this.arg2;
}
/**
* Returns the argument at position 3.
* @return the argument at position 3
*/
@Nullable
public A3 arg3() {
return this.arg3;
}
/**
* Returns the argument at position 4.
* @return the argument at position 4
*/
@Nullable
public A4 arg4() {
return this.arg4;
}
/**
* Returns the argument at position 5.
* @return the argument at position 5
*/
@Nullable
public A5 arg5() {
return this.arg5;
}
/**
* Returns the argument at position 6.
* @return the argument at position 6
*/
@Nullable
public A6 arg6() {
return this.arg6;
}
/**
* Returns the argument at position 7.
* @return the argument at position 7
*/
@Nullable
public A7 arg7() {
return this.arg7;
}
/**
* Returns the argument at position 8.
* @return the argument at position 8
*/
@Nullable
public A8 arg8() {
return this.arg8;
}
/**
* Returns the argument at position 9.
* @return the argument at position 9
*/
@Nullable
public A9 arg9() {
return this.arg9;
}
/**
* Returns the argument at position 10.
* @return the argument at position 10
*/
@Nullable
public A10 arg10() {
return this.arg10;
}
/**
* Returns the argument at position 11.
* @return the argument at position 11
*/
@Nullable
public A11 arg11() {
return this.arg11;
}
/**
* Returns the argument at position 12.
* @return the argument at position 12
*/
@Nullable
public A12 arg12() {
return this.arg12;
}
/**
* Returns the argument at position 13.
* @return the argument at position 13
*/
@Nullable
public A13 arg13() {
return this.arg13;
}
/**
* Applies the provided mapping function to all arguments contained in this instance.
* @param <X> the type of the result
* @param mapper the function to apply to the arguments
* @return the result of applying the mapper function to the arguments
*/
public <X> X map(
Function13<? super A1, ? super A2, ? super A3, ? super A4, ? super A5, ? super A6, ? super A7, ? super A8, ? super A9, ? super A10, ? super A11, ? super A12, ? super A13, ? extends X> mapper) {
return mapper.apply(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13);
}
/**
* Returns a new Arguments1 instance containing only the first 1 arguments.
* @return an Arguments1 instance with arguments from arg1 to arg1
* @since 0.16.0
*/
public Arguments1<A1> first1() {
return new Arguments1<>(arg1);
}
/**
* Returns a new Arguments2 instance containing only the first 2 arguments.
* @return an Arguments2 instance with arguments from arg1 to arg2
* @since 0.16.0
*/
public Arguments2<A1, A2> first2() {
return new Arguments2<>(arg1, arg2);
}
/**
* Returns a new Arguments3 instance containing only the first 3 arguments.
* @return an Arguments3 instance with arguments from arg1 to arg3
* @since 0.16.0
*/
public Arguments3<A1, A2, A3> first3() {
return new Arguments3<>(arg1, arg2, arg3);
}
/**
* Returns a new Arguments4 instance containing only the first 4 arguments.
* @return an Arguments4 instance with arguments from arg1 to arg4
* @since 0.16.0
*/
public Arguments4<A1, A2, A3, A4> first4() {
return new Arguments4<>(arg1, arg2, arg3, arg4);
}
/**
* Returns a new Arguments5 instance containing only the first 5 arguments.
* @return an Arguments5 instance with arguments from arg1 to arg5
* @since 0.16.0
*/
public Arguments5<A1, A2, A3, A4, A5> first5() {
return new Arguments5<>(arg1, arg2, arg3, arg4, arg5);
}
/**
* Returns a new Arguments6 instance containing only the first 6 arguments.
* @return an Arguments6 instance with arguments from arg1 to arg6
* @since 0.16.0
*/
public Arguments6<A1, A2, A3, A4, A5, A6> first6() {
return new Arguments6<>(arg1, arg2, arg3, arg4, arg5, arg6);
}
/**
* Returns a new Arguments7 instance containing only the first 7 arguments.
* @return an Arguments7 instance with arguments from arg1 to arg7
* @since 0.16.0
*/
public Arguments7<A1, A2, A3, A4, A5, A6, A7> first7() {
return new Arguments7<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7);
}
/**
* Returns a new Arguments8 instance containing only the first 8 arguments.
* @return an Arguments8 instance with arguments from arg1 to arg8
* @since 0.16.0
*/
public Arguments8<A1, A2, A3, A4, A5, A6, A7, A8> first8() {
return new Arguments8<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
}
/**
* Returns a new Arguments9 instance containing only the first 9 arguments.
* @return an Arguments9 instance with arguments from arg1 to arg9
* @since 0.16.0
*/
public Arguments9<A1, A2, A3, A4, A5, A6, A7, A8, A9> first9() {
return new Arguments9<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
}
/**
* Returns a new Arguments10 instance containing only the first 10 arguments.
* @return an Arguments10 instance with arguments from arg1 to arg10
* @since 0.16.0
*/
public Arguments10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10> first10() {
return new Arguments10<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
}
/**
* Returns a new Arguments11 instance containing only the first 11 arguments.
* @return an Arguments11 instance with arguments from arg1 to arg11
* @since 0.16.0
*/
public Arguments11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11> first11() {
return new Arguments11<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11);
}
/**
* Returns a new Arguments12 instance containing only the first 12 arguments.
* @return an Arguments12 instance with arguments from arg1 to arg12
* @since 0.16.0
*/
public Arguments12<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12> first12() {
return new Arguments12<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12);
}
/**
* Returns a new Arguments1 instance containing only the last 1 arguments.
* @return an Arguments1 instance with arguments from arg13 to arg13
* @since 0.16.0
*/
public Arguments1<A13> last1() {
return new Arguments1<>(arg13);
}
/**
* Returns a new Arguments2 instance containing only the last 2 arguments.
* @return an Arguments2 instance with arguments from arg12 to arg13
* @since 0.16.0
*/
public Arguments2<A12, A13> last2() {
return new Arguments2<>(arg12, arg13);
}
/**
* Returns a new Arguments3 instance containing only the last 3 arguments.
* @return an Arguments3 instance with arguments from arg11 to arg13
* @since 0.16.0
*/
public Arguments3<A11, A12, A13> last3() {
return new Arguments3<>(arg11, arg12, arg13);
}
/**
* Returns a new Arguments4 instance containing only the last 4 arguments.
* @return an Arguments4 instance with arguments from arg10 to arg13
* @since 0.16.0
*/
public Arguments4<A10, A11, A12, A13> last4() {
return new Arguments4<>(arg10, arg11, arg12, arg13);
}
/**
* Returns a new Arguments5 instance containing only the last 5 arguments.
* @return an Arguments5 instance with arguments from arg9 to arg13
* @since 0.16.0
*/
public Arguments5<A9, A10, A11, A12, A13> last5() {
return new Arguments5<>(arg9, arg10, arg11, arg12, arg13);
}
/**
* Returns a new Arguments6 instance containing only the last 6 arguments.
* @return an Arguments6 instance with arguments from arg8 to arg13
* @since 0.16.0
*/
public Arguments6<A8, A9, A10, A11, A12, A13> last6() {
return new Arguments6<>(arg8, arg9, arg10, arg11, arg12, arg13);
}
/**
* Returns a new Arguments7 instance containing only the last 7 arguments.
* @return an Arguments7 instance with arguments from arg7 to arg13
* @since 0.16.0
*/
public Arguments7<A7, A8, A9, A10, A11, A12, A13> last7() {
return new Arguments7<>(arg7, arg8, arg9, arg10, arg11, arg12, arg13);
}
/**
* Returns a new Arguments8 instance containing only the last 8 arguments.
* @return an Arguments8 instance with arguments from arg6 to arg13
* @since 0.16.0
*/
public Arguments8<A6, A7, A8, A9, A10, A11, A12, A13> last8() {
return new Arguments8<>(arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13);
}
/**
* Returns a new Arguments9 instance containing only the last 9 arguments.
* @return an Arguments9 instance with arguments from arg5 to arg13
* @since 0.16.0
*/
public Arguments9<A5, A6, A7, A8, A9, A10, A11, A12, A13> last9() {
return new Arguments9<>(arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13);
}
/**
* Returns a new Arguments10 instance containing only the last 10 arguments.
* @return an Arguments10 instance with arguments from arg4 to arg13
* @since 0.16.0
*/
public Arguments10<A4, A5, A6, A7, A8, A9, A10, A11, A12, A13> last10() {
return new Arguments10<>(arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13);
}
/**
* Returns a new Arguments11 instance containing only the last 11 arguments.
* @return an Arguments11 instance with arguments from arg3 to arg13
* @since 0.16.0
*/
public Arguments11<A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13> last11() {
return new Arguments11<>(arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13);
}
/**
* Returns a new Arguments12 instance containing only the last 12 arguments.
* @return an Arguments12 instance with arguments from arg2 to arg13
* @since 0.16.0
*/
public Arguments12<A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13> last12() {
return new Arguments12<>(arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13);
}
/**
* Appends an additional argument to create a new, larger Arguments instance.
* @param <B> the type of the argument to append
* @param arg the argument to append
* @return a new Arguments14 instance with the additional argument
* @since 0.16.0
*/
public <B> Arguments14<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, B> append(@Nullable B arg) {
return new Arguments14<>(this.arg1, this.arg2, this.arg3, this.arg4, this.arg5, this.arg6, this.arg7, this.arg8,
this.arg9, this.arg10, this.arg11, this.arg12, this.arg13, arg);
}
/**
* Prepends an additional argument to create a new, larger Arguments instance.
* @param <B> the type of the argument to prepend
* @param arg the argument to prepend
* @return a new Arguments14 instance with the additional argument
* @since 0.16.0
*/
public <B> Arguments14<B, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13> prepend(@Nullable B arg) {
return new Arguments14<>(arg, this.arg1, this.arg2, this.arg3, this.arg4, this.arg5, this.arg6, this.arg7,
this.arg8, this.arg9, this.arg10, this.arg11, this.arg12, this.arg13);
}
/**
* Returns a new Arguments13 instance with the arguments in reverse order.
* @return an Arguments13 instance with arguments in reverse order
* @since 0.16.0
*/
public Arguments13<A13, A12, A11, A10, A9, A8, A7, A6, A5, A4, A3, A2, A1> reverse() {
return new Arguments13<>(arg13, arg12, arg11, arg10, arg9, arg8, arg7, arg6, arg5, arg4, arg3, arg2, arg1);
}
/**
* Indicates whether some other object is "equal to" this one.
* @param obj the reference object with which to compare
* @return true if this object is the same as the obj argument; false otherwise
*/
@Override
@SuppressWarnings("unchecked")
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
Arguments13<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13> that = (Arguments13<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13>) obj;
return Objects.equals(this.arg1, that.arg1) && Objects.equals(this.arg2, that.arg2)
&& Objects.equals(this.arg3, that.arg3) && Objects.equals(this.arg4, that.arg4)
&& Objects.equals(this.arg5, that.arg5) && Objects.equals(this.arg6, that.arg6)
&& Objects.equals(this.arg7, that.arg7) && Objects.equals(this.arg8, that.arg8)
&& Objects.equals(this.arg9, that.arg9) && Objects.equals(this.arg10, that.arg10)
&& Objects.equals(this.arg11, that.arg11) && Objects.equals(this.arg12, that.arg12)
&& Objects.equals(this.arg13, that.arg13);
}
/**
* Returns a hash code value for the object.
* @return a hash code value for this object
*/
@Override
public int hashCode() {
return Objects.hash(this.arg1, this.arg2, this.arg3, this.arg4, this.arg5, this.arg6, this.arg7, this.arg8,
this.arg9, this.arg10, this.arg11, this.arg12, this.arg13);
}
/**
* Returns a string representation of the object.
* @return a string representation of the object
*/
@Override
public String toString() {
return "Arguments13{" + "arg1=" + this.arg1 + ", " + "arg2=" + this.arg2 + ", " + "arg3=" + this.arg3 + ", "
+ "arg4=" + this.arg4 + ", " + "arg5=" + this.arg5 + ", " + "arg6=" + this.arg6 + ", " + "arg7="
+ this.arg7 + ", " + "arg8=" + this.arg8 + ", " + "arg9=" + this.arg9 + ", " + "arg10=" + this.arg10
+ ", " + "arg11=" + this.arg11 + ", " + "arg12=" + this.arg12 + ", " + "arg13=" + this.arg13 + "}";
}
}
|
0 | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi/arguments/Arguments13Combining.java | /*
* Copyright (C) 2018-2025 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.yavi.arguments;
import am.ik.yavi.core.ConstraintContext;
import am.ik.yavi.core.Validated;
import am.ik.yavi.core.ValueValidator;
import am.ik.yavi.fn.Function13;
import am.ik.yavi.fn.Validations;
import java.util.Locale;
import java.util.function.Supplier;
/**
* Generated by https://github.com/making/yavi/blob/develop/scripts/generate-args.sh
*
* @since 0.7.0
*/
public class Arguments13Combining<A, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13> {
protected final ValueValidator<? super A, ? extends R1> v1;
protected final ValueValidator<? super A, ? extends R2> v2;
protected final ValueValidator<? super A, ? extends R3> v3;
protected final ValueValidator<? super A, ? extends R4> v4;
protected final ValueValidator<? super A, ? extends R5> v5;
protected final ValueValidator<? super A, ? extends R6> v6;
protected final ValueValidator<? super A, ? extends R7> v7;
protected final ValueValidator<? super A, ? extends R8> v8;
protected final ValueValidator<? super A, ? extends R9> v9;
protected final ValueValidator<? super A, ? extends R10> v10;
protected final ValueValidator<? super A, ? extends R11> v11;
protected final ValueValidator<? super A, ? extends R12> v12;
protected final ValueValidator<? super A, ? extends R13> v13;
public Arguments13Combining(ValueValidator<? super A, ? extends R1> v1, ValueValidator<? super A, ? extends R2> v2,
ValueValidator<? super A, ? extends R3> v3, ValueValidator<? super A, ? extends R4> v4,
ValueValidator<? super A, ? extends R5> v5, ValueValidator<? super A, ? extends R6> v6,
ValueValidator<? super A, ? extends R7> v7, ValueValidator<? super A, ? extends R8> v8,
ValueValidator<? super A, ? extends R9> v9, ValueValidator<? super A, ? extends R10> v10,
ValueValidator<? super A, ? extends R11> v11, ValueValidator<? super A, ? extends R12> v12,
ValueValidator<? super A, ? extends R13> v13) {
this.v1 = v1;
this.v2 = v2;
this.v3 = v3;
this.v4 = v4;
this.v5 = v5;
this.v6 = v6;
this.v7 = v7;
this.v8 = v8;
this.v9 = v9;
this.v10 = v10;
this.v11 = v11;
this.v12 = v12;
this.v13 = v13;
}
public <X> Arguments1Validator<A, X> apply(
Function13<? super R1, ? super R2, ? super R3, ? super R4, ? super R5, ? super R6, ? super R7, ? super R8, ? super R9, ? super R10, ? super R11, ? super R12, ? super R13, ? extends X> f) {
return new Arguments1Validator<A, X>() {
@Override
public Validated<X> validate(A a, Locale locale, ConstraintContext constraintContext) {
return Validations.apply(f::apply, Arguments13Combining.this.v1.validate(a, locale, constraintContext),
Arguments13Combining.this.v2.validate(a, locale, constraintContext),
Arguments13Combining.this.v3.validate(a, locale, constraintContext),
Arguments13Combining.this.v4.validate(a, locale, constraintContext),
Arguments13Combining.this.v5.validate(a, locale, constraintContext),
Arguments13Combining.this.v6.validate(a, locale, constraintContext),
Arguments13Combining.this.v7.validate(a, locale, constraintContext),
Arguments13Combining.this.v8.validate(a, locale, constraintContext),
Arguments13Combining.this.v9.validate(a, locale, constraintContext),
Arguments13Combining.this.v10.validate(a, locale, constraintContext),
Arguments13Combining.this.v11.validate(a, locale, constraintContext),
Arguments13Combining.this.v12.validate(a, locale, constraintContext),
Arguments13Combining.this.v13.validate(a, locale, constraintContext));
}
@Override
public Arguments1Validator<A, Supplier<X>> lazy() {
return (a, locale, constraintContext) -> Validations.apply(
(r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12,
r13) -> () -> f.apply(r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13),
Arguments13Combining.this.v1.validate(a, locale, constraintContext),
Arguments13Combining.this.v2.validate(a, locale, constraintContext),
Arguments13Combining.this.v3.validate(a, locale, constraintContext),
Arguments13Combining.this.v4.validate(a, locale, constraintContext),
Arguments13Combining.this.v5.validate(a, locale, constraintContext),
Arguments13Combining.this.v6.validate(a, locale, constraintContext),
Arguments13Combining.this.v7.validate(a, locale, constraintContext),
Arguments13Combining.this.v8.validate(a, locale, constraintContext),
Arguments13Combining.this.v9.validate(a, locale, constraintContext),
Arguments13Combining.this.v10.validate(a, locale, constraintContext),
Arguments13Combining.this.v11.validate(a, locale, constraintContext),
Arguments13Combining.this.v12.validate(a, locale, constraintContext),
Arguments13Combining.this.v13.validate(a, locale, constraintContext));
}
};
}
public <R14> Arguments14Combining<A, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14> combine(
ValueValidator<? super A, ? extends R14> v14) {
return new Arguments14Combining<>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14);
}
}
|
0 | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi/arguments/Arguments13Splitting.java | /*
* Copyright (C) 2018-2025 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.yavi.arguments;
import java.util.Locale;
import java.util.function.Supplier;
import am.ik.yavi.core.ConstraintContext;
import am.ik.yavi.core.Validated;
import am.ik.yavi.core.ValueValidator;
import am.ik.yavi.fn.Function13;
import am.ik.yavi.fn.Validations;
import am.ik.yavi.jsr305.Nullable;
/**
* Generated by https://github.com/making/yavi/blob/develop/scripts/generate-args.sh
*
* @since 0.7.0
*/
public class Arguments13Splitting<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13> {
protected final ValueValidator<? super A1, ? extends R1> v1;
protected final ValueValidator<? super A2, ? extends R2> v2;
protected final ValueValidator<? super A3, ? extends R3> v3;
protected final ValueValidator<? super A4, ? extends R4> v4;
protected final ValueValidator<? super A5, ? extends R5> v5;
protected final ValueValidator<? super A6, ? extends R6> v6;
protected final ValueValidator<? super A7, ? extends R7> v7;
protected final ValueValidator<? super A8, ? extends R8> v8;
protected final ValueValidator<? super A9, ? extends R9> v9;
protected final ValueValidator<? super A10, ? extends R10> v10;
protected final ValueValidator<? super A11, ? extends R11> v11;
protected final ValueValidator<? super A12, ? extends R12> v12;
protected final ValueValidator<? super A13, ? extends R13> v13;
public Arguments13Splitting(ValueValidator<? super A1, ? extends R1> v1,
ValueValidator<? super A2, ? extends R2> v2, ValueValidator<? super A3, ? extends R3> v3,
ValueValidator<? super A4, ? extends R4> v4, ValueValidator<? super A5, ? extends R5> v5,
ValueValidator<? super A6, ? extends R6> v6, ValueValidator<? super A7, ? extends R7> v7,
ValueValidator<? super A8, ? extends R8> v8, ValueValidator<? super A9, ? extends R9> v9,
ValueValidator<? super A10, ? extends R10> v10, ValueValidator<? super A11, ? extends R11> v11,
ValueValidator<? super A12, ? extends R12> v12, ValueValidator<? super A13, ? extends R13> v13) {
this.v1 = v1;
this.v2 = v2;
this.v3 = v3;
this.v4 = v4;
this.v5 = v5;
this.v6 = v6;
this.v7 = v7;
this.v8 = v8;
this.v9 = v9;
this.v10 = v10;
this.v11 = v11;
this.v12 = v12;
this.v13 = v13;
}
public <X> Arguments13Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, X> apply(
Function13<? super R1, ? super R2, ? super R3, ? super R4, ? super R5, ? super R6, ? super R7, ? super R8, ? super R9, ? super R10, ? super R11, ? super R12, ? super R13, ? extends X> f) {
return new Arguments13Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, X>() {
@Override
public Arguments13Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, Supplier<X>> lazy() {
return ((a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, locale,
constraintContext) -> Validations.apply(
(r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12,
r13) -> () -> f.apply(r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13),
v1.validate(a1, locale, constraintContext), v2.validate(a2, locale, constraintContext),
v3.validate(a3, locale, constraintContext), v4.validate(a4, locale, constraintContext),
v5.validate(a5, locale, constraintContext), v6.validate(a6, locale, constraintContext),
v7.validate(a7, locale, constraintContext), v8.validate(a8, locale, constraintContext),
v9.validate(a9, locale, constraintContext),
v10.validate(a10, locale, constraintContext),
v11.validate(a11, locale, constraintContext),
v12.validate(a12, locale, constraintContext),
v13.validate(a13, locale, constraintContext)));
}
@Override
public Validated<X> validate(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4,
@Nullable A5 a5, @Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9,
@Nullable A10 a10, @Nullable A11 a11, @Nullable A12 a12, @Nullable A13 a13, Locale locale,
ConstraintContext constraintContext) {
return Validations.apply(f::apply, v1.validate(a1, locale, constraintContext),
v2.validate(a2, locale, constraintContext), v3.validate(a3, locale, constraintContext),
v4.validate(a4, locale, constraintContext), v5.validate(a5, locale, constraintContext),
v6.validate(a6, locale, constraintContext), v7.validate(a7, locale, constraintContext),
v8.validate(a8, locale, constraintContext), v9.validate(a9, locale, constraintContext),
v10.validate(a10, locale, constraintContext), v11.validate(a11, locale, constraintContext),
v12.validate(a12, locale, constraintContext), v13.validate(a13, locale, constraintContext));
}
};
}
public <A14, R14> Arguments14Splitting<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14> split(
ValueValidator<? super A14, ? extends R14> v14) {
return new Arguments14Splitting<>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14);
}
}
|
0 | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi/arguments/Arguments13Validator.java | /*
* Copyright (C) 2018-2025 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.yavi.arguments;
import java.util.Locale;
import java.util.Objects;
import java.util.function.Function;
import java.util.function.Supplier;
import am.ik.yavi.core.ConstraintContext;
import am.ik.yavi.core.ConstraintGroup;
import am.ik.yavi.core.ConstraintViolationsException;
import am.ik.yavi.core.Validated;
import am.ik.yavi.core.ValueValidator;
import am.ik.yavi.jsr305.Nullable;
/**
* Generated by https://github.com/making/yavi/blob/develop/scripts/generate-args.sh
*
* @since 0.3.0
*/
@FunctionalInterface
public interface Arguments13Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, X> {
/**
* Convert an Arguments1Validator that validates Arguments13 to an
* Arguments13Validator
* @param validator validator for Arguments13
* @param <A1> type of first argument
* @param <A2> type of argument at position 2
* @param <A3> type of argument at position 3
* @param <A4> type of argument at position 4
* @param <A5> type of argument at position 5
* @param <A6> type of argument at position 6
* @param <A7> type of argument at position 7
* @param <A8> type of argument at position 8
* @param <A9> type of argument at position 9
* @param <A10> type of argument at position 10
* @param <A11> type of argument at position 11
* @param <A12> type of argument at position 12
* @param <A13> type of argument at position 13
* @param <X> target result type
* @return arguments13 validator that takes arguments directly
* @since 0.16.0
*/
static <A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, X> Arguments13Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, X> unwrap(
Arguments1Validator<Arguments13<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13>, X> validator) {
return new Arguments13Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, X>() {
@Override
public Validated<X> validate(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4,
@Nullable A5 a5, @Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9,
@Nullable A10 a10, @Nullable A11 a11, @Nullable A12 a12, @Nullable A13 a13, Locale locale,
ConstraintContext constraintContext) {
return validator.validate(Arguments.of(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13), locale,
constraintContext);
}
@Override
public Arguments13Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, Supplier<X>> lazy() {
return Arguments13Validator.unwrap(validator.lazy());
}
};
}
Validated<X> validate(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4, @Nullable A5 a5,
@Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9, @Nullable A10 a10, @Nullable A11 a11,
@Nullable A12 a12, @Nullable A13 a13, Locale locale, ConstraintContext constraintContext);
/**
* Convert this validator to one that validates Arguments13 as a single object.
* @return a validator that takes an Arguments13
* @since 0.16.0
*/
default Arguments1Validator<Arguments13<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13>, X> wrap() {
return new Arguments1Validator<Arguments13<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13>, X>() {
@Override
public Validated<X> validate(Arguments13<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13> args,
Locale locale, ConstraintContext constraintContext) {
final Arguments13<? extends A1, ? extends A2, ? extends A3, ? extends A4, ? extends A5, ? extends A6, ? extends A7, ? extends A8, ? extends A9, ? extends A10, ? extends A11, ? extends A12, ? extends A13> nonNullArgs = Objects
.requireNonNull(args);
return Arguments13Validator.this.validate(nonNullArgs.arg1(), nonNullArgs.arg2(), nonNullArgs.arg3(),
nonNullArgs.arg4(), nonNullArgs.arg5(), nonNullArgs.arg6(), nonNullArgs.arg7(),
nonNullArgs.arg8(), nonNullArgs.arg9(), nonNullArgs.arg10(), nonNullArgs.arg11(),
nonNullArgs.arg12(), nonNullArgs.arg13(), locale, constraintContext);
}
@Override
public Arguments1Validator<Arguments13<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13>, Supplier<X>> lazy() {
return Arguments13Validator.this.lazy().wrap();
}
};
}
/**
* @since 0.7.0
*/
default <X2> Arguments13Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, X2> andThen(
Function<? super X, ? extends X2> mapper) {
return new Arguments13Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, X2>() {
@Override
public Validated<X2> validate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10,
A11 a11, A12 a12, A13 a13, Locale locale, ConstraintContext constraintContext) {
return Arguments13Validator.this
.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, locale, constraintContext)
.map(mapper);
}
@Override
public Arguments13Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, Supplier<X2>> lazy() {
return Arguments13Validator.this.lazy()
.andThen((Function<Supplier<X>, Supplier<X2>>) xSupplier -> () -> mapper.apply(xSupplier.get()));
}
};
}
/**
* @since 0.11.0
*/
default <X2> Arguments13Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, X2> andThen(
ValueValidator<? super X, X2> validator) {
return new Arguments13Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, X2>() {
@Override
public Validated<X2> validate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10,
A11 a11, A12 a12, A13 a13, Locale locale, ConstraintContext constraintContext) {
return Arguments13Validator.this
.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, locale, constraintContext)
.flatMap(v -> validator.validate(v, locale, constraintContext));
}
@Override
public Arguments13Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, Supplier<X2>> lazy() {
return Arguments13Validator.this.lazy()
.andThen((xSupplier, locale, constraintContext) -> validator
.validate(Objects.requireNonNull(xSupplier).get(), locale, constraintContext)
.map(x2 -> () -> x2));
}
};
}
/**
* @since 0.7.0
*/
default <A> Arguments1Validator<A, X> compose(
Function<? super A, ? extends Arguments13<? extends A1, ? extends A2, ? extends A3, ? extends A4, ? extends A5, ? extends A6, ? extends A7, ? extends A8, ? extends A9, ? extends A10, ? extends A11, ? extends A12, ? extends A13>> mapper) {
return new Arguments1Validator<A, X>() {
@Override
public Validated<X> validate(A a, Locale locale, ConstraintContext constraintContext) {
final Arguments13<? extends A1, ? extends A2, ? extends A3, ? extends A4, ? extends A5, ? extends A6, ? extends A7, ? extends A8, ? extends A9, ? extends A10, ? extends A11, ? extends A12, ? extends A13> args = mapper
.apply(a);
return Arguments13Validator.this.validate(args.arg1(), args.arg2(), args.arg3(), args.arg4(),
args.arg5(), args.arg6(), args.arg7(), args.arg8(), args.arg9(), args.arg10(), args.arg11(),
args.arg12(), args.arg13(), locale, constraintContext);
}
@Override
public Arguments1Validator<A, Supplier<X>> lazy() {
return Arguments13Validator.this.lazy().compose(mapper);
}
};
}
/**
* @since 0.10.0
*/
default Arguments13Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, Supplier<X>> lazy() {
throw new UnsupportedOperationException("lazy is not implemented!");
}
default Validated<X> validate(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4, @Nullable A5 a5,
@Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9, @Nullable A10 a10, @Nullable A11 a11,
@Nullable A12 a12, @Nullable A13 a13) {
return this.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, Locale.getDefault(),
ConstraintGroup.DEFAULT);
}
default Validated<X> validate(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4, @Nullable A5 a5,
@Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9, @Nullable A10 a10, @Nullable A11 a11,
@Nullable A12 a12, @Nullable A13 a13, ConstraintContext constraintContext) {
return this.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, Locale.getDefault(),
constraintContext);
}
default Validated<X> validate(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4, @Nullable A5 a5,
@Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9, @Nullable A10 a10, @Nullable A11 a11,
@Nullable A12 a12, @Nullable A13 a13, Locale locale) {
return this.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, locale, ConstraintGroup.DEFAULT);
}
default X validated(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4, @Nullable A5 a5,
@Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9, @Nullable A10 a10, @Nullable A11 a11,
@Nullable A12 a12, @Nullable A13 a13) throws ConstraintViolationsException {
return this.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13)
.orElseThrow(ConstraintViolationsException::new);
}
default X validated(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4, @Nullable A5 a5,
@Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9, @Nullable A10 a10, @Nullable A11 a11,
@Nullable A12 a12, @Nullable A13 a13, ConstraintContext constraintContext)
throws ConstraintViolationsException {
return this.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, constraintContext)
.orElseThrow(ConstraintViolationsException::new);
}
default X validated(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4, @Nullable A5 a5,
@Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9, @Nullable A10 a10, @Nullable A11 a11,
@Nullable A12 a12, @Nullable A13 a13, Locale locale) throws ConstraintViolationsException {
return this.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, locale)
.orElseThrow(ConstraintViolationsException::new);
}
default X validated(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4, @Nullable A5 a5,
@Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9, @Nullable A10 a10, @Nullable A11 a11,
@Nullable A12 a12, @Nullable A13 a13, Locale locale, ConstraintContext constraintContext)
throws ConstraintViolationsException {
return this.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, locale, constraintContext)
.orElseThrow(ConstraintViolationsException::new);
}
}
|
0 | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi/arguments/Arguments14.java | /*
* Copyright (C) 2018-2025 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.yavi.arguments;
import java.util.Objects;
import am.ik.yavi.fn.Function14;
import am.ik.yavi.jsr305.Nullable;
/**
* A container class that holds 14 arguments, providing type-safe access to each argument
* and mapping functionality to transform these arguments.
*
* Generated by https://github.com/making/yavi/blob/develop/scripts/generate-args.sh
*
* @param <A1> the type of argument at position 1
* @param <A2> the type of argument at position 2
* @param <A3> the type of argument at position 3
* @param <A4> the type of argument at position 4
* @param <A5> the type of argument at position 5
* @param <A6> the type of argument at position 6
* @param <A7> the type of argument at position 7
* @param <A8> the type of argument at position 8
* @param <A9> the type of argument at position 9
* @param <A10> the type of argument at position 10
* @param <A11> the type of argument at position 11
* @param <A12> the type of argument at position 12
* @param <A13> the type of argument at position 13
* @param <A14> the type of argument at position 14
* @since 0.3.0
*/
public final class Arguments14<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14> {
private final A1 arg1;
private final A2 arg2;
private final A3 arg3;
private final A4 arg4;
private final A5 arg5;
private final A6 arg6;
private final A7 arg7;
private final A8 arg8;
private final A9 arg9;
private final A10 arg10;
private final A11 arg11;
private final A12 arg12;
private final A13 arg13;
private final A14 arg14;
/**
* Creates a new Arguments14 instance with the provided arguments.
* @param arg1 the argument at position 1, arg2 the argument at position 2, arg3 the
* argument at position 3, arg4 the argument at position 4, arg5 the argument at
* position 5, arg6 the argument at position 6, arg7 the argument at position 7, arg8
* the argument at position 8, arg9 the argument at position 9, arg10 the argument at
* position 10, arg11 the argument at position 11, arg12 the argument at position 12,
* arg13 the argument at position 13, arg14 the argument at position 14
*/
Arguments14(@Nullable A1 arg1, @Nullable A2 arg2, @Nullable A3 arg3, @Nullable A4 arg4, @Nullable A5 arg5,
@Nullable A6 arg6, @Nullable A7 arg7, @Nullable A8 arg8, @Nullable A9 arg9, @Nullable A10 arg10,
@Nullable A11 arg11, @Nullable A12 arg12, @Nullable A13 arg13, @Nullable A14 arg14) {
this.arg1 = arg1;
this.arg2 = arg2;
this.arg3 = arg3;
this.arg4 = arg4;
this.arg5 = arg5;
this.arg6 = arg6;
this.arg7 = arg7;
this.arg8 = arg8;
this.arg9 = arg9;
this.arg10 = arg10;
this.arg11 = arg11;
this.arg12 = arg12;
this.arg13 = arg13;
this.arg14 = arg14;
}
/**
* Returns the argument at position 1.
* @return the argument at position 1
*/
@Nullable
public A1 arg1() {
return this.arg1;
}
/**
* Returns the argument at position 2.
* @return the argument at position 2
*/
@Nullable
public A2 arg2() {
return this.arg2;
}
/**
* Returns the argument at position 3.
* @return the argument at position 3
*/
@Nullable
public A3 arg3() {
return this.arg3;
}
/**
* Returns the argument at position 4.
* @return the argument at position 4
*/
@Nullable
public A4 arg4() {
return this.arg4;
}
/**
* Returns the argument at position 5.
* @return the argument at position 5
*/
@Nullable
public A5 arg5() {
return this.arg5;
}
/**
* Returns the argument at position 6.
* @return the argument at position 6
*/
@Nullable
public A6 arg6() {
return this.arg6;
}
/**
* Returns the argument at position 7.
* @return the argument at position 7
*/
@Nullable
public A7 arg7() {
return this.arg7;
}
/**
* Returns the argument at position 8.
* @return the argument at position 8
*/
@Nullable
public A8 arg8() {
return this.arg8;
}
/**
* Returns the argument at position 9.
* @return the argument at position 9
*/
@Nullable
public A9 arg9() {
return this.arg9;
}
/**
* Returns the argument at position 10.
* @return the argument at position 10
*/
@Nullable
public A10 arg10() {
return this.arg10;
}
/**
* Returns the argument at position 11.
* @return the argument at position 11
*/
@Nullable
public A11 arg11() {
return this.arg11;
}
/**
* Returns the argument at position 12.
* @return the argument at position 12
*/
@Nullable
public A12 arg12() {
return this.arg12;
}
/**
* Returns the argument at position 13.
* @return the argument at position 13
*/
@Nullable
public A13 arg13() {
return this.arg13;
}
/**
* Returns the argument at position 14.
* @return the argument at position 14
*/
@Nullable
public A14 arg14() {
return this.arg14;
}
/**
* Applies the provided mapping function to all arguments contained in this instance.
* @param <X> the type of the result
* @param mapper the function to apply to the arguments
* @return the result of applying the mapper function to the arguments
*/
public <X> X map(
Function14<? super A1, ? super A2, ? super A3, ? super A4, ? super A5, ? super A6, ? super A7, ? super A8, ? super A9, ? super A10, ? super A11, ? super A12, ? super A13, ? super A14, ? extends X> mapper) {
return mapper.apply(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14);
}
/**
* Returns a new Arguments1 instance containing only the first 1 arguments.
* @return an Arguments1 instance with arguments from arg1 to arg1
* @since 0.16.0
*/
public Arguments1<A1> first1() {
return new Arguments1<>(arg1);
}
/**
* Returns a new Arguments2 instance containing only the first 2 arguments.
* @return an Arguments2 instance with arguments from arg1 to arg2
* @since 0.16.0
*/
public Arguments2<A1, A2> first2() {
return new Arguments2<>(arg1, arg2);
}
/**
* Returns a new Arguments3 instance containing only the first 3 arguments.
* @return an Arguments3 instance with arguments from arg1 to arg3
* @since 0.16.0
*/
public Arguments3<A1, A2, A3> first3() {
return new Arguments3<>(arg1, arg2, arg3);
}
/**
* Returns a new Arguments4 instance containing only the first 4 arguments.
* @return an Arguments4 instance with arguments from arg1 to arg4
* @since 0.16.0
*/
public Arguments4<A1, A2, A3, A4> first4() {
return new Arguments4<>(arg1, arg2, arg3, arg4);
}
/**
* Returns a new Arguments5 instance containing only the first 5 arguments.
* @return an Arguments5 instance with arguments from arg1 to arg5
* @since 0.16.0
*/
public Arguments5<A1, A2, A3, A4, A5> first5() {
return new Arguments5<>(arg1, arg2, arg3, arg4, arg5);
}
/**
* Returns a new Arguments6 instance containing only the first 6 arguments.
* @return an Arguments6 instance with arguments from arg1 to arg6
* @since 0.16.0
*/
public Arguments6<A1, A2, A3, A4, A5, A6> first6() {
return new Arguments6<>(arg1, arg2, arg3, arg4, arg5, arg6);
}
/**
* Returns a new Arguments7 instance containing only the first 7 arguments.
* @return an Arguments7 instance with arguments from arg1 to arg7
* @since 0.16.0
*/
public Arguments7<A1, A2, A3, A4, A5, A6, A7> first7() {
return new Arguments7<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7);
}
/**
* Returns a new Arguments8 instance containing only the first 8 arguments.
* @return an Arguments8 instance with arguments from arg1 to arg8
* @since 0.16.0
*/
public Arguments8<A1, A2, A3, A4, A5, A6, A7, A8> first8() {
return new Arguments8<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
}
/**
* Returns a new Arguments9 instance containing only the first 9 arguments.
* @return an Arguments9 instance with arguments from arg1 to arg9
* @since 0.16.0
*/
public Arguments9<A1, A2, A3, A4, A5, A6, A7, A8, A9> first9() {
return new Arguments9<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
}
/**
* Returns a new Arguments10 instance containing only the first 10 arguments.
* @return an Arguments10 instance with arguments from arg1 to arg10
* @since 0.16.0
*/
public Arguments10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10> first10() {
return new Arguments10<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
}
/**
* Returns a new Arguments11 instance containing only the first 11 arguments.
* @return an Arguments11 instance with arguments from arg1 to arg11
* @since 0.16.0
*/
public Arguments11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11> first11() {
return new Arguments11<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11);
}
/**
* Returns a new Arguments12 instance containing only the first 12 arguments.
* @return an Arguments12 instance with arguments from arg1 to arg12
* @since 0.16.0
*/
public Arguments12<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12> first12() {
return new Arguments12<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12);
}
/**
* Returns a new Arguments13 instance containing only the first 13 arguments.
* @return an Arguments13 instance with arguments from arg1 to arg13
* @since 0.16.0
*/
public Arguments13<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13> first13() {
return new Arguments13<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13);
}
/**
* Returns a new Arguments1 instance containing only the last 1 arguments.
* @return an Arguments1 instance with arguments from arg14 to arg14
* @since 0.16.0
*/
public Arguments1<A14> last1() {
return new Arguments1<>(arg14);
}
/**
* Returns a new Arguments2 instance containing only the last 2 arguments.
* @return an Arguments2 instance with arguments from arg13 to arg14
* @since 0.16.0
*/
public Arguments2<A13, A14> last2() {
return new Arguments2<>(arg13, arg14);
}
/**
* Returns a new Arguments3 instance containing only the last 3 arguments.
* @return an Arguments3 instance with arguments from arg12 to arg14
* @since 0.16.0
*/
public Arguments3<A12, A13, A14> last3() {
return new Arguments3<>(arg12, arg13, arg14);
}
/**
* Returns a new Arguments4 instance containing only the last 4 arguments.
* @return an Arguments4 instance with arguments from arg11 to arg14
* @since 0.16.0
*/
public Arguments4<A11, A12, A13, A14> last4() {
return new Arguments4<>(arg11, arg12, arg13, arg14);
}
/**
* Returns a new Arguments5 instance containing only the last 5 arguments.
* @return an Arguments5 instance with arguments from arg10 to arg14
* @since 0.16.0
*/
public Arguments5<A10, A11, A12, A13, A14> last5() {
return new Arguments5<>(arg10, arg11, arg12, arg13, arg14);
}
/**
* Returns a new Arguments6 instance containing only the last 6 arguments.
* @return an Arguments6 instance with arguments from arg9 to arg14
* @since 0.16.0
*/
public Arguments6<A9, A10, A11, A12, A13, A14> last6() {
return new Arguments6<>(arg9, arg10, arg11, arg12, arg13, arg14);
}
/**
* Returns a new Arguments7 instance containing only the last 7 arguments.
* @return an Arguments7 instance with arguments from arg8 to arg14
* @since 0.16.0
*/
public Arguments7<A8, A9, A10, A11, A12, A13, A14> last7() {
return new Arguments7<>(arg8, arg9, arg10, arg11, arg12, arg13, arg14);
}
/**
* Returns a new Arguments8 instance containing only the last 8 arguments.
* @return an Arguments8 instance with arguments from arg7 to arg14
* @since 0.16.0
*/
public Arguments8<A7, A8, A9, A10, A11, A12, A13, A14> last8() {
return new Arguments8<>(arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14);
}
/**
* Returns a new Arguments9 instance containing only the last 9 arguments.
* @return an Arguments9 instance with arguments from arg6 to arg14
* @since 0.16.0
*/
public Arguments9<A6, A7, A8, A9, A10, A11, A12, A13, A14> last9() {
return new Arguments9<>(arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14);
}
/**
* Returns a new Arguments10 instance containing only the last 10 arguments.
* @return an Arguments10 instance with arguments from arg5 to arg14
* @since 0.16.0
*/
public Arguments10<A5, A6, A7, A8, A9, A10, A11, A12, A13, A14> last10() {
return new Arguments10<>(arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14);
}
/**
* Returns a new Arguments11 instance containing only the last 11 arguments.
* @return an Arguments11 instance with arguments from arg4 to arg14
* @since 0.16.0
*/
public Arguments11<A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14> last11() {
return new Arguments11<>(arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14);
}
/**
* Returns a new Arguments12 instance containing only the last 12 arguments.
* @return an Arguments12 instance with arguments from arg3 to arg14
* @since 0.16.0
*/
public Arguments12<A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14> last12() {
return new Arguments12<>(arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14);
}
/**
* Returns a new Arguments13 instance containing only the last 13 arguments.
* @return an Arguments13 instance with arguments from arg2 to arg14
* @since 0.16.0
*/
public Arguments13<A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14> last13() {
return new Arguments13<>(arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14);
}
/**
* Appends an additional argument to create a new, larger Arguments instance.
* @param <B> the type of the argument to append
* @param arg the argument to append
* @return a new Arguments15 instance with the additional argument
* @since 0.16.0
*/
public <B> Arguments15<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, B> append(@Nullable B arg) {
return new Arguments15<>(this.arg1, this.arg2, this.arg3, this.arg4, this.arg5, this.arg6, this.arg7, this.arg8,
this.arg9, this.arg10, this.arg11, this.arg12, this.arg13, this.arg14, arg);
}
/**
* Prepends an additional argument to create a new, larger Arguments instance.
* @param <B> the type of the argument to prepend
* @param arg the argument to prepend
* @return a new Arguments15 instance with the additional argument
* @since 0.16.0
*/
public <B> Arguments15<B, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14> prepend(@Nullable B arg) {
return new Arguments15<>(arg, this.arg1, this.arg2, this.arg3, this.arg4, this.arg5, this.arg6, this.arg7,
this.arg8, this.arg9, this.arg10, this.arg11, this.arg12, this.arg13, this.arg14);
}
/**
* Returns a new Arguments14 instance with the arguments in reverse order.
* @return an Arguments14 instance with arguments in reverse order
* @since 0.16.0
*/
public Arguments14<A14, A13, A12, A11, A10, A9, A8, A7, A6, A5, A4, A3, A2, A1> reverse() {
return new Arguments14<>(arg14, arg13, arg12, arg11, arg10, arg9, arg8, arg7, arg6, arg5, arg4, arg3, arg2,
arg1);
}
/**
* Indicates whether some other object is "equal to" this one.
* @param obj the reference object with which to compare
* @return true if this object is the same as the obj argument; false otherwise
*/
@Override
@SuppressWarnings("unchecked")
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
Arguments14<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14> that = (Arguments14<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14>) obj;
return Objects.equals(this.arg1, that.arg1) && Objects.equals(this.arg2, that.arg2)
&& Objects.equals(this.arg3, that.arg3) && Objects.equals(this.arg4, that.arg4)
&& Objects.equals(this.arg5, that.arg5) && Objects.equals(this.arg6, that.arg6)
&& Objects.equals(this.arg7, that.arg7) && Objects.equals(this.arg8, that.arg8)
&& Objects.equals(this.arg9, that.arg9) && Objects.equals(this.arg10, that.arg10)
&& Objects.equals(this.arg11, that.arg11) && Objects.equals(this.arg12, that.arg12)
&& Objects.equals(this.arg13, that.arg13) && Objects.equals(this.arg14, that.arg14);
}
/**
* Returns a hash code value for the object.
* @return a hash code value for this object
*/
@Override
public int hashCode() {
return Objects.hash(this.arg1, this.arg2, this.arg3, this.arg4, this.arg5, this.arg6, this.arg7, this.arg8,
this.arg9, this.arg10, this.arg11, this.arg12, this.arg13, this.arg14);
}
/**
* Returns a string representation of the object.
* @return a string representation of the object
*/
@Override
public String toString() {
return "Arguments14{" + "arg1=" + this.arg1 + ", " + "arg2=" + this.arg2 + ", " + "arg3=" + this.arg3 + ", "
+ "arg4=" + this.arg4 + ", " + "arg5=" + this.arg5 + ", " + "arg6=" + this.arg6 + ", " + "arg7="
+ this.arg7 + ", " + "arg8=" + this.arg8 + ", " + "arg9=" + this.arg9 + ", " + "arg10=" + this.arg10
+ ", " + "arg11=" + this.arg11 + ", " + "arg12=" + this.arg12 + ", " + "arg13=" + this.arg13 + ", "
+ "arg14=" + this.arg14 + "}";
}
}
|
0 | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi/arguments/Arguments14Combining.java | /*
* Copyright (C) 2018-2025 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.yavi.arguments;
import am.ik.yavi.core.ConstraintContext;
import am.ik.yavi.core.Validated;
import am.ik.yavi.core.ValueValidator;
import am.ik.yavi.fn.Function14;
import am.ik.yavi.fn.Validations;
import java.util.Locale;
import java.util.function.Supplier;
/**
* Generated by https://github.com/making/yavi/blob/develop/scripts/generate-args.sh
*
* @since 0.7.0
*/
public class Arguments14Combining<A, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14> {
protected final ValueValidator<? super A, ? extends R1> v1;
protected final ValueValidator<? super A, ? extends R2> v2;
protected final ValueValidator<? super A, ? extends R3> v3;
protected final ValueValidator<? super A, ? extends R4> v4;
protected final ValueValidator<? super A, ? extends R5> v5;
protected final ValueValidator<? super A, ? extends R6> v6;
protected final ValueValidator<? super A, ? extends R7> v7;
protected final ValueValidator<? super A, ? extends R8> v8;
protected final ValueValidator<? super A, ? extends R9> v9;
protected final ValueValidator<? super A, ? extends R10> v10;
protected final ValueValidator<? super A, ? extends R11> v11;
protected final ValueValidator<? super A, ? extends R12> v12;
protected final ValueValidator<? super A, ? extends R13> v13;
protected final ValueValidator<? super A, ? extends R14> v14;
public Arguments14Combining(ValueValidator<? super A, ? extends R1> v1, ValueValidator<? super A, ? extends R2> v2,
ValueValidator<? super A, ? extends R3> v3, ValueValidator<? super A, ? extends R4> v4,
ValueValidator<? super A, ? extends R5> v5, ValueValidator<? super A, ? extends R6> v6,
ValueValidator<? super A, ? extends R7> v7, ValueValidator<? super A, ? extends R8> v8,
ValueValidator<? super A, ? extends R9> v9, ValueValidator<? super A, ? extends R10> v10,
ValueValidator<? super A, ? extends R11> v11, ValueValidator<? super A, ? extends R12> v12,
ValueValidator<? super A, ? extends R13> v13, ValueValidator<? super A, ? extends R14> v14) {
this.v1 = v1;
this.v2 = v2;
this.v3 = v3;
this.v4 = v4;
this.v5 = v5;
this.v6 = v6;
this.v7 = v7;
this.v8 = v8;
this.v9 = v9;
this.v10 = v10;
this.v11 = v11;
this.v12 = v12;
this.v13 = v13;
this.v14 = v14;
}
public <X> Arguments1Validator<A, X> apply(
Function14<? super R1, ? super R2, ? super R3, ? super R4, ? super R5, ? super R6, ? super R7, ? super R8, ? super R9, ? super R10, ? super R11, ? super R12, ? super R13, ? super R14, ? extends X> f) {
return new Arguments1Validator<A, X>() {
@Override
public Validated<X> validate(A a, Locale locale, ConstraintContext constraintContext) {
return Validations.apply(f::apply, Arguments14Combining.this.v1.validate(a, locale, constraintContext),
Arguments14Combining.this.v2.validate(a, locale, constraintContext),
Arguments14Combining.this.v3.validate(a, locale, constraintContext),
Arguments14Combining.this.v4.validate(a, locale, constraintContext),
Arguments14Combining.this.v5.validate(a, locale, constraintContext),
Arguments14Combining.this.v6.validate(a, locale, constraintContext),
Arguments14Combining.this.v7.validate(a, locale, constraintContext),
Arguments14Combining.this.v8.validate(a, locale, constraintContext),
Arguments14Combining.this.v9.validate(a, locale, constraintContext),
Arguments14Combining.this.v10.validate(a, locale, constraintContext),
Arguments14Combining.this.v11.validate(a, locale, constraintContext),
Arguments14Combining.this.v12.validate(a, locale, constraintContext),
Arguments14Combining.this.v13.validate(a, locale, constraintContext),
Arguments14Combining.this.v14.validate(a, locale, constraintContext));
}
@Override
public Arguments1Validator<A, Supplier<X>> lazy() {
return (a, locale,
constraintContext) -> Validations.apply(
(r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13,
r14) -> () -> f.apply(r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13,
r14),
Arguments14Combining.this.v1.validate(a, locale, constraintContext),
Arguments14Combining.this.v2.validate(a, locale, constraintContext),
Arguments14Combining.this.v3.validate(a, locale, constraintContext),
Arguments14Combining.this.v4.validate(a, locale, constraintContext),
Arguments14Combining.this.v5.validate(a, locale, constraintContext),
Arguments14Combining.this.v6.validate(a, locale, constraintContext),
Arguments14Combining.this.v7.validate(a, locale, constraintContext),
Arguments14Combining.this.v8.validate(a, locale, constraintContext),
Arguments14Combining.this.v9.validate(a, locale, constraintContext),
Arguments14Combining.this.v10.validate(a, locale, constraintContext),
Arguments14Combining.this.v11.validate(a, locale, constraintContext),
Arguments14Combining.this.v12.validate(a, locale, constraintContext),
Arguments14Combining.this.v13.validate(a, locale, constraintContext),
Arguments14Combining.this.v14.validate(a, locale, constraintContext));
}
};
}
public <R15> Arguments15Combining<A, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15> combine(
ValueValidator<? super A, ? extends R15> v15) {
return new Arguments15Combining<>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15);
}
}
|
0 | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi/arguments/Arguments14Splitting.java | /*
* Copyright (C) 2018-2025 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.yavi.arguments;
import java.util.Locale;
import java.util.function.Supplier;
import am.ik.yavi.core.ConstraintContext;
import am.ik.yavi.core.Validated;
import am.ik.yavi.core.ValueValidator;
import am.ik.yavi.fn.Function14;
import am.ik.yavi.fn.Validations;
import am.ik.yavi.jsr305.Nullable;
/**
* Generated by https://github.com/making/yavi/blob/develop/scripts/generate-args.sh
*
* @since 0.7.0
*/
public class Arguments14Splitting<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14> {
protected final ValueValidator<? super A1, ? extends R1> v1;
protected final ValueValidator<? super A2, ? extends R2> v2;
protected final ValueValidator<? super A3, ? extends R3> v3;
protected final ValueValidator<? super A4, ? extends R4> v4;
protected final ValueValidator<? super A5, ? extends R5> v5;
protected final ValueValidator<? super A6, ? extends R6> v6;
protected final ValueValidator<? super A7, ? extends R7> v7;
protected final ValueValidator<? super A8, ? extends R8> v8;
protected final ValueValidator<? super A9, ? extends R9> v9;
protected final ValueValidator<? super A10, ? extends R10> v10;
protected final ValueValidator<? super A11, ? extends R11> v11;
protected final ValueValidator<? super A12, ? extends R12> v12;
protected final ValueValidator<? super A13, ? extends R13> v13;
protected final ValueValidator<? super A14, ? extends R14> v14;
public Arguments14Splitting(ValueValidator<? super A1, ? extends R1> v1,
ValueValidator<? super A2, ? extends R2> v2, ValueValidator<? super A3, ? extends R3> v3,
ValueValidator<? super A4, ? extends R4> v4, ValueValidator<? super A5, ? extends R5> v5,
ValueValidator<? super A6, ? extends R6> v6, ValueValidator<? super A7, ? extends R7> v7,
ValueValidator<? super A8, ? extends R8> v8, ValueValidator<? super A9, ? extends R9> v9,
ValueValidator<? super A10, ? extends R10> v10, ValueValidator<? super A11, ? extends R11> v11,
ValueValidator<? super A12, ? extends R12> v12, ValueValidator<? super A13, ? extends R13> v13,
ValueValidator<? super A14, ? extends R14> v14) {
this.v1 = v1;
this.v2 = v2;
this.v3 = v3;
this.v4 = v4;
this.v5 = v5;
this.v6 = v6;
this.v7 = v7;
this.v8 = v8;
this.v9 = v9;
this.v10 = v10;
this.v11 = v11;
this.v12 = v12;
this.v13 = v13;
this.v14 = v14;
}
public <X> Arguments14Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, X> apply(
Function14<? super R1, ? super R2, ? super R3, ? super R4, ? super R5, ? super R6, ? super R7, ? super R8, ? super R9, ? super R10, ? super R11, ? super R12, ? super R13, ? super R14, ? extends X> f) {
return new Arguments14Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, X>() {
@Override
public Arguments14Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, Supplier<X>> lazy() {
return ((a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, locale,
constraintContext) -> Validations.apply(
(r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13,
r14) -> () -> f.apply(r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13,
r14),
v1.validate(a1, locale, constraintContext), v2.validate(a2, locale, constraintContext),
v3.validate(a3, locale, constraintContext), v4.validate(a4, locale, constraintContext),
v5.validate(a5, locale, constraintContext), v6.validate(a6, locale, constraintContext),
v7.validate(a7, locale, constraintContext), v8.validate(a8, locale, constraintContext),
v9.validate(a9, locale, constraintContext),
v10.validate(a10, locale, constraintContext),
v11.validate(a11, locale, constraintContext),
v12.validate(a12, locale, constraintContext),
v13.validate(a13, locale, constraintContext),
v14.validate(a14, locale, constraintContext)));
}
@Override
public Validated<X> validate(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4,
@Nullable A5 a5, @Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9,
@Nullable A10 a10, @Nullable A11 a11, @Nullable A12 a12, @Nullable A13 a13, @Nullable A14 a14,
Locale locale, ConstraintContext constraintContext) {
return Validations.apply(f::apply, v1.validate(a1, locale, constraintContext),
v2.validate(a2, locale, constraintContext), v3.validate(a3, locale, constraintContext),
v4.validate(a4, locale, constraintContext), v5.validate(a5, locale, constraintContext),
v6.validate(a6, locale, constraintContext), v7.validate(a7, locale, constraintContext),
v8.validate(a8, locale, constraintContext), v9.validate(a9, locale, constraintContext),
v10.validate(a10, locale, constraintContext), v11.validate(a11, locale, constraintContext),
v12.validate(a12, locale, constraintContext), v13.validate(a13, locale, constraintContext),
v14.validate(a14, locale, constraintContext));
}
};
}
public <A15, R15> Arguments15Splitting<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15> split(
ValueValidator<? super A15, ? extends R15> v15) {
return new Arguments15Splitting<>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15);
}
}
|
0 | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi/arguments/Arguments14Validator.java | /*
* Copyright (C) 2018-2025 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.yavi.arguments;
import java.util.Locale;
import java.util.Objects;
import java.util.function.Function;
import java.util.function.Supplier;
import am.ik.yavi.core.ConstraintContext;
import am.ik.yavi.core.ConstraintGroup;
import am.ik.yavi.core.ConstraintViolationsException;
import am.ik.yavi.core.Validated;
import am.ik.yavi.core.ValueValidator;
import am.ik.yavi.jsr305.Nullable;
/**
* Generated by https://github.com/making/yavi/blob/develop/scripts/generate-args.sh
*
* @since 0.3.0
*/
@FunctionalInterface
public interface Arguments14Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, X> {
/**
* Convert an Arguments1Validator that validates Arguments14 to an
* Arguments14Validator
* @param validator validator for Arguments14
* @param <A1> type of first argument
* @param <A2> type of argument at position 2
* @param <A3> type of argument at position 3
* @param <A4> type of argument at position 4
* @param <A5> type of argument at position 5
* @param <A6> type of argument at position 6
* @param <A7> type of argument at position 7
* @param <A8> type of argument at position 8
* @param <A9> type of argument at position 9
* @param <A10> type of argument at position 10
* @param <A11> type of argument at position 11
* @param <A12> type of argument at position 12
* @param <A13> type of argument at position 13
* @param <A14> type of argument at position 14
* @param <X> target result type
* @return arguments14 validator that takes arguments directly
* @since 0.16.0
*/
static <A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, X> Arguments14Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, X> unwrap(
Arguments1Validator<Arguments14<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14>, X> validator) {
return new Arguments14Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, X>() {
@Override
public Validated<X> validate(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4,
@Nullable A5 a5, @Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9,
@Nullable A10 a10, @Nullable A11 a11, @Nullable A12 a12, @Nullable A13 a13, @Nullable A14 a14,
Locale locale, ConstraintContext constraintContext) {
return validator.validate(Arguments.of(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14),
locale, constraintContext);
}
@Override
public Arguments14Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, Supplier<X>> lazy() {
return Arguments14Validator.unwrap(validator.lazy());
}
};
}
Validated<X> validate(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4, @Nullable A5 a5,
@Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9, @Nullable A10 a10, @Nullable A11 a11,
@Nullable A12 a12, @Nullable A13 a13, @Nullable A14 a14, Locale locale,
ConstraintContext constraintContext);
/**
* Convert this validator to one that validates Arguments14 as a single object.
* @return a validator that takes an Arguments14
* @since 0.16.0
*/
default Arguments1Validator<Arguments14<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14>, X> wrap() {
return new Arguments1Validator<Arguments14<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14>, X>() {
@Override
public Validated<X> validate(Arguments14<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14> args,
Locale locale, ConstraintContext constraintContext) {
final Arguments14<? extends A1, ? extends A2, ? extends A3, ? extends A4, ? extends A5, ? extends A6, ? extends A7, ? extends A8, ? extends A9, ? extends A10, ? extends A11, ? extends A12, ? extends A13, ? extends A14> nonNullArgs = Objects
.requireNonNull(args);
return Arguments14Validator.this.validate(nonNullArgs.arg1(), nonNullArgs.arg2(), nonNullArgs.arg3(),
nonNullArgs.arg4(), nonNullArgs.arg5(), nonNullArgs.arg6(), nonNullArgs.arg7(),
nonNullArgs.arg8(), nonNullArgs.arg9(), nonNullArgs.arg10(), nonNullArgs.arg11(),
nonNullArgs.arg12(), nonNullArgs.arg13(), nonNullArgs.arg14(), locale, constraintContext);
}
@Override
public Arguments1Validator<Arguments14<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14>, Supplier<X>> lazy() {
return Arguments14Validator.this.lazy().wrap();
}
};
}
/**
* @since 0.7.0
*/
default <X2> Arguments14Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, X2> andThen(
Function<? super X, ? extends X2> mapper) {
return new Arguments14Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, X2>() {
@Override
public Validated<X2> validate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10,
A11 a11, A12 a12, A13 a13, A14 a14, Locale locale, ConstraintContext constraintContext) {
return Arguments14Validator.this
.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, locale, constraintContext)
.map(mapper);
}
@Override
public Arguments14Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, Supplier<X2>> lazy() {
return Arguments14Validator.this.lazy()
.andThen((Function<Supplier<X>, Supplier<X2>>) xSupplier -> () -> mapper.apply(xSupplier.get()));
}
};
}
/**
* @since 0.11.0
*/
default <X2> Arguments14Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, X2> andThen(
ValueValidator<? super X, X2> validator) {
return new Arguments14Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, X2>() {
@Override
public Validated<X2> validate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10,
A11 a11, A12 a12, A13 a13, A14 a14, Locale locale, ConstraintContext constraintContext) {
return Arguments14Validator.this
.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, locale, constraintContext)
.flatMap(v -> validator.validate(v, locale, constraintContext));
}
@Override
public Arguments14Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, Supplier<X2>> lazy() {
return Arguments14Validator.this.lazy()
.andThen((xSupplier, locale, constraintContext) -> validator
.validate(Objects.requireNonNull(xSupplier).get(), locale, constraintContext)
.map(x2 -> () -> x2));
}
};
}
/**
* @since 0.7.0
*/
default <A> Arguments1Validator<A, X> compose(
Function<? super A, ? extends Arguments14<? extends A1, ? extends A2, ? extends A3, ? extends A4, ? extends A5, ? extends A6, ? extends A7, ? extends A8, ? extends A9, ? extends A10, ? extends A11, ? extends A12, ? extends A13, ? extends A14>> mapper) {
return new Arguments1Validator<A, X>() {
@Override
public Validated<X> validate(A a, Locale locale, ConstraintContext constraintContext) {
final Arguments14<? extends A1, ? extends A2, ? extends A3, ? extends A4, ? extends A5, ? extends A6, ? extends A7, ? extends A8, ? extends A9, ? extends A10, ? extends A11, ? extends A12, ? extends A13, ? extends A14> args = mapper
.apply(a);
return Arguments14Validator.this.validate(args.arg1(), args.arg2(), args.arg3(), args.arg4(),
args.arg5(), args.arg6(), args.arg7(), args.arg8(), args.arg9(), args.arg10(), args.arg11(),
args.arg12(), args.arg13(), args.arg14(), locale, constraintContext);
}
@Override
public Arguments1Validator<A, Supplier<X>> lazy() {
return Arguments14Validator.this.lazy().compose(mapper);
}
};
}
/**
* @since 0.10.0
*/
default Arguments14Validator<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, Supplier<X>> lazy() {
throw new UnsupportedOperationException("lazy is not implemented!");
}
default Validated<X> validate(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4, @Nullable A5 a5,
@Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9, @Nullable A10 a10, @Nullable A11 a11,
@Nullable A12 a12, @Nullable A13 a13, @Nullable A14 a14) {
return this.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, Locale.getDefault(),
ConstraintGroup.DEFAULT);
}
default Validated<X> validate(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4, @Nullable A5 a5,
@Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9, @Nullable A10 a10, @Nullable A11 a11,
@Nullable A12 a12, @Nullable A13 a13, @Nullable A14 a14, ConstraintContext constraintContext) {
return this.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, Locale.getDefault(),
constraintContext);
}
default Validated<X> validate(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4, @Nullable A5 a5,
@Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9, @Nullable A10 a10, @Nullable A11 a11,
@Nullable A12 a12, @Nullable A13 a13, @Nullable A14 a14, Locale locale) {
return this.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, locale,
ConstraintGroup.DEFAULT);
}
default X validated(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4, @Nullable A5 a5,
@Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9, @Nullable A10 a10, @Nullable A11 a11,
@Nullable A12 a12, @Nullable A13 a13, @Nullable A14 a14) throws ConstraintViolationsException {
return this.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14)
.orElseThrow(ConstraintViolationsException::new);
}
default X validated(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4, @Nullable A5 a5,
@Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9, @Nullable A10 a10, @Nullable A11 a11,
@Nullable A12 a12, @Nullable A13 a13, @Nullable A14 a14, ConstraintContext constraintContext)
throws ConstraintViolationsException {
return this.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, constraintContext)
.orElseThrow(ConstraintViolationsException::new);
}
default X validated(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4, @Nullable A5 a5,
@Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9, @Nullable A10 a10, @Nullable A11 a11,
@Nullable A12 a12, @Nullable A13 a13, @Nullable A14 a14, Locale locale)
throws ConstraintViolationsException {
return this.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, locale)
.orElseThrow(ConstraintViolationsException::new);
}
default X validated(@Nullable A1 a1, @Nullable A2 a2, @Nullable A3 a3, @Nullable A4 a4, @Nullable A5 a5,
@Nullable A6 a6, @Nullable A7 a7, @Nullable A8 a8, @Nullable A9 a9, @Nullable A10 a10, @Nullable A11 a11,
@Nullable A12 a12, @Nullable A13 a13, @Nullable A14 a14, Locale locale, ConstraintContext constraintContext)
throws ConstraintViolationsException {
return this.validate(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, locale, constraintContext)
.orElseThrow(ConstraintViolationsException::new);
}
}
|
0 | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi | java-sources/am/ik/yavi/yavi/0.16.0/am/ik/yavi/arguments/Arguments15.java | /*
* Copyright (C) 2018-2025 Toshiaki Maki <makingx@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package am.ik.yavi.arguments;
import java.util.Objects;
import am.ik.yavi.fn.Function15;
import am.ik.yavi.jsr305.Nullable;
/**
* A container class that holds 15 arguments, providing type-safe access to each argument
* and mapping functionality to transform these arguments.
*
* Generated by https://github.com/making/yavi/blob/develop/scripts/generate-args.sh
*
* @param <A1> the type of argument at position 1
* @param <A2> the type of argument at position 2
* @param <A3> the type of argument at position 3
* @param <A4> the type of argument at position 4
* @param <A5> the type of argument at position 5
* @param <A6> the type of argument at position 6
* @param <A7> the type of argument at position 7
* @param <A8> the type of argument at position 8
* @param <A9> the type of argument at position 9
* @param <A10> the type of argument at position 10
* @param <A11> the type of argument at position 11
* @param <A12> the type of argument at position 12
* @param <A13> the type of argument at position 13
* @param <A14> the type of argument at position 14
* @param <A15> the type of argument at position 15
* @since 0.3.0
*/
public final class Arguments15<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15> {
private final A1 arg1;
private final A2 arg2;
private final A3 arg3;
private final A4 arg4;
private final A5 arg5;
private final A6 arg6;
private final A7 arg7;
private final A8 arg8;
private final A9 arg9;
private final A10 arg10;
private final A11 arg11;
private final A12 arg12;
private final A13 arg13;
private final A14 arg14;
private final A15 arg15;
/**
* Creates a new Arguments15 instance with the provided arguments.
* @param arg1 the argument at position 1, arg2 the argument at position 2, arg3 the
* argument at position 3, arg4 the argument at position 4, arg5 the argument at
* position 5, arg6 the argument at position 6, arg7 the argument at position 7, arg8
* the argument at position 8, arg9 the argument at position 9, arg10 the argument at
* position 10, arg11 the argument at position 11, arg12 the argument at position 12,
* arg13 the argument at position 13, arg14 the argument at position 14, arg15 the
* argument at position 15
*/
Arguments15(@Nullable A1 arg1, @Nullable A2 arg2, @Nullable A3 arg3, @Nullable A4 arg4, @Nullable A5 arg5,
@Nullable A6 arg6, @Nullable A7 arg7, @Nullable A8 arg8, @Nullable A9 arg9, @Nullable A10 arg10,
@Nullable A11 arg11, @Nullable A12 arg12, @Nullable A13 arg13, @Nullable A14 arg14, @Nullable A15 arg15) {
this.arg1 = arg1;
this.arg2 = arg2;
this.arg3 = arg3;
this.arg4 = arg4;
this.arg5 = arg5;
this.arg6 = arg6;
this.arg7 = arg7;
this.arg8 = arg8;
this.arg9 = arg9;
this.arg10 = arg10;
this.arg11 = arg11;
this.arg12 = arg12;
this.arg13 = arg13;
this.arg14 = arg14;
this.arg15 = arg15;
}
/**
* Returns the argument at position 1.
* @return the argument at position 1
*/
@Nullable
public A1 arg1() {
return this.arg1;
}
/**
* Returns the argument at position 2.
* @return the argument at position 2
*/
@Nullable
public A2 arg2() {
return this.arg2;
}
/**
* Returns the argument at position 3.
* @return the argument at position 3
*/
@Nullable
public A3 arg3() {
return this.arg3;
}
/**
* Returns the argument at position 4.
* @return the argument at position 4
*/
@Nullable
public A4 arg4() {
return this.arg4;
}
/**
* Returns the argument at position 5.
* @return the argument at position 5
*/
@Nullable
public A5 arg5() {
return this.arg5;
}
/**
* Returns the argument at position 6.
* @return the argument at position 6
*/
@Nullable
public A6 arg6() {
return this.arg6;
}
/**
* Returns the argument at position 7.
* @return the argument at position 7
*/
@Nullable
public A7 arg7() {
return this.arg7;
}
/**
* Returns the argument at position 8.
* @return the argument at position 8
*/
@Nullable
public A8 arg8() {
return this.arg8;
}
/**
* Returns the argument at position 9.
* @return the argument at position 9
*/
@Nullable
public A9 arg9() {
return this.arg9;
}
/**
* Returns the argument at position 10.
* @return the argument at position 10
*/
@Nullable
public A10 arg10() {
return this.arg10;
}
/**
* Returns the argument at position 11.
* @return the argument at position 11
*/
@Nullable
public A11 arg11() {
return this.arg11;
}
/**
* Returns the argument at position 12.
* @return the argument at position 12
*/
@Nullable
public A12 arg12() {
return this.arg12;
}
/**
* Returns the argument at position 13.
* @return the argument at position 13
*/
@Nullable
public A13 arg13() {
return this.arg13;
}
/**
* Returns the argument at position 14.
* @return the argument at position 14
*/
@Nullable
public A14 arg14() {
return this.arg14;
}
/**
* Returns the argument at position 15.
* @return the argument at position 15
*/
@Nullable
public A15 arg15() {
return this.arg15;
}
/**
* Applies the provided mapping function to all arguments contained in this instance.
* @param <X> the type of the result
* @param mapper the function to apply to the arguments
* @return the result of applying the mapper function to the arguments
*/
public <X> X map(
Function15<? super A1, ? super A2, ? super A3, ? super A4, ? super A5, ? super A6, ? super A7, ? super A8, ? super A9, ? super A10, ? super A11, ? super A12, ? super A13, ? super A14, ? super A15, ? extends X> mapper) {
return mapper.apply(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
arg15);
}
/**
* Returns a new Arguments1 instance containing only the first 1 arguments.
* @return an Arguments1 instance with arguments from arg1 to arg1
* @since 0.16.0
*/
public Arguments1<A1> first1() {
return new Arguments1<>(arg1);
}
/**
* Returns a new Arguments2 instance containing only the first 2 arguments.
* @return an Arguments2 instance with arguments from arg1 to arg2
* @since 0.16.0
*/
public Arguments2<A1, A2> first2() {
return new Arguments2<>(arg1, arg2);
}
/**
* Returns a new Arguments3 instance containing only the first 3 arguments.
* @return an Arguments3 instance with arguments from arg1 to arg3
* @since 0.16.0
*/
public Arguments3<A1, A2, A3> first3() {
return new Arguments3<>(arg1, arg2, arg3);
}
/**
* Returns a new Arguments4 instance containing only the first 4 arguments.
* @return an Arguments4 instance with arguments from arg1 to arg4
* @since 0.16.0
*/
public Arguments4<A1, A2, A3, A4> first4() {
return new Arguments4<>(arg1, arg2, arg3, arg4);
}
/**
* Returns a new Arguments5 instance containing only the first 5 arguments.
* @return an Arguments5 instance with arguments from arg1 to arg5
* @since 0.16.0
*/
public Arguments5<A1, A2, A3, A4, A5> first5() {
return new Arguments5<>(arg1, arg2, arg3, arg4, arg5);
}
/**
* Returns a new Arguments6 instance containing only the first 6 arguments.
* @return an Arguments6 instance with arguments from arg1 to arg6
* @since 0.16.0
*/
public Arguments6<A1, A2, A3, A4, A5, A6> first6() {
return new Arguments6<>(arg1, arg2, arg3, arg4, arg5, arg6);
}
/**
* Returns a new Arguments7 instance containing only the first 7 arguments.
* @return an Arguments7 instance with arguments from arg1 to arg7
* @since 0.16.0
*/
public Arguments7<A1, A2, A3, A4, A5, A6, A7> first7() {
return new Arguments7<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7);
}
/**
* Returns a new Arguments8 instance containing only the first 8 arguments.
* @return an Arguments8 instance with arguments from arg1 to arg8
* @since 0.16.0
*/
public Arguments8<A1, A2, A3, A4, A5, A6, A7, A8> first8() {
return new Arguments8<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
}
/**
* Returns a new Arguments9 instance containing only the first 9 arguments.
* @return an Arguments9 instance with arguments from arg1 to arg9
* @since 0.16.0
*/
public Arguments9<A1, A2, A3, A4, A5, A6, A7, A8, A9> first9() {
return new Arguments9<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
}
/**
* Returns a new Arguments10 instance containing only the first 10 arguments.
* @return an Arguments10 instance with arguments from arg1 to arg10
* @since 0.16.0
*/
public Arguments10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10> first10() {
return new Arguments10<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
}
/**
* Returns a new Arguments11 instance containing only the first 11 arguments.
* @return an Arguments11 instance with arguments from arg1 to arg11
* @since 0.16.0
*/
public Arguments11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11> first11() {
return new Arguments11<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11);
}
/**
* Returns a new Arguments12 instance containing only the first 12 arguments.
* @return an Arguments12 instance with arguments from arg1 to arg12
* @since 0.16.0
*/
public Arguments12<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12> first12() {
return new Arguments12<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12);
}
/**
* Returns a new Arguments13 instance containing only the first 13 arguments.
* @return an Arguments13 instance with arguments from arg1 to arg13
* @since 0.16.0
*/
public Arguments13<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13> first13() {
return new Arguments13<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13);
}
/**
* Returns a new Arguments14 instance containing only the first 14 arguments.
* @return an Arguments14 instance with arguments from arg1 to arg14
* @since 0.16.0
*/
public Arguments14<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14> first14() {
return new Arguments14<>(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13,
arg14);
}
/**
* Returns a new Arguments1 instance containing only the last 1 arguments.
* @return an Arguments1 instance with arguments from arg15 to arg15
* @since 0.16.0
*/
public Arguments1<A15> last1() {
return new Arguments1<>(arg15);
}
/**
* Returns a new Arguments2 instance containing only the last 2 arguments.
* @return an Arguments2 instance with arguments from arg14 to arg15
* @since 0.16.0
*/
public Arguments2<A14, A15> last2() {
return new Arguments2<>(arg14, arg15);
}
/**
* Returns a new Arguments3 instance containing only the last 3 arguments.
* @return an Arguments3 instance with arguments from arg13 to arg15
* @since 0.16.0
*/
public Arguments3<A13, A14, A15> last3() {
return new Arguments3<>(arg13, arg14, arg15);
}
/**
* Returns a new Arguments4 instance containing only the last 4 arguments.
* @return an Arguments4 instance with arguments from arg12 to arg15
* @since 0.16.0
*/
public Arguments4<A12, A13, A14, A15> last4() {
return new Arguments4<>(arg12, arg13, arg14, arg15);
}
/**
* Returns a new Arguments5 instance containing only the last 5 arguments.
* @return an Arguments5 instance with arguments from arg11 to arg15
* @since 0.16.0
*/
public Arguments5<A11, A12, A13, A14, A15> last5() {
return new Arguments5<>(arg11, arg12, arg13, arg14, arg15);
}
/**
* Returns a new Arguments6 instance containing only the last 6 arguments.
* @return an Arguments6 instance with arguments from arg10 to arg15
* @since 0.16.0
*/
public Arguments6<A10, A11, A12, A13, A14, A15> last6() {
return new Arguments6<>(arg10, arg11, arg12, arg13, arg14, arg15);
}
/**
* Returns a new Arguments7 instance containing only the last 7 arguments.
* @return an Arguments7 instance with arguments from arg9 to arg15
* @since 0.16.0
*/
public Arguments7<A9, A10, A11, A12, A13, A14, A15> last7() {
return new Arguments7<>(arg9, arg10, arg11, arg12, arg13, arg14, arg15);
}
/**
* Returns a new Arguments8 instance containing only the last 8 arguments.
* @return an Arguments8 instance with arguments from arg8 to arg15
* @since 0.16.0
*/
public Arguments8<A8, A9, A10, A11, A12, A13, A14, A15> last8() {
return new Arguments8<>(arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15);
}
/**
* Returns a new Arguments9 instance containing only the last 9 arguments.
* @return an Arguments9 instance with arguments from arg7 to arg15
* @since 0.16.0
*/
public Arguments9<A7, A8, A9, A10, A11, A12, A13, A14, A15> last9() {
return new Arguments9<>(arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15);
}
/**
* Returns a new Arguments10 instance containing only the last 10 arguments.
* @return an Arguments10 instance with arguments from arg6 to arg15
* @since 0.16.0
*/
public Arguments10<A6, A7, A8, A9, A10, A11, A12, A13, A14, A15> last10() {
return new Arguments10<>(arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15);
}
/**
* Returns a new Arguments11 instance containing only the last 11 arguments.
* @return an Arguments11 instance with arguments from arg5 to arg15
* @since 0.16.0
*/
public Arguments11<A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15> last11() {
return new Arguments11<>(arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15);
}
/**
* Returns a new Arguments12 instance containing only the last 12 arguments.
* @return an Arguments12 instance with arguments from arg4 to arg15
* @since 0.16.0
*/
public Arguments12<A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15> last12() {
return new Arguments12<>(arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15);
}
/**
* Returns a new Arguments13 instance containing only the last 13 arguments.
* @return an Arguments13 instance with arguments from arg3 to arg15
* @since 0.16.0
*/
public Arguments13<A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15> last13() {
return new Arguments13<>(arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15);
}
/**
* Returns a new Arguments14 instance containing only the last 14 arguments.
* @return an Arguments14 instance with arguments from arg2 to arg15
* @since 0.16.0
*/
public Arguments14<A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15> last14() {
return new Arguments14<>(arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
arg15);
}
/**
* Appends an additional argument to create a new, larger Arguments instance.
* @param <B> the type of the argument to append
* @param arg the argument to append
* @return a new Arguments16 instance with the additional argument
* @since 0.16.0
*/
public <B> Arguments16<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, B> append(
@Nullable B arg) {
return new Arguments16<>(this.arg1, this.arg2, this.arg3, this.arg4, this.arg5, this.arg6, this.arg7, this.arg8,
this.arg9, this.arg10, this.arg11, this.arg12, this.arg13, this.arg14, this.arg15, arg);
}
/**
* Prepends an additional argument to create a new, larger Arguments instance.
* @param <B> the type of the argument to prepend
* @param arg the argument to prepend
* @return a new Arguments16 instance with the additional argument
* @since 0.16.0
*/
public <B> Arguments16<B, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15> prepend(
@Nullable B arg) {
return new Arguments16<>(arg, this.arg1, this.arg2, this.arg3, this.arg4, this.arg5, this.arg6, this.arg7,
this.arg8, this.arg9, this.arg10, this.arg11, this.arg12, this.arg13, this.arg14, this.arg15);
}
/**
* Returns a new Arguments15 instance with the arguments in reverse order.
* @return an Arguments15 instance with arguments in reverse order
* @since 0.16.0
*/
public Arguments15<A15, A14, A13, A12, A11, A10, A9, A8, A7, A6, A5, A4, A3, A2, A1> reverse() {
return new Arguments15<>(arg15, arg14, arg13, arg12, arg11, arg10, arg9, arg8, arg7, arg6, arg5, arg4, arg3,
arg2, arg1);
}
/**
* Indicates whether some other object is "equal to" this one.
* @param obj the reference object with which to compare
* @return true if this object is the same as the obj argument; false otherwise
*/
@Override
@SuppressWarnings("unchecked")
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
Arguments15<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15> that = (Arguments15<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15>) obj;
return Objects.equals(this.arg1, that.arg1) && Objects.equals(this.arg2, that.arg2)
&& Objects.equals(this.arg3, that.arg3) && Objects.equals(this.arg4, that.arg4)
&& Objects.equals(this.arg5, that.arg5) && Objects.equals(this.arg6, that.arg6)
&& Objects.equals(this.arg7, that.arg7) && Objects.equals(this.arg8, that.arg8)
&& Objects.equals(this.arg9, that.arg9) && Objects.equals(this.arg10, that.arg10)
&& Objects.equals(this.arg11, that.arg11) && Objects.equals(this.arg12, that.arg12)
&& Objects.equals(this.arg13, that.arg13) && Objects.equals(this.arg14, that.arg14)
&& Objects.equals(this.arg15, that.arg15);
}
/**
* Returns a hash code value for the object.
* @return a hash code value for this object
*/
@Override
public int hashCode() {
return Objects.hash(this.arg1, this.arg2, this.arg3, this.arg4, this.arg5, this.arg6, this.arg7, this.arg8,
this.arg9, this.arg10, this.arg11, this.arg12, this.arg13, this.arg14, this.arg15);
}
/**
* Returns a string representation of the object.
* @return a string representation of the object
*/
@Override
public String toString() {
return "Arguments15{" + "arg1=" + this.arg1 + ", " + "arg2=" + this.arg2 + ", " + "arg3=" + this.arg3 + ", "
+ "arg4=" + this.arg4 + ", " + "arg5=" + this.arg5 + ", " + "arg6=" + this.arg6 + ", " + "arg7="
+ this.arg7 + ", " + "arg8=" + this.arg8 + ", " + "arg9=" + this.arg9 + ", " + "arg10=" + this.arg10
+ ", " + "arg11=" + this.arg11 + ", " + "arg12=" + this.arg12 + ", " + "arg13=" + this.arg13 + ", "
+ "arg14=" + this.arg14 + ", " + "arg15=" + this.arg15 + "}";
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.