Example usage for org.apache.commons.lang ArrayUtils contains

List of usage examples for org.apache.commons.lang ArrayUtils contains

Introduction

In this page you can find the example usage for org.apache.commons.lang ArrayUtils contains.

Prototype

public static boolean contains(boolean[] array, boolean valueToFind) 

Source Link

Document

Checks if the value is in the given array.

Usage

From source file:ai.walkers.PolorSerinAI2.java

@Override
protected void handleMoveArrived() {
    boolean adultsNear = false;
    for (VisibleObject object : getOwner().getKnownList().getKnownObjects().values()) {
        if (object instanceof Npc) {
            Npc npc = (Npc) object;/*from  w w  w  .  j a  v  a 2s .c o m*/
            if (!ArrayUtils.contains(stopAdults, npc.getNpcId())) {
                continue;
            }
            if (MathUtil.isIn3dRange(npc, getOwner(), getOwner().getAggroRange())) {
                adultsNear = true;
                break;
            }
        }
    }
    if (adultsNear) {
        MoveEventHandler.onMoveArrived(this);
        getOwner().unsetState(CreatureState.WEAPON_EQUIPPED);
    } else {
        super.handleMoveArrived();
        getOwner().setState(CreatureState.WEAPON_EQUIPPED);
    }
}

From source file:gr.abiss.calipso.fs.FilePersistenceService.java

public static void validateContentType(String contentType, FilePersistence config) {
    if (ArrayUtils.isNotEmpty(config.mimeTypeIncludes())
            && !ArrayUtils.contains(config.mimeTypeIncludes(), contentType.toLowerCase())) {
        throw new IllegalArgumentException("Unacceptable MIME type: " + contentType);
    }//ww  w .  j  a  v a 2 s.  co m
}

From source file:com.manydesigns.elements.reflection.GroovyClassAccessor.java

@Override
protected boolean isValidProperty(PropertyAccessor propertyAccessor) {
    // blacklisted?
    if (ArrayUtils.contains(PROPERTY_NAME_BLACKLIST, propertyAccessor.getName())) {
        return false;
    }//w w w  . ja va 2 s .c  o  m
    return super.isValidProperty(propertyAccessor);
}

From source file:com.jaspersoft.studio.server.wizard.pages.UsernameValidator.java

public IStatus validate(Object value) {
    String uname = (String) value;
    if (value == null || uname.isEmpty())
        return ValidationStatus.error(Messages.EmptyStringValidator_EmptyError);
    if (uname.length() > 100)
        return ValidationStatus.error(Messages.UsernameValidator_ErrorMsgUsernameTooLong);
    for (char c : uname.toCharArray()) {
        if (!Character.isSpaceChar(c)) {
            if (!ArrayUtils.contains(NOT_ALLOWED_ID_CHARS, c)) {
                continue;
            } else {
                return ValidationStatus.error(Messages.UsernameValidator_ErrorMsgNotAllowedChars);
            }//from w ww  .  j  a  va  2s  .c o m
        } else {
            return ValidationStatus.error(Messages.UsernameValidator_ErrorMsgNoSpaceChars);
        }
    }

    return Status.OK_STATUS;
}

From source file:net.sf.zekr.ui.BrowserCallbackHandler.java

public Object newCallbackHandler(Object[] args) {
    String method = (String) args[0];
    if (ArrayUtils.contains(new String[] { "ZEKR::GOTO", "ZEKR::REDIRECT" }, method)) {
        int sura = 0, aya = 0, page = 0;
        try {// ww w . ja v  a 2 s . com
            sura = Integer.parseInt(((String) args[1]).trim());
            aya = Integer.parseInt(((String) args[2]).trim());
            if (args.length > 3) {
                page = Integer.parseInt(((String) args[3]).trim());
            }
        } catch (Exception e) {
            return null; // do nothing
        }
        logger.info("Goto (sura: " + sura + ", aya: " + aya + ", page: " + page + ")");
        form.browserGoto(sura, aya, page, method.startsWith("ZEKR::REDIRECT"));
    } else if ("ZEKR::TRANS".equals(method) && config.getTranslation().getDefault() != null) {
        int sura;
        int aya;
        try {
            sura = Integer.parseInt(((String) args[1]).trim());
            aya = Integer.parseInt(((String) args[2]).trim());
        } catch (Exception e1) {
            return null; // do nothing
        }
        PopupBox pe = null;
        boolean isQuranTarget = false;
        if (form.uvc.getViewMode() == IUserView.VM_ADVANCED_SEARCH) {
            isQuranTarget = form.advancedQuranTargetBut.getSelection();
        } else if (form.uvc.getViewMode() == IUserView.VM_SEARCH) {
            isQuranTarget = form.quranTargetBut.getSelection();
        } else { // root
            isQuranTarget = true;
        }

        if (isQuranTarget) {
            logger.info("Show translation: (" + sura + ", " + aya + ")");
            TranslationData td = config.getTranslation().getDefault();
            pe = new PopupBox(form.shell, form.meaning("TRANSLATION_SCOPE"), td.get(sura, aya),
                    FormUtils.toSwtDirection(td.direction));
        } else {
            logger.info("Show quran: (" + sura + ", " + aya + ")");
            try {
                pe = new PopupBox(form.shell, form.meaning("QURAN_SCOPE"),
                        new FilteredQuranText(IQuranText.SIMPLE_MODE, IQuranFilter.NONE).get(sura, aya),
                        SWT.RIGHT_TO_LEFT);
            } catch (IOException e) {
                logger.log(e);
            }
        }
        Point p = form.display.getCursorLocation();
        p.y += 15;
        int x = 300;
        pe.open(new Point(x, 100), new Point(p.x - x / 2, p.y));
    } else if ("ZEKR::NEXT".equals(method)) {
        form.quranFormController.gotoNextAya();
    } else if ("ZEKR::PLAY".equals(method)) {
        IQuranLocation loc = QuranPropertiesUtils.getLocation((String) args[1]);
        boolean play = Boolean.parseBoolean((String) args[2]);
        if (play) {
            PlayableObject playableObject = config.getAudioCacheManager().getPlayableObject(loc, 0);
            if (playableObject == null) {
                logger.error("Search result audio for this location cannot be loaded: " + loc);
            } else {
                logger.debug(String.format("Open search result playable object: %s.", playableObject));
                form.searchPlayerController.open(playableObject);
                form.searchPlayerController.setVolume(config.getPlayerController().getVolume());
                form.searchPlayerController.play();
            }
        } else {
            form.searchPlayerController.stop();
        }
    } else if ("ZEKR::ZOOM".equals(method)) {
        int zoom = (int) Double.parseDouble(args[1].toString());
        String layout = config.getViewLayout();
        boolean onlyTrans = false;
        boolean onlyQuran = false;
        if (ApplicationConfig.SEPARATE_LAYOUT.equals(layout)) {
            onlyTrans = Boolean.parseBoolean(args[2].toString());
            onlyQuran = !Boolean.parseBoolean(args[2].toString());
        }

        ThemeData themeData = config.getTheme().getCurrent();
        Map<String, String> props = themeData.props;

        if (!onlyQuran) {
            for (Entry<String, String> entry : props.entrySet()) {
                String key = entry.getKey();
                if (key.startsWith("trans_") && key.endsWith("fontSize")) {
                    int transFontSize = MapUtils.getIntValue(props, key, 10);
                    transFontSize += zoom;
                    props.put(key, String.valueOf(transFontSize));
                }
            }
        }

        if (!onlyTrans) {
            String quranFontSizeKey = "quran_fontSize";
            int quranFontSize = MapUtils.getIntValue(props, quranFontSizeKey, 10);
            quranFontSize += zoom;
            props.put(quranFontSizeKey, String.valueOf(quranFontSize));
        }

        EventUtils.sendEvent(EventProtocol.REFRESH_VIEW);
    }
    return null;
}

From source file:io.fabric8.elasticsearch.plugin.PluginSettings.java

@Inject
public PluginSettings(final Settings settings) {
    this.kibanaIndexMode = settings.get(OPENSHIFT_KIBANA_INDEX_MODE, KibanaIndexMode.DEFAULT_MODE);
    if (!ArrayUtils.contains(new String[] { UNIQUE, SHARED_OPS, SHARED_NON_OPS },
            kibanaIndexMode.toLowerCase())) {
        this.kibanaIndexMode = UNIQUE;
    }//w w  w  .j  a va 2 s .c o m

    this.roleStrategy = settings.get(OPENSHIFT_ACL_ROLE_STRATEGY, DEFAULT_ACL_ROLE_STRATEGY);
    if (!ArrayUtils.contains(new String[] { PROJECT, USER }, roleStrategy.toLowerCase())) {
        this.kibanaIndexMode = USER;
    }

    this.cdmProjectPrefix = settings.get(OPENSHIFT_CONFIG_PROJECT_INDEX_PREFIX,
            OPENSHIFT_DEFAULT_PROJECT_INDEX_PREFIX);
    this.defaultKibanaIndex = settings.get(KIBANA_CONFIG_INDEX_NAME, DEFAULT_USER_PROFILE_PREFIX);
    this.searchGuardIndex = settings.get(SEARCHGUARD_CONFIG_INDEX_NAME, DEFAULT_SECURITY_CONFIG_INDEX);
    this.kibanaVersion = settings.get(KIBANA_CONFIG_VERSION, DEFAULT_KIBANA_VERSION);
    this.kbnVersionHeader = settings.get(KIBANA_VERSION_HEADER, DEFAULT_KIBANA_VERSION_HEADER);
    this.enabled = settings.getAsBoolean(OPENSHIFT_DYNAMIC_ENABLED_FLAG, OPENSHIFT_DYNAMIC_ENABLED_DEFAULT);

    LOGGER.info("Using kibanaIndexMode: '{}'", this.kibanaIndexMode);
    LOGGER.debug("searchGuardIndex: {}", this.searchGuardIndex);
    LOGGER.debug("roleStrategy: {}", this.roleStrategy);

}

From source file:com.taobao.itest.matcher.AssertExcludedPropertiesEquals.java

/**
 * assertPropertiesEqualsIgnoreOthers /*from ww w . j  ava 2s. c o  m*/
 * Mainly used to compare the two bean, 
 * in addition to ignoring the property, other various attributes are equal
 * 
 *
 * @param expect
 * @param actual
 * @param ignoredProperties   ignoring property,
 *
 * 
 */
public static void assertPropertiesEqualsIgnoreOthers(Object expect, Object actual,
        String... ignoredProperties) {
    if (!ArrayUtils.isEmpty(ignoredProperties)) {
        PropertyDescriptor[] props = BeanUtilsBean.getInstance().getPropertyUtils()
                .getPropertyDescriptors(expect);
        String propertyNames = "";
        for (int i = 0; i < props.length; i++) {
            /*
             * The current bean in the property not for the "class", 
             * nor is ignoredProperties values, this time to put in the comparison
             */
            if (!props[i].getName().equals("class")
                    && !ArrayUtils.contains(ignoredProperties, props[i].getName())) {
                propertyNames += props[i].getName() + ",";
            }
        }
        /*   According to include comparison  */
        AssertPropertiesEquals.assertPropertiesEquals(expect, actual,
                propertyNames.substring(0, propertyNames.length() - 1).split(","));
    } else {
        /*
         * This parameter is empty, the situation has in the upper control,
         * directly through the reflection verified. 
         * But to prevent each other's direct calls, and still retain
         */
        AssertPropertiesEquals.assertPropertiesEquals(expect, actual);
    }
}

From source file:com.swtxml.util.properties.PropertyMatcher.java

public boolean match(Class<?> queryClass, String queryPropertyName, Class<?> queryTargetType) {
    if (forClass != null && !forClass.isAssignableFrom(queryClass)) {
        return false;
    }/*from w  w w.ja  v  a  2s  .co  m*/
    if (propertyName != null && !propertyName.equals(queryPropertyName)) {
        return false;
    }
    if (targetTypes.length > 0 && !ArrayUtils.contains(targetTypes, queryTargetType)) {
        return false;
    }
    return true;
}

From source file:com.piketec.jenkins.plugins.tpt.publisher.PieChart.java

private static void checkLegendSegmentOrder(List<Segment> segments, int[] legendSegmentOrder) {
    if (legendSegmentOrder == null) {
        return;/* w  w  w.ja v  a2s. c  o m*/
    }
    assert legendSegmentOrder.length == segments.size();
    for (int i = 0; i < legendSegmentOrder.length; ++i) {
        assert ArrayUtils.contains(legendSegmentOrder, i);
    }
}

From source file:eionet.cr.web.util.tabs.TabElement.java

/**
 * Class constructor./*from   w ww  . j  av a  2  s.c om*/
 *
 * @param title
 * @param href
 * @param selectedTitle
 */
public TabElement(String title, String href, String... selectedTitle) {
    this.title = title;
    this.href = href;
    selected = ArrayUtils.isEmpty(selectedTitle) ? false : ArrayUtils.contains(selectedTitle, title);
}