org.apache.commons.lang3.ArrayUtils#contains ( )源码实例Demo

下面列出了org.apache.commons.lang3.ArrayUtils#contains ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: carbon-apimgt   文件: OAS2Parser.java
/**
 * Update OAS definition with GW endpoints and API information
 *
 * @param swagger        Swagger
 * @param basePath       API context
 * @param transports     transports types
 * @param hostsWithSchemes GW hosts with protocol mapping
 */
private void updateEndpoints(Swagger swagger, String basePath, String transports,
                             Map<String, String> hostsWithSchemes) {

    String host = StringUtils.EMPTY;
    String[] apiTransports = transports.split(",");
    List<Scheme> schemes = new ArrayList<>();
    if (ArrayUtils.contains(apiTransports, APIConstants.HTTPS_PROTOCOL)
            && hostsWithSchemes.get(APIConstants.HTTPS_PROTOCOL) != null) {
        schemes.add(Scheme.HTTPS);
        host = hostsWithSchemes.get(APIConstants.HTTPS_PROTOCOL).trim()
                .replace(APIConstants.HTTPS_PROTOCOL_URL_PREFIX, "");
    }
    if (ArrayUtils.contains(apiTransports, APIConstants.HTTP_PROTOCOL)
            && hostsWithSchemes.get(APIConstants.HTTP_PROTOCOL) != null) {
        schemes.add(Scheme.HTTP);
        if (StringUtils.isEmpty(host)) {
            host = hostsWithSchemes.get(APIConstants.HTTP_PROTOCOL).trim()
                    .replace(APIConstants.HTTP_PROTOCOL_URL_PREFIX, "");
        }
    }
    swagger.setSchemes(schemes);
    swagger.setBasePath(basePath);
    swagger.setHost(host);
}
 
源代码2 项目: jboot   文件: StrUtil.java
public static Model escapeModel(Model model, String... ignoreAttrs) {
    String[] attrNames = model._getAttrNames();
    for (String attr : attrNames) {

        if (ArrayUtils.contains(ignoreAttrs, attr)) {
            continue;
        }

        Object value = model.get(attr);

        if (value != null && value instanceof String) {
            model.set(attr, escapeHtml(value.toString()));
        }
    }

    return model;
}
 
源代码3 项目: molgenis   文件: SystemEntityTestUtils.java
protected static Object getTestValue(Class returnType, ParameterizedType parameterizedType) {
  if (ArrayUtils.contains(BOOLEAN_CLASS, returnType)) {
    return new Random().nextBoolean();
  }
  if (Entity.class.isAssignableFrom(returnType)) {
    return getTestEntity(returnType);
  }
  if (returnType.equals(Iterable.class)) {
    Object type = getTypedTestEntity(parameterizedType);
    return newArrayList(type);
  }
  if (returnType.equals(LocalDate.class)) {
    return getRandomDate();
  }
  if (returnType.equals(Instant.class)) {
    return Instant.ofEpochSecond(new Random().nextInt());
  }
  if (ArrayUtils.contains(DOUBLE_CLASS, returnType)) {
    return new Random().nextDouble();
  }
  if (returnType.equals(String.class)) {
    return getRandomString();
  }
  if (ArrayUtils.contains(INT_CLASS, returnType)) {
    return new Random().nextInt();
  }
  if (ArrayUtils.contains(LONG_CLASS, returnType)) {
    return new Random().nextLong();
  }
  throw new RuntimeException("Unknown returntype: " + returnType.getSimpleName());
}
 
@Override
public boolean apply(Object object, String name, Object value) {
	if (object instanceof BizEntity) {
		if (ArrayUtils.contains(
				new String[] { "createdBy", "createdDate", "lastModifiedBy", "lastModifiedDate" }, name)) {
			return false;
		}
	}
	return true;
}
 
源代码5 项目: svg2vector   文件: AO_TargetExt.java
/**
 * Returns the target for a given set value.
 * @return the target if valid value in the option, null if no value was set or the required target not in the list of supported targets
 */
public SvgTargets getTarget(){
	SvgTargets target = null;
	try{
		target = SvgTargets.valueOf(this.getValue());
	}
	catch(Exception ignore) {}

	return (ArrayUtils.contains(supportedTargets, target))?target:null;
}
 
源代码6 项目: astor   文件: EqualsBuilder.java
/**
 * <p>Appends the fields and values defined by the given object of the
 * given Class.</p>
 *
 * @param lhs  the left hand object
 * @param rhs  the right hand object
 * @param clazz  the class to append details of
 * @param builder  the builder to append to
 * @param useTransients  whether to test transient fields
 * @param excludeFields  array of field names to exclude from testing
 */
private static void reflectionAppend(
    Object lhs,
    Object rhs,
    Class<?> clazz,
    EqualsBuilder builder,
    boolean useTransients,
    String[] excludeFields) {

    if (isRegistered(lhs, rhs)) {
        return;
    }

    try {
        register(lhs, rhs);
        Field[] fields = clazz.getDeclaredFields();
        AccessibleObject.setAccessible(fields, true);
        for (int i = 0; i < fields.length && builder.isEquals; i++) {
            Field f = fields[i];
            if (!ArrayUtils.contains(excludeFields, f.getName())
                && (f.getName().indexOf('$') == -1)
                && (useTransients || !Modifier.isTransient(f.getModifiers()))
                && (!Modifier.isStatic(f.getModifiers()))) {
                try {
                    builder.append(f.get(lhs), f.get(rhs));
                } catch (IllegalAccessException e) {
                    //this can't happen. Would get a Security exception instead
                    //throw a runtime exception in case the impossible happens.
                    throw new InternalError("Unexpected IllegalAccessException");
                }
            }
        }
    } finally {
        unregister(lhs, rhs);
    }
}
 
源代码7 项目: mybatis-dynamic-query   文件: QueryHelper.java
public String toSelectColumnsExpression(final Class entityClass,
                                        final String[] selectedProperties,
                                        final String[] ignoredProperties,
                                        final boolean mapUnderscoreToCamelCase) {
    ColumnInfo[] columnInfos = entityCache.getColumnInfos(entityClass);
    List<String> columns = new ArrayList<>();
    boolean isSelectedPropertiesNotEmpty = ArrayUtils.isNotEmpty(selectedProperties);
    boolean isIgnoredPropertiesNotEmpty = ArrayUtils.isNotEmpty(ignoredProperties);
    for (ColumnInfo columnInfo : columnInfos) {
        String fieldName = columnInfo.getField().getName();
        boolean needSelectColumn;
        if (isSelectedPropertiesNotEmpty) {
            needSelectColumn = ArrayUtils.contains(selectedProperties, fieldName);
        } else if (isIgnoredPropertiesNotEmpty) {
            needSelectColumn = !ArrayUtils.contains(ignoredProperties, fieldName);
        } else {
            needSelectColumn = true;
        }

        if (needSelectColumn) {
            // 这里我们需要判断一下,是否设置了 @column ,如果有的话,我们不做驼峰
            String useFieldName = mapUnderscoreToCamelCase ? EntityHelper.camelCaseToUnderscore(fieldName) : fieldName;
            String column = String.format("%s AS %s", columnInfo.getQueryColumn(), useFieldName);
            columns.add(column);
        }
    }
    return String.join(", ", columns);
}
 
源代码8 项目: HtmlUnit-Android   文件: HTMLElement.java
/**
 * Returns the value of the {@code vAlign} property.
 * @param valid the valid values; if {@code null}, any value is valid
 * @param defaultValue the default value to use, if necessary
 * @return the value of the {@code vAlign} property
 */
protected String getVAlign(final String[] valid, final String defaultValue) {
    final String valign = getDomNodeOrDie().getAttributeDirect("valign");
    if (valid == null || ArrayUtils.contains(valid, valign)) {
        return valign;
    }
    return defaultValue;
}
 
源代码9 项目: HtmlUnit-Android   文件: HTMLParser.java
private DomNode findElementOnStack(final String... searchedElementNames) {
    DomNode searchedNode = null;
    for (final DomNode node : stack_) {
        if (ArrayUtils.contains(searchedElementNames, node.getNodeName())) {
            searchedNode = node;
            break;
        }
    }

    if (searchedNode == null) {
        searchedNode = stack_.peek(); // this is surely wrong but at least it won't throw a NPE
    }

    return searchedNode;
}
 
源代码10 项目: openemm   文件: UpsellingController.java
private String getView(UpsellingForm form) {
    if (ArrayUtils.contains(CUSTOM_VIEWS, form.getPage())) {
        return form.getPage();
    }

    return GENERAL_VIEW;
}
 
源代码11 项目: yare   文件: DefaultRulesExecutorBuilder.java
/**
 * {@inheritDoc}
 */
@Override
public DefaultRulesExecutorBuilder withFunctionMappings(Map<String, FeaturedObject<CallMetadata>> functionMappings) {
    for (Map.Entry<String, FeaturedObject<CallMetadata>> entry : functionMappings.entrySet()) {
        String name = entry.getKey();
        FeaturedObject<CallMetadata> object = entry.getValue();
        boolean shouldCache = !ArrayUtils.contains(object.getFeatures(), DefaultEngineFeature.DISABLE_CACHE_FUNCTION_RESULT);
        this.functionMappings.put(name, object.getObject());
        withFunctionCacheable(name, shouldCache);
    }
    return this;
}
 
源代码12 项目: kbase-doc   文件: FileExtensionUtils.java
/**
 * 是否是 ppt 文件
 * @author eko.zhan at 2018年9月1日 上午10:16:11
 * @param filename
 * @return
 */
public static Boolean isPpt(String filename) {
	String[] arr = new String[]{"ppt", "pptx"};
	String extension = FilenameUtils.getExtension(filename).toLowerCase();
	if (ArrayUtils.contains(arr, extension)){
		return true;
	}
	return false;
}
 
源代码13 项目: riiablo   文件: HirelingPanel.java
@Override
public void draw(Batch batch, float a) {
  int x, y;
  x = xOffs;
  y = yOffs;

  if (item == null) {
    batch.draw(background, getX() + x, getY() + y);
  }

  boolean blocked = false;
  Item cursorItem = Riiablo.cursor.getItem();
  if (cursorItem != null) {
    blocked = !ArrayUtils.contains(cursorItem.typeEntry.BodyLoc, bodyPart);
  }

  // TODO: red if does not meet item requirements
  boolean isOver = clickListener.isOver();
  PaletteIndexedBatch b = (PaletteIndexedBatch) batch;
  if (isOver && !blocked && (cursorItem != null || item != null)) {
    b.setBlendMode(BlendMode.SOLID, backgroundColorG);
    b.draw(fill, getX(), getY(), getWidth(), getHeight());
    b.resetBlendMode();
  }

  // FIXME: Alt images on weapons are slightly off by maybe a pixel or so (rounding?) -- backgrounds fine
  if (item != null && item.checkLoaded()) {
    BBox box = item.invFile.getBox();
    item.setPosition(
        getX() + getWidth()  / 2 - box.width  / 2f + x,
        getY() + getHeight() / 2 - box.height / 2f + y);
    item.draw(b, 1);
  }

  if (isOver && blocked) {
    b.setBlendMode(BlendMode.SOLID, backgroundColorR);
    b.draw(fill, getX(), getY(), getWidth(), getHeight());
    b.resetBlendMode();
  }

  if (isOver && item != null && cursorItem == null) {
    Riiablo.game.setDetails(item.details(), item, HirelingPanel.this, this);
  }
}
 
源代码14 项目: youran   文件: WordBlacklist.java
public static boolean isClassNameBlacklist(String value) {
    return ArrayUtils.contains(classNameBlacklist, value);
}
 
源代码15 项目: o2oa   文件: ActionDownloadImageWidthHeight.java
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id, Integer width, Integer height)
		throws Exception {
	try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
		ActionResult<Wo> result = new ActionResult<>();
		Attachment2 attachment = emc.find(id, Attachment2.class, ExceptionWhen.not_found);
		/* 判断文件的当前用户是否是管理员或者文件创建者 或者当前用户在分享或者共同编辑中 */
		if (effectivePerson.isNotManager() && effectivePerson.isNotPerson(attachment.getPerson())) {
			throw new Exception("person{name:" + effectivePerson.getDistinguishedName() + "} access attachment{id:"
					+ id + "} denied.");
		}
		if (!ArrayUtils.contains(IMAGE_EXTENSIONS, attachment.getExtension())) {
			throw new Exception("attachment not image file.");
		}
		if (width < 0 || width > 5000) {
			throw new Exception("invalid width:" + width + ".");
		}
		if (height < 0 || height > 5000) {
			throw new Exception("invalid height:" + height + ".");
		}
		OriginFile originFile = emc.find(attachment.getOriginFile(),OriginFile.class);
		if (null == originFile) {
			throw new ExceptionAttachmentNotExist(id,attachment.getOriginFile());
		}
		Wo wo = null;
		String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), id+width+height);
		Element element = cache.get(cacheKey);
		if ((null != element) && (null != element.getObjectValue())) {
			wo = (Wo) element.getObjectValue();
			result.setData(wo);
		} else {
			StorageMapping mapping = ThisApplication.context().storageMappings().get(OriginFile.class,
					originFile.getStorage());
			try (ByteArrayOutputStream output = new ByteArrayOutputStream()) {
				originFile.readContent(mapping, output);
				try (ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray())) {
					BufferedImage src = ImageIO.read(input);
					int scalrWidth = (width == 0) ? src.getWidth() : width;
					int scalrHeight = (height == 0) ? src.getHeight() : height;
					Scalr.Mode mode = Scalr.Mode.FIT_TO_WIDTH;
					if(src.getWidth()>src.getHeight()){
						mode = Scalr.Mode.FIT_TO_HEIGHT;
					}
					BufferedImage scalrImage = Scalr.resize(src,Scalr.Method.SPEED, mode, NumberUtils.min(scalrWidth, src.getWidth()),
							NumberUtils.min(scalrHeight, src.getHeight()));
					try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
						ImageIO.write(scalrImage, "png", baos);
						byte[] bs = baos.toByteArray();

						wo = new Wo(bs, this.contentType(false, attachment.getName()),
								this.contentDisposition(false, attachment.getName()));

						cache.put(new Element(cacheKey, wo));
						result.setData(wo);
					}
				}
			}
		}

		return result;
	}
}
 
源代码16 项目: Sandbox   文件: SidedRespective.java
@Override
public void setStack(int slot, ItemStack stack) {
    if (ArrayUtils.contains(inventory.getInvAvailableSlots(WrappingUtil.convert(direction)), slot))
        super.setStack(slot, stack);
}
 
源代码17 项目: riiablo   文件: InventoryPanel.java
@Override
public void draw(Batch batch, float a) {
  int x, y;
  if (Riiablo.charData.getItems().getAlternate() > 0) {
    x = xOffsAlt == Integer.MIN_VALUE ? xOffs : xOffsAlt;
    y = yOffsAlt == Integer.MIN_VALUE ? yOffs : yOffsAlt;
  } else {
    x = xOffs;
    y = yOffs;
  }

  if (item == null) {
    batch.draw(background, getX() + x, getY() + y);
  }

  boolean blocked = false;
  Item cursorItem = Riiablo.cursor.getItem();
  if (cursorItem != null) {
    blocked = !ArrayUtils.contains(cursorItem.typeEntry.BodyLoc, bodyPart);
  }

  // TODO: red if does not meet item requirements
  boolean isOver = clickListener.isOver();
  PaletteIndexedBatch b = (PaletteIndexedBatch) batch;
  if (isOver && !blocked && (cursorItem != null || item != null)) {
    b.setBlendMode(BlendMode.SOLID, backgroundColorG);
    b.draw(fill, getX(), getY(), getWidth(), getHeight());
    b.resetBlendMode();
  }

  // FIXME: Alt images on weapons are slightly off by maybe a pixel or so (rounding?) -- backgrounds fine
  if (item != null && item.checkLoaded()) {
    BBox box = item.invFile.getBox();
    item.setPosition(
        getX() + getWidth()  / 2 - box.width  / 2f + x,
        getY() + getHeight() / 2 - box.height / 2f + y);
    item.draw(b, 1);
  }

  if (isOver && blocked) {
    b.setBlendMode(BlendMode.SOLID, backgroundColorR);
    b.draw(fill, getX(), getY(), getWidth(), getHeight());
    b.resetBlendMode();
  }

  if (isOver && item != null && cursorItem == null) {
    Riiablo.game.setDetails(item.details(), item, InventoryPanel.this, this);
  }
}
 
源代码18 项目: onetwo   文件: MethodInterceptorAdaptor.java
protected boolean isInterceptMethod(T target, Method method){
	return ArrayUtils.contains(interceptMethodNames, method.getName());
}
 
源代码19 项目: systemds   文件: ParamServer.java
private boolean allFinished() {
	return !ArrayUtils.contains(_finishedStates, false);
}
 
源代码20 项目: systemds   文件: TemplateBase.java
public boolean isIn(TemplateType... types) {
	return ArrayUtils.contains(types, this);
}