Java Code Examples for io.vertx.core.impl.Arguments#require()
The following examples show how to use
io.vertx.core.impl.Arguments#require() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractAsyncVertxDAO.java From vertx-jooq with MIT License | 6 votes |
@SuppressWarnings("unchecked") protected AbstractAsyncVertxDAO(Table<R> table, Class<P> type, QueryExecutor<R, T, FIND_MANY, FIND_ONE, EXECUTE, INSERT_RETURNING> queryExecutor) { super(table, type, queryExecutor); Arguments.require(isMysql(queryExecutor.configuration()) || isPostgres(queryExecutor.configuration()),"Only Postgres and MySQL supported"); if(isMysql(queryExecutor.configuration())){ keyConverter = keyConverter(); }else{ keyConverter = o -> { JsonArray j = (JsonArray) o; int pkLength = getTable().getPrimaryKey().getFieldsArray().length; if(pkLength == 1){ return (T)j.getValue(0); } Object[] values = new Object[j.size()]; for(int i=0;i<j.size();i++){ values[i] = j.getValue(i); } return compositeKeyRecord(values); }; } }
Example 2
Source File: PolicyConfigLoader.java From apiman with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private <T, K> List<T> requireJsonArray(String keyName, JsonObject json, Class<K> klazz) { // Contains key. Arguments.require(json.containsKey(keyName), String.format("Must provide array of %s objects for key '%s'", StringUtils.capitalize(keyName), keyName)); // Is of type array. Arguments.require(json.getValue(keyName) instanceof JsonArray, String.format("'%s' must be a Json array", keyName)); // Transform into List<T>. return Json.decodeValue(json.getJsonArray(keyName).encode(), List.class, klazz); }
Example 3
Source File: URILoadingRegistry.java From apiman with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private <T, K> List<T> requireJsonArray(String keyName, JsonObject json, Class<K> klazz) { // Contains key. Arguments.require(json.containsKey(keyName), String.format("Must provide array of %s objects for key '%s'", StringUtils.capitalize(keyName), keyName)); // Is of type array. Arguments.require(json.getValue(keyName) instanceof JsonArray, String.format("'%s' must be a Json array", keyName)); // Transform into List<T>. return Json.decodeValue(json.getJsonArray(keyName).encode(), List.class, klazz); }
Example 4
Source File: URILoadingRegistry.java From apiman with Apache License 2.0 | 5 votes |
public URILoadingRegistry(Vertx vertx, IEngineConfig vxConfig, Map<String, String> options) { super(); this.vertx = vertx; this.options = options; Arguments.require(options.containsKey("configUri"), "configUri is required in configuration"); uri = URI.create(options.get("configUri")); }
Example 5
Source File: MqttServerOptions.java From vertx-mqtt with Apache License 2.0 | 5 votes |
/** * Create an options from JSON * * @param json the JSON */ public MqttServerOptions(JsonObject json) { super(json); // override the default port this.setPort(json.getInteger("port", DEFAULT_PORT)); this.maxMessageSize = json.getInteger("maxMessageSize", DEFAULT_MAX_MESSAGE_SIZE); this.isAutoClientId = json.getBoolean("isAutoClientId", true); this.timeoutOnConnect = json.getInteger("timeoutOnConnect", DEFAULT_TIMEOUT_ON_CONNECT); if ((this.maxMessageSize > 0) && (this.getReceiveBufferSize() > 0)) { Arguments.require(this.getReceiveBufferSize() >= this.maxMessageSize, "Receiver buffer size can't be lower than max message size"); } }
Example 6
Source File: MqttServerOptions.java From vertx-mqtt with Apache License 2.0 | 5 votes |
@Override public MqttServerOptions setReceiveBufferSize(int receiveBufferSize) { if ((this.maxMessageSize > 0) && (receiveBufferSize > 0)) { Arguments.require(receiveBufferSize >= this.maxMessageSize, "Receiver buffer size can't be lower than max message size"); } super.setReceiveBufferSize(receiveBufferSize); return this; }
Example 7
Source File: MqttServerOptions.java From vertx-mqtt with Apache License 2.0 | 5 votes |
/** * Set max MQTT message size * * @param maxMessageSize max MQTT message size (variable header + payload) * @return MQTT server options instance */ public MqttServerOptions setMaxMessageSize(int maxMessageSize) { Arguments.require(maxMessageSize > 0 || maxMessageSize == DEFAULT_MAX_MESSAGE_SIZE, "maxMessageSize must be > 0"); if ((maxMessageSize > 0) && (this.getReceiveBufferSize() > 0)) { Arguments.require(this.getReceiveBufferSize() >= maxMessageSize, "Receiver buffer size can't be lower than max message size"); } this.maxMessageSize = maxMessageSize; return this; }
Example 8
Source File: MqttClientOptions.java From vertx-mqtt with Apache License 2.0 | 5 votes |
@Override public MqttClientOptions setReceiveBufferSize(int receiveBufferSize) { if ((this.maxMessageSize > 0) && (receiveBufferSize > 0)) { Arguments.require(receiveBufferSize >= this.maxMessageSize, "Receiver buffer size can't be lower than max message size"); } super.setReceiveBufferSize(receiveBufferSize); return this; }
Example 9
Source File: MqttClientOptions.java From vertx-mqtt with Apache License 2.0 | 5 votes |
/** * Set max MQTT message size * * @param maxMessageSize max MQTT message size * @return MQTT client options instance */ public MqttClientOptions setMaxMessageSize(int maxMessageSize) { Arguments.require(maxMessageSize > 0 || maxMessageSize == DEFAULT_MAX_MESSAGE_SIZE, "maxMessageSize must be > 0"); if ((maxMessageSize > 0) && (this.getReceiveBufferSize() > 0)) { Arguments.require(this.getReceiveBufferSize() >= maxMessageSize, "Receiver buffer size can't be lower than max message size"); } this.maxMessageSize = maxMessageSize; return this; }
Example 10
Source File: HttpResourceFetcher.java From apiman with Apache License 2.0 | 5 votes |
public HttpResourceFetcher(Vertx vertx, URI uri, Map<String, String> config, boolean isHttps) { this.vertx = vertx; this.uri = uri; this.isHttps = isHttps; this.config = config; String authString = config.getOrDefault("auth", "NONE").toUpperCase(); Arguments.require(EnumUtils.isValidEnum(AuthType.class, authString), "auth must be one of: " + AuthType.all()); authenticator = AuthType.valueOf(authString).getAuthenticator(); authenticator.validateConfig(config); }
Example 11
Source File: AbstractVertxDAO.java From vertx-jooq with MIT License | 5 votes |
@Override public EXECUTE insert(Collection<P> pojos, boolean onDuplicateKeyIgnore) { Arguments.require(!pojos.isEmpty(), "No elements"); return queryExecutor().execute(dslContext -> { InsertSetStep<R> insertSetStep = dslContext.insertInto(getTable()); InsertValuesStepN<R> insertValuesStepN = null; for (P pojo : pojos) { insertValuesStepN = insertSetStep.values(newRecord(dslContext, pojo).intoArray()); } return onDuplicateKeyIgnore?insertValuesStepN.onDuplicateKeyIgnore():insertValuesStepN; }); }
Example 12
Source File: LocalData.java From vxms with Apache License 2.0 | 5 votes |
/** * Get a local lock with the specified name with specifying a timeout. The lock will be passed to * the handler when it is available. If the lock is not obtained within the timeout a failure * will be sent to the handler * * @param name the name of the lock * @param timeout the timeout in ms * @param resultHandler the handler */ public void getLockWithTimeout(String name, long timeout, Handler<AsyncResult<Lock>> resultHandler) { Objects.requireNonNull(name, "name"); Objects.requireNonNull(resultHandler, "resultHandler"); Arguments.require(timeout >= 0L, "timeout must be >= 0"); LocalAsyncLocks lock = this.localLocks .computeIfAbsent(name, (n) -> new LocalAsyncLocks()); lock.acquire(this.vertx.getOrCreateContext(),name,timeout, resultHandler); }
Example 13
Source File: VertxGenerator.java From vertx-jooq with MIT License | 4 votes |
@Override public void setStrategy(GeneratorStrategy strategy) { Arguments.require(strategy instanceof VertxGeneratorStrategy, "Requires instance of VertxGeneratorStrategy"); super.setStrategy(strategy); this.vertxGeneratorStrategy = (VertxGeneratorStrategy) strategy; }
Example 14
Source File: ThreeScaleImmutableRegistry.java From apiman with Apache License 2.0 | 4 votes |
private String requireOpt(String key, String errorMsg) { Arguments.require(config.containsKey(key), errorMsg); return config.get(key); }
Example 15
Source File: AccessTokenResourceFetcher.java From apiman with Apache License 2.0 | 4 votes |
private String requireOpt(String key, String errorMsg) { Arguments.require(options.containsKey(key), errorMsg); return options.get(key); }
Example 16
Source File: VertxBufferImpl.java From quarkus-http with Apache License 2.0 | 4 votes |
public byte[] getBytes(int start, int end) { Arguments.require(end >= start, "end must be greater or equal than start"); byte[] arr = new byte[end - start]; buffer.getBytes(start, arr, 0, end - start); return arr; }
Example 17
Source File: VertxBufferImpl.java From quarkus with Apache License 2.0 | 4 votes |
@Override public Buffer getBytes(int start, int end, byte[] dst, int dstIndex) { Arguments.require(end >= start, "end must be greater or equal than start"); buffer.getBytes(start, dst, dstIndex, end - start); return this; }
Example 18
Source File: VertxBufferImpl.java From quarkus with Apache License 2.0 | 4 votes |
public byte[] getBytes(int start, int end) { Arguments.require(end >= start, "end must be greater or equal than start"); byte[] arr = new byte[end - start]; buffer.getBytes(start, arr, 0, end - start); return arr; }
Example 19
Source File: VertxBufferImpl.java From quarkus-http with Apache License 2.0 | 4 votes |
@Override public Buffer getBytes(int start, int end, byte[] dst, int dstIndex) { Arguments.require(end >= start, "end must be greater or equal than start"); buffer.getBytes(start, dst, dstIndex, end - start); return this; }