本文整理匯總了Java中org.apache.commons.lang.Validate.notEmpty方法的典型用法代碼示例。如果您正苦於以下問題:Java Validate.notEmpty方法的具體用法?Java Validate.notEmpty怎麽用?Java Validate.notEmpty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.lang.Validate
的用法示例。
在下文中一共展示了Validate.notEmpty方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createNode
import org.apache.commons.lang.Validate; //導入方法依賴的package包/類
/**
* @param email Mail of the new user.
* @param username Username of the new user.
* @param first_name First name of the new user.
* @param last_name Last name of the new user.
* @param password Password of the new user OPTIONAL. (Leave blank will be generated by the panel randomly)
* @param root_admin Set the root admin role of the new user.
* @return if success it return the ID of the new user.
*/
public String createNode(String email, String username, String first_name, String last_name, String password, boolean root_admin){
Validate.notEmpty(email, "The MAIL is required");
Validate.notEmpty(username, "The USERNAME is required");
Validate.notEmpty(first_name, "The FIRST_NAME is required");
Validate.notEmpty(last_name, "The LAST_NAME is required");
Validate.notNull(root_admin, "The ROOT_ADMIN Boolean is required");
int admin = (root_admin) ? 1 : 0;
return call(main.getMainURL() + Methods.USERS_CREATE_USER.getURL(),
"email="+email+
"&username="+username+
"&name_first="+first_name+
"&name_last="+last_name+
"&password="+password+
"&root_admin="+admin);
}
示例2: createUser
import org.apache.commons.lang.Validate; //導入方法依賴的package包/類
/**
* @param email Mail of the new user.
* @param username Username of the new user.
* @param first_name First name of the new user.
* @param last_name Last name of the new user.
* @param password Password of the new user OPTIONAL. (Leave blank will be generated by the panel randomly)
* @param root_admin Set the root admin role of the new user.
* @return if success it return the USER class with ATTRIBUTES of the new user.
*/
public User createUser(String email, String username, String first_name, String last_name, String password, boolean root_admin){
Validate.notEmpty(email, "The MAIL is required");
Validate.notEmpty(username, "The USERNAME is required");
Validate.notEmpty(first_name, "The FIRST_NAME is required");
Validate.notEmpty(last_name, "The LAST_NAME is required");
Validate.notNull(root_admin, "The ROOT_ADMIN Boolean is required");
int admin = (root_admin) ? 1 : 0;
JSONObject jsonUserPost = new JSONObject();
jsonUserPost.put("email",email);
jsonUserPost.put("username",email);
jsonUserPost.put("name_first",email);
jsonUserPost.put("name_last",email);
jsonUserPost.put("password",email);
jsonUserPost.put("root_admin",email);
JSONObject jsonObject = new JSONObject(main.getPostMethods().call(main.getMainURL() + POSTMethods.Methods.USERS_CREATE_USER.getURL(),jsonUserPost.toString()));
if(!jsonObject.has("data")){
main.log(Level.SEVERE, jsonObject.toString());
return new User();
}
JSONObject userJSON = jsonObject.getJSONObject("data");
User user = getUser(userJSON.getInt("id"));
return user;
}
示例3: getAccessibleField
import org.apache.commons.lang.Validate; //導入方法依賴的package包/類
/**
* 循環向上轉型, 獲取對象的DeclaredField, 並強製設置為可訪問.
* <p>
* 如向上轉型到Object仍無法找到, 返回null.
*/
public static Field getAccessibleField(final Object obj, final String fieldName) {
Validate.notNull(obj, "object can't be null");
Validate.notEmpty(fieldName, "fieldName can't be blank");
for (Class<?> superClass = obj.getClass(); superClass != Object.class; superClass = superClass.getSuperclass()) {
try {
Field field = superClass.getDeclaredField(fieldName);
makeAccessible(field);
return field;
} catch (NoSuchFieldException e) {//NOSONAR
// Field不在當前類定義,繼續向上轉型
continue;// new add
}
}
return null;
}
示例4: getAccessibleMethod
import org.apache.commons.lang.Validate; //導入方法依賴的package包/類
/**
* 循環向上轉型, 獲取對象的DeclaredMethod,並強製設置為可訪問.
* 如向上轉型到Object仍無法找到, 返回null.
* 匹配函數名+參數類型。
* <p>
* 用於方法需要被多次調用的情況. 先使用本函數先取得Method,然後調用Method.invoke(Object obj, Object... args)
*/
public static Method getAccessibleMethod(final Object obj, final String methodName,
final Class<?>... parameterTypes) {
Validate.notNull(obj, "object can't be null");
Validate.notEmpty(methodName, "methodName can't be blank");
for (Class<?> searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass()) {
try {
Method method = searchType.getDeclaredMethod(methodName, parameterTypes);
makeAccessible(method);
return method;
} catch (NoSuchMethodException e) {
// Method不在當前類定義,繼續向上轉型
continue;// new add
}
}
return null;
}
示例5: getAccessibleMethodByName
import org.apache.commons.lang.Validate; //導入方法依賴的package包/類
/**
* 循環向上轉型, 獲取對象的DeclaredMethod,並強製設置為可訪問.
* 如向上轉型到Object仍無法找到, 返回null.
* 隻匹配函數名。
* <p>
* 用於方法需要被多次調用的情況. 先使用本函數先取得Method,然後調用Method.invoke(Object obj, Object... args)
*/
public static Method getAccessibleMethodByName(final Object obj, final String methodName) {
Validate.notNull(obj, "object can't be null");
Validate.notEmpty(methodName, "methodName can't be blank");
for (Class<?> searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass()) {
Method[] methods = searchType.getDeclaredMethods();
for (Method method : methods) {
if (method.getName().equals(methodName)) {
makeAccessible(method);
return method;
}
}
}
return null;
}
示例6: ParticleShapeDefinition
import org.apache.commons.lang.Validate; //導入方法依賴的package包/類
/**
* Construct a new ParticleShapeDefinition with a given location, and mathmatical equations
* for both the x and z axis
*
* @param initialLocation the initial starting location
* @param xExpression the expression for the x axis
* @param zExpression the expression for the y axis
*/
public ParticleShapeDefinition(Location initialLocation, String xExpression, String zExpression) {
Validate.notNull(initialLocation, "Null initial locations are not supported");
Validate.notEmpty(xExpression, "The x axis expression cannot be null or empty");
Validate.notEmpty(zExpression, "The z axis expression cannot be null or empty");
this.variables.put("x", 0.0);
this.variables.put("z", 0.0);
this.variables.put("t", 0.0);
this.variables.put("theta", 0.0);
this.initialLocation = initialLocation;
this.world = initialLocation.getWorld();
this.xExpression = MathUtils.parseExpression(xExpression, variables);
this.zExpression = MathUtils.parseExpression(zExpression, variables);
}
示例7: InventoryBase
import org.apache.commons.lang.Validate; //導入方法依賴的package包/類
/**
* Simplify creation of bukkit inventories.
*
* @param displayName The inventory name.
* @param slots The inventory slots.
*/
public InventoryBase(String displayName, int slots) {
Validate.notEmpty(displayName);
Validate.isTrue(slots % 9 == 0 && slots > 0);
this.displayName = displayName;
this.slots = slots;
this.items = new HashMap<>();
inventories.add(this);
}
示例8: Itinerary
import org.apache.commons.lang.Validate; //導入方法依賴的package包/類
/**
* Constructor.
*
* @param legs List of legs for this itinerary.
*/
public Itinerary(final List<Leg> legs) {
Validate.notEmpty(legs);
Validate.noNullElements(legs);
this.legs = legs;
}
示例9: Schedule
import org.apache.commons.lang.Validate; //導入方法依賴的package包/類
Schedule(final List<CarrierMovement> carrierMovements) {
Validate.notNull(carrierMovements);
Validate.noNullElements(carrierMovements);
Validate.notEmpty(carrierMovements);
this.carrierMovements = carrierMovements;
}
示例10: createMCServer
import org.apache.commons.lang.Validate; //導入方法依賴的package包/類
/**
* @param name Name of the new server.
* @param user_id ID of a user that exists on the system to assign this server to.
* @param location_id ID of location in which server should be created.
* @param node_id ID of the node to assign this server to. Only required if auto_deploy is false OPTIONAL.
* @param allocation_id ID of allocation to use for the server. Only required if auto_deploy is false OPTIONAL.
* @param memory Total memory (in MB) to assign to the server.
* @param swap Total swap (in MB) to assign to the server.
* @param disk Total disk space (in MB) to assign to the server.
* @param cpu CPU limit adjustment number.
* @param io Block IO adjustment number.
* @param service_id ID of the service this server is using.
* @param option_id ID of the specific service option this server is using.
* @param startup The startup parameters this server is using.
* @param auto_deploy Should the server be auto-deployed to a node.
* @param pack_id The pack ID to use for this server.
* @param custom_container Pass a custom docker image to run this server with.
* @return if success it return the ID of the new server.
*/
public String createMCServer(String name, int user_id, int location_id, int node_id, int allocation_id, int memory, int swap, int disk, int cpu, int io, int service_id, int option_id, String startup, String jarName, String version, boolean auto_deploy, int pack_id, String custom_container){
Validate.notEmpty(name, "The NAME is required");
Validate.notNull(user_id, "The USER_ID is required");
Validate.notNull(location_id, "The location_id is required");
Validate.notNull(memory, "The MEMORY is required");
Validate.notNull(swap, "The SWAP is required");
Validate.notNull(disk, "The DISK is required");
Validate.notNull(cpu, "The CPU is required");
Validate.notNull(io, "The IO is required");
Validate.notNull(service_id, "The SERVICE_ID is required");
Validate.notNull(option_id, "The OPTION_ID is required");
Validate.notNull(startup, "The STARTUP is required");
Validate.notNull(jarName, "The JARNAME is required");
Validate.notNull(version, "The VERSION is required");
int autoDeploy = (auto_deploy) ? 1 : 0;
JSONObject jsonServerPost = new JSONObject();
jsonServerPost.put("name",name);
jsonServerPost.put("user_id",node_id);
jsonServerPost.put("location_id",location_id);
jsonServerPost.put("node_id",node_id);
jsonServerPost.put("allocation_id",allocation_id);
jsonServerPost.put("memory",memory);
jsonServerPost.put("swap",swap);
jsonServerPost.put("disk",disk);
jsonServerPost.put("cpu",cpu);
jsonServerPost.put("io",io);
jsonServerPost.put("service_id",service_id);
jsonServerPost.put("option_id",option_id);
jsonServerPost.put("startup",startup);
jsonServerPost.put("env_SERVER_JARFILE",jarName);
jsonServerPost.put("env_DL_VERSION",version);
jsonServerPost.put("auto_deploy",autoDeploy);
jsonServerPost.put("pack_id",pack_id);
jsonServerPost.put("custom_container",custom_container);
return call(main.getMainURL() + Methods.SERVERS_CREATE_SERVER.getURL(), jsonServerPost.toString());
}
示例11: set
import org.apache.commons.lang.Validate; //導入方法依賴的package包/類
public void set( String path, Object value )
{
Validate.notEmpty( path, "Cannot set to an empty path" );
Configuration root = getRoot();
if ( root == null ) {
throw new IllegalStateException( "Cannot use section without a root" );
}
final char separator = root.options().pathSeparator();
// i1 is the leading (higher) index
// i2 is the trailing (lower) index
int i1 = -1, i2;
ConfigurationSection section = this;
while ( ( i1 = path.indexOf( separator, i2 = i1 + 1 ) ) != -1 ) {
String node = path.substring( i2, i1 );
ConfigurationSection subSection = section.getConfigurationSection( node );
if ( subSection == null ) {
section = section.createSection( node );
}
else {
section = subSection;
}
}
String key = path.substring( i2 );
if ( section == this ) {
if ( value == null ) {
map.remove( key );
}
else {
map.put( key, value );
}
}
else {
section.set( key, value );
}
}
示例12: createSection
import org.apache.commons.lang.Validate; //導入方法依賴的package包/類
public ConfigurationSection createSection( String path )
{
Validate.notEmpty( path, "Cannot create section at empty path" );
Configuration root = getRoot();
if ( root == null ) {
throw new IllegalStateException( "Cannot create section without a root" );
}
final char separator = root.options().pathSeparator();
// i1 is the leading (higher) index
// i2 is the trailing (lower) index
int i1 = -1, i2;
ConfigurationSection section = this;
while ( ( i1 = path.indexOf( separator, i2 = i1 + 1 ) ) != -1 ) {
String node = path.substring( i2, i1 );
ConfigurationSection subSection = section.getConfigurationSection( node );
if ( subSection == null ) {
section = section.createSection( node );
}
else {
section = subSection;
}
}
String key = path.substring( i2 );
if ( section == this ) {
ConfigurationSection result = new MemorySection( this, key );
map.put( key, result );
return result;
}
return section.createSection( key );
}
示例13: DragonTemplate
import org.apache.commons.lang.Validate; //導入方法依賴的package包/類
/**
* Construct a new DragonTemplate object
*
* @param identifier the name to identify this template
* @param name the name of the dragon. Can be null
* @param barStyle the style of the bar. Can be null
* @param barColour the colour of the bar. Can be null
*/
public DragonTemplate(String identifier, String name, BarStyle barStyle, BarColor barColour) {
Validate.notEmpty(identifier, "Idenfitier must not be empty or null");
this.file = null;
this.configFile = null;
this.identifier = identifier;
this.name = (name != null ? ChatColor.translateAlternateColorCodes('&', name) : null);
this.barStyle = (barStyle != null ? barStyle : BarStyle.SOLID);
this.barColour = (barColour != null ? barColour : BarColor.PINK);
this.loot = new DragonLoot(this);
}
示例14: createNode
import org.apache.commons.lang.Validate; //導入方法依賴的package包/類
/**
* Create a new node
* @param name NAME of the new NODE.
* @param location_id LOCATION_ID corresponding to the location this node should exist under.
* @param publicNode PUBLIC Should this node be public on the system (allows auto-allocation of servers) (0 or 1).
* @param fqdn FQDN or IP to use for this node.
* @param scheme SCHEME Should be https or http depending on the scheme to use when connecting to the node.
* @param behind_proxy If you are running the daemon behind a proxy such as Cloudflare set true
* @param memory MEMORY Total amount of memory in MB to be available for allocation on this node.
* @param memory_overallocate MEMORY_OVERALLOCATE Percentage of memory overallocation allowed.
* @param disk DISK Amount of disk space allowed for allocation.
* @param disk_overallocate DISK_OVERALLOCATE Percentage of disk overallocation allowed.
* @param daemonBase DAEMON_BASE Base directory for daemon files.
* @param daemonListen DAEMON_LISTEN Default listening port for daemon.
* @param daemonSFTP DAEMON_SFTP Default SFTP port for daemon.
* @return if success it return the NODE class with ATTRIBUTES of the new node.
*/
public Node createNode(String name, int location_id, boolean publicNode, String fqdn, String scheme, boolean behind_proxy, int memory, int memory_overallocate, int disk, int disk_overallocate, String daemonBase, int daemonListen, int daemonSFTP){
Validate.notEmpty(name, "The NAME is required");
Validate.notNull(location_id, "The LOCATION_ID is required");
Validate.notNull(publicNode, "The PUBLIC variable is required");
Validate.notEmpty(fqdn, "The FQDN is required");
Validate.notEmpty(scheme, "The SCHEME is required");
Validate.notNull(behind_proxy, "The BEHIND_PROXY is required");
Validate.notNull(memory, "The MEMORY is required");
Validate.notNull(memory_overallocate, "The MEMORY_OVERALLOCATE is required");
Validate.notNull(disk, "The DISK is required");
Validate.notNull(disk_overallocate, "The DISK_OVERALLOCATE is required");
Validate.notEmpty(daemonBase, "The DAEMON_BASE is required");
Validate.notNull(daemonListen, "The DAEMON_LISTEN is required");
Validate.notNull(daemonSFTP, "The DAEMON_SFTP is required");
int publicNodeInt = (publicNode) ? 1 : 0;
int behindProxyInt = (behind_proxy) ? 1 : 0;
JSONObject jsonNodeRequest = new JSONObject();
jsonNodeRequest.put("name",name);
jsonNodeRequest.put("location_id",location_id);
jsonNodeRequest.put("public",publicNodeInt);
jsonNodeRequest.put("fqdn",fqdn);
jsonNodeRequest.put("behind_proxy",behindProxyInt);
jsonNodeRequest.put("scheme",scheme);
jsonNodeRequest.put("memory",memory);
jsonNodeRequest.put("memory_overallocate",memory_overallocate);
jsonNodeRequest.put("disk",disk);
jsonNodeRequest.put("disk_overallocate",disk_overallocate);
jsonNodeRequest.put("daemonBase",daemonBase);
jsonNodeRequest.put("daemonListen",daemonListen);
jsonNodeRequest.put("daemonSFTP",daemonSFTP);
JSONObject jsonObject = new JSONObject(main.getPostMethods().call(main.getMainURL() + POSTMethods.Methods.NODES_CREATE_NODE.getURL(),
jsonNodeRequest.toString()));
System.out.println("DEBUG: \n" + jsonNodeRequest.toString());
if(!jsonObject.has("data")){
main.log(Level.SEVERE, jsonObject.toString());
return new Node();
}
JSONObject nodeJSON = jsonObject.getJSONObject("data");
Node node = getNode(nodeJSON.getInt("id"));
return node;
}