public void setCorePoolSize(int poolSize) { Args.assertTrue(poolSize > 1,"poolSize must be 1 or higer"); this.corePoolSize = poolSize; }
public Limit(int start,int end) { Args.assertTrue(start > 0 && end > 0 && end >= start, "Invalid start and end"); this.start = start; this.end = end; }
@ConfigProperty public DefaultSecurityConfig setDefaultRememberMeExpires(int defaultRememberExpires) { Args.assertTrue(defaultRememberExpires > 0, "Expires must be > 0"); this.defaultRememberMeExpires = defaultRememberExpires; return this; }
static int advance(Iterator<?> iterator, int numberToAdvance) { Args.notNull(iterator); Args.assertTrue(numberToAdvance >= 0, "numberToAdvance"); int i; for (i = 0; i < numberToAdvance && iterator.hasNext(); i++) { iterator.next(); } return i; }
public ElStaticField(ReflectField field) { Args.assertTrue(field.isStatic(),"Must be static field"); this.field = field; }
public static ReflectEnum of(Class<?> enumType){ Args.notNull(enumType,"enumType"); Args.assertTrue(enumType.isEnum(),"'" + enumType.getName() + "' is not an enum type"); ReflectEnum reflectEnum = cache.get(enumType); if(null == reflectEnum){ reflectEnum = new ReflectEnum(enumType); cache.put(enumType, reflectEnum); } return reflectEnum; }
public TypeInfo(Class<?> type, Type genericType, MTypeKind kind,Class<?> elementType, TypeInfo elementTypeInfo) { Args.notNull(type,"type"); Args.notNull(kind,"kind"); if(null != elementType){ Args.assertTrue(kind == MTypeKind.COLLECTION, "The element type must not be null if the kind is 'COLLECTION'"); Args.assertTrue(elementTypeInfo != null,"The element type info must not be null if the element type is not null"); }else{ Args.assertFalse(kind == MTypeKind.COLLECTION, "The element type must be null if the kind is not 'COLLECTION'"); Args.assertTrue(elementTypeInfo == null, "The element type info must be null if the element type is null"); } this.type = type; this.genericType = genericType; this.typeKind = kind; this.elementType = elementType; this.elementTypeInfo = elementTypeInfo; }
/** * Register a global function. */ @Override public void registerFunction(String prefix,String name,Method m) { int modifiers = m.getModifiers(); Args.assertTrue(Modifier.isPublic(modifiers) && Modifier.isStatic(modifiers), "Method '" + m.getName() + "' must be 'public static'"); functions.put(getFunctionFullName(prefix, name), new ElStaticMethod(m)); }
public void setBasePath(String basePath) { Args.notEmpty(basePath, "basePath"); Args.assertTrue(basePath.startsWith("/"), "The base path must be leading with a slash '/'"); this.basePath = Paths.suffixWithoutSlash(basePath); }
/** * Attempt to find a {@link Field field} on the supplied {@link Class} with the supplied <code>name</code> and/or * {@link Class type}. * * Searches all superclasses up to {@link Object}. * * @param clazz the class to introspect * @param name the name of the field (may be <code>null</code> if type is specified) * @param type the type of the field (may be <code>null</code> if name is specified) * @return the corresponding Field object, or <code>null</code> if not found */ public static Field findField(Class<?> clazz, String name, Class<?> type) { Args.notNull(clazz, "clazz"); Args.assertTrue(name != null || type != null, "Either name or type of the field must be specified"); Class<?> searchType = clazz; while (!Object.class.equals(searchType) && searchType != null) { Field[] fields = searchType.getDeclaredFields(); for (Field field : fields) { if ((name == null || name.equals(field.getName())) && (type == null || type.equals(field.getType()))) { return field; } } searchType = searchType.getSuperclass(); } return null; }
public DefaultApiConfig(String name, String basePath, Object source) { Args.notEmpty(name, "name"); Args.notEmpty(basePath, "basePath"); Args.assertTrue(basePath.startsWith("/"), "The base path must be leading with a slash '/'"); this.source = source; this.name = name; this.title = name; this.setBasePath(basePath); }
private ElConstantField(ReflectField field) { Args.assertTrue(field.isStatic() && field.isFinal(),"Must be static final field"); this.value = field.getValue(null); }
@Instrument public static <T extends Model> List<T> lastCreated(int num) { Args.assertTrue(num > 0,"num must be > 0"); return (List<T>)query().lastCreated(num).list(); }
@Instrument public static <T extends Model> List<T> lastUpdated(int num) { Args.assertTrue(num > 0,"num must be > 0"); return (List<T>)query().lastUpdated().list(); }
@Override public int executeUpdate(Connection connection, String sql, Object[] args, int[] types) throws NestedSQLException { Args.notNull(connection, "connection"); Args.notEmpty(sql,"sql"); Args.notNull(args); Args.notNull(types); Args.assertTrue(args.length == types.length || types.length == 0,"args length must equals to types length"); return doExecuteUpdate(connection, sql, args, types, null); }
@Override public int executeUpdate(Connection connection, String sql, Object[] args, int[] types, PreparedStatementHandler<Db> handler) throws NestedSQLException { Args.notNull(connection, "connection"); Args.notEmpty(sql,"sql"); Args.notNull(args); Args.notNull(types); Args.assertTrue(args.length == types.length || types.length == 0,"args length must equals to types length"); return doExecuteUpdate(connection, sql, args, types, handler); }
@Instrument public static <T extends Model> List<T> first(int num) { Args.assertTrue(num > 0,"num must be > 0"); return (List<T>)query().orderByIdAsc().limit(num).list(); }
@Instrument public static <T extends Model> List<T> last(int num) { Args.assertTrue(num > 0,"num must be > 0"); return (List<T>)query().orderByIdDesc().limit(num).list(); }
@Override public <T> T executeQuery(Connection connection, String sql, Object[] args, int[] types, ResultSetReader<T> reader) throws NestedSQLException { Args.notNull(connection,"connection"); Args.notEmpty(sql,"sql"); Args.notNull(args,"args"); Args.notNull(types,"types"); Args.assertTrue(args.length == types.length || types.length == 0,"args length must equals to types length"); Args.notNull(reader); return doExecuteQuery(connection, sql, args, types, reader); }
protected JdkHttpRequest(JdkHttpClient client, String url) { Args.notEmpty(url, "url"); Args.assertTrue(Strings.startsWithIgnoreCase(url, HttpClient.PREFIX_HTTP) || Strings.startsWithIgnoreCase(url, HttpClient.PREFIX_HTTPS), "The url must prefix with http:// or https://"); this.client = client; this.url = url; this.ssl = Strings.startsWithIgnoreCase(url, HttpClient.PREFIX_HTTPS); this.connectTimeout = client.getDefaultConnectTimeout(); this.readTimeout = client.getDefaultReadTimeout(); this.charset = client.getDefaultCharset(); }