本文整理汇总了Java中org.apache.commons.lang3.ArrayUtils.contains方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayUtils.contains方法的具体用法?Java ArrayUtils.contains怎么用?Java ArrayUtils.contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang3.ArrayUtils
的用法示例。
在下文中一共展示了ArrayUtils.contains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: WeightedSegmentsFormatter
import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
public WeightedSegmentsFormatter(final String[] args) {
if (args != null) {
prependPriority = ArrayUtils.contains(args, "-pp") || ArrayUtils.contains(args, "-prependPriority");
int index1 = ArrayUtils.indexOf(args, "-weight");
if (index1 < args.length - 1) {
final String weightString = args[index1 + 1];
Validate.isTrue(NumberUtils.isParsable(weightString), "Please provide a numeric value for weight.");
this.weight = Integer.parseInt(weightString);
}
int index2 = ArrayUtils.indexOf(args, "-separator");
if (index2 < args.length - 1) {
valueSeparator = args[index2 + 1];
}
}
}
示例2: permitted
import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
public PermissionInfo permitted() {
Subject currentUser = SecurityUtils.getSubject();
if (TYPE.ROLE.equals(this.type)) {
// role based
if (Logical.AND.equals(this.logical)) {
isPermitted = currentUser.hasAllRoles(Arrays.asList(roles));
return this;
}
isPermitted = ArrayUtils.contains(currentUser.hasRoles(Arrays.asList(roles)), true);
return this;
}
// permission based
if (Logical.AND.equals(this.logical)) {
isPermitted = currentUser.isPermittedAll(permissions);
return this;
}
isPermitted = ArrayUtils.contains(currentUser.isPermitted(permissions), true);
return this;
}
示例3: handle
import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
@Override
public CompletableFuture<Response> handle(Command command, Arguments arguments, Response response, IDebugAdapterContext context) {
if (context.getDebugSession() == null) {
return AdapterUtils.createAsyncErrorResponse(response, ErrorCode.EMPTY_DEBUG_SESSION, "Empty debug session.");
}
String[] filters = ((SetExceptionBreakpointsArguments) arguments).filters;
try {
boolean notifyCaught = ArrayUtils.contains(filters, Types.ExceptionBreakpointFilter.CAUGHT_EXCEPTION_FILTER_NAME);
boolean notifyUncaught = ArrayUtils.contains(filters, Types.ExceptionBreakpointFilter.UNCAUGHT_EXCEPTION_FILTER_NAME);
context.getDebugSession().setExceptionBreakpoints(notifyCaught, notifyUncaught);
return CompletableFuture.completedFuture(response);
} catch (Exception ex) {
return AdapterUtils.createAsyncErrorResponse(response, ErrorCode.SET_EXCEPTIONBREAKPOINT_FAILURE,
String.format("Failed to setExceptionBreakpoints. Reason: '%s'", ex.toString()));
}
}
示例4: getRandomSoundFromCategories
import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
/**
* Returns a random sound from one or more categories
*/
public SoundEventAccessorComposite getRandomSoundFromCategories(SoundCategory... categories)
{
List<SoundEventAccessorComposite> list = Lists.<SoundEventAccessorComposite>newArrayList();
for (ResourceLocation resourcelocation : this.sndRegistry.getKeys())
{
SoundEventAccessorComposite soundeventaccessorcomposite = (SoundEventAccessorComposite)this.sndRegistry.getObject(resourcelocation);
if (ArrayUtils.contains(categories, soundeventaccessorcomposite.getSoundCategory()))
{
list.add(soundeventaccessorcomposite);
}
}
if (list.isEmpty())
{
return null;
}
else
{
return (SoundEventAccessorComposite)list.get((new Random()).nextInt(list.size()));
}
}
示例5: createAttributeCache
import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
private AttributeCache createAttributeCache(final String cacheType, final long maxCachedIntervalMinutes,
final String zoneName, final RedisTemplate<String, String> cacheRedisTemplate,
final BiFunction<String, String, String> getKey, final boolean enableAttributeCaching) {
String[] profiles = environment.getActiveProfiles();
if (!enableAttributeCaching) {
LOGGER.info("Caching disabled for {} attributes.", cacheType);
return new NonCachingAttributeCache();
}
if (ArrayUtils.contains(profiles, "redis") || ArrayUtils.contains(profiles, "cloud-redis")) {
LOGGER.info("Redis caching enabled for {} attributes.", cacheType);
return new RedisAttributeCache(maxCachedIntervalMinutes, zoneName, getKey, cacheRedisTemplate);
}
LOGGER.info("In-memory caching enabled for {} attributes.", cacheType);
return new InMemoryAttributeCache(maxCachedIntervalMinutes, zoneName, getKey);
}
示例6: propertiesToStringMap
import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
private static Map<String, String> propertiesToStringMap(final Properties properties) {
final Map<String, String> map = new HashMap<String, String>();
for (String key : properties.stringPropertyNames()) {
// 过滤掉受保护的key
if (ArrayUtils.contains(PROTECT_KEY_ARRAY, key)
&& map.containsKey(key)) {
continue;
}
map.put(key, properties.getProperty(key));
}
return map;
}
示例7: escapeRegChars
import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
/**
* 将除了指定字符之外的所有正则元字符全部用转义符更改为字面含义
* @param key
* @param
* @return
*/
public static String escapeRegChars(String key, char[] keeps) {
for(char c:REGEXP_KEY_CHARS){
if(!ArrayUtils.contains(keeps, c)){
key=key.replace(String.valueOf(c),"\\"+c);
}
}
return key;
}
示例8: getContentInfo
import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
/**
* 创建Content基本信息.
*/
private ContentInfo getContentInfo(String contentPath) {
ContentInfo contentInfo = new ContentInfo();
String realFilePath = this.findRealFilePath(contentPath);
logger.debug("realFilePath {}", realFilePath);
File file = new File(realFilePath);
contentInfo.setFile(file);
contentInfo.setContentPath(contentPath);
contentInfo.setFileName(file.getName());
contentInfo.setLength((int) file.length());
contentInfo.setLastModified(file.lastModified());
contentInfo.setEtag("W/\"" + contentInfo.lastModified + "\"");
contentInfo.setMimeType(mimetypesFileTypeMap
.getContentType(contentInfo.fileName));
if ((contentInfo.length >= GZIP_MINI_LENGTH)
&& ArrayUtils.contains(GZIP_MIME_TYPES,
contentInfo.getMimeType())) {
contentInfo.setNeedGzip(true);
} else {
contentInfo.setNeedGzip(false);
}
return contentInfo;
}
示例9: filterServerResponseHeader
import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
@Override
protected String filterServerResponseHeader(final HttpServletRequest clientRequest, final Response serverResponse, final String headerName,
final String headerValue) {
// Filter some headers
final String lowerCase = StringUtils.lowerCase(headerName);
return ArrayUtils.contains(INGNORE_HEADERS, lowerCase)
|| INGORE_HEADER_VALUE.containsKey(lowerCase) && headerValue.startsWith(INGORE_HEADER_VALUE.get(lowerCase)) ? null : headerValue;
}
示例10: checkParameters
import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
private void checkParameters(WxPayRefundRequest request) throws WxErrorException {
BeanUtils.checkRequiredFields(request);
if (StringUtils.isNotBlank(request.getRefundAccount())) {
if (!ArrayUtils.contains(REFUND_ACCOUNT, request.getRefundAccount())) {
throw new IllegalArgumentException("refund_account目前必须为" + Arrays.toString(REFUND_ACCOUNT) + "其中之一,实际值:" + request.getRefundAccount());
}
}
if (StringUtils.isBlank(request.getOutTradeNo()) && StringUtils.isBlank(request.getTransactionId())) {
throw new IllegalArgumentException("transaction_id 和 out_trade_no 不能同时为空,必须提供一个");
}
}
示例11: urlReturnsCode
import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
public static BooleanSupplier urlReturnsCode(String url, int... codes) {
return () -> {
try {
int responseCode = HttpClient.get(url).code();
return ArrayUtils.contains(codes, responseCode);
} catch (IOException x) {
return false;
}
};
}
示例12: validate
import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
private void validate() {
super.validate(getRegisterCount());
if (range == RegisterRange.COIL_STATUS || range == RegisterRange.INPUT_STATUS)
throw new IllegalDataTypeException("Only binary values can be read from Coil and Input ranges");
if (!ArrayUtils.contains(DATA_TYPES, dataType))
throw new IllegalDataTypeException("Invalid data type");
}
示例13: hasColor
import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
@Override
protected boolean hasColor(ItemStack stack) {
int[] ids = OreDictionary.getOreIDs(stack);
for (int id : ids) {
if (ArrayUtils.contains(PonySocks.dyeOreIds, id)) {
return true;
}
}
return false;
}
示例14: moveStacks
import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
public void moveStacks()
{
for (int i = 0; i < getSlots(); i++)
{
if (!ArrayUtils.contains(destSlots, i))
{
ItemStack src = getStackInSlot(i);
if (!src.isEmpty())
{
ItemStack remainder = moveStackToFirstDest(src);
setStackInSlot(i, remainder);
}
}
}
}
示例15: hasCapability
import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
@Override
public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing)
{
return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY &&
(facing == null || ArrayUtils.contains(supplier.sides, facing));
}