Example usage for org.apache.commons.lang3 StringUtils equals

List of usage examples for org.apache.commons.lang3 StringUtils equals

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils equals.

Prototype

public static boolean equals(final CharSequence cs1, final CharSequence cs2) 

Source Link

Document

Compares two CharSequences, returning true if they represent equal sequences of characters.

null s are handled without exceptions.

Usage

From source file:io.wcm.testing.mock.aem.MockRendition.java

@Override
public boolean equals(Object obj) {
    if (!(obj instanceof MockRendition)) {
        return false;
    }/*from w ww .  j  a  va  2 s.c o m*/
    return StringUtils.equals(getPath(), ((MockRendition) obj).getPath());
}

From source file:io.wcm.devops.conga.generator.util.VariableMapResolver.java

private static String replaceString(String value, Map<String, Object> variables) {
    String replacedValue = VariableStringResolver.resolve(value, variables, false);
    if (StringUtils.equals(value, replacedValue)) {
        return value;
    } else {//www. j  a  va 2  s.  co  m
        return replacedValue;
    }
}

From source file:com.msg.wmTestHelper.metaModel.extractor.WaitStepExtractor.java

private boolean isWaitStep(Element publishedDoc) {

    if (publishedDoc == null) {
        return false;
    }/* w w w.  jav  a  2  s  .  c om*/

    String docName = extractPlainValue(publishedDoc, "docName");

    return StringUtils.isNotEmpty(docName)
            && (StringUtils.equals(ProprietaryHelper.getConfig("wait.1.startmessage"), docName)
                    || StringUtils.equals(ProprietaryHelper.getConfig("wait.2.startmessage"), docName)
                    || StringUtils.equals(ProprietaryHelper.getConfig("wait.3.startmessage"), docName));
}

From source file:com.adeptj.modules.cache.caffeine.internal.CaffeineCacheService.java

public void unbindCaffeineCacheFactory(CaffeineCacheFactory cacheFactory) {
    this.caches.removeIf(cache -> StringUtils.equals(cache.getName(), cacheFactory.getCacheConfig().name()));
}

From source file:com.adeptj.runtime.tools.logging.LogbackManager.java

public Appender<ILoggingEvent> getAppender(String name) {
    return this.appenderList.stream().filter(appender -> StringUtils.equals(appender.getName(), name))
            .findFirst().orElse(null);/*from w ww . j a  v  a 2s .  com*/
}

From source file:io.github.swagger2markup.internal.component.BodyParameterComponent.java

@Override
public MarkupDocBuilder apply(MarkupDocBuilder markupDocBuilder, Parameters params) {
    PathOperation operation = params.operation;
    List<ObjectType> inlineDefinitions = params.inlineDefinitions;
    if (config.isFlatBodyEnabled()) {
        List<Parameter> parameters = operation.getOperation().getParameters();
        if (CollectionUtils.isNotEmpty(parameters)) {
            for (Parameter parameter : parameters) {
                if (StringUtils.equals(parameter.getIn(), "body")) {
                    ParameterAdapter parameterAdapter = new ParameterAdapter(context, operation, parameter,
                            definitionDocumentResolver);

                    Type type = parameterAdapter.getType();
                    inlineDefinitions.addAll(parameterAdapter.getInlineDefinitions());

                    buildSectionTitle(markupDocBuilder, labels.getLabel(BODY_PARAMETER));
                    String description = parameter.getDescription();
                    if (isNotBlank(description)) {
                        markupDocBuilder.paragraph(markupDescription(config.getSwaggerMarkupLanguage(),
                                markupDocBuilder, description));
                    }//w  w  w  . ja v  a2  s . co m

                    MarkupDocBuilder typeInfos = copyMarkupDocBuilder(markupDocBuilder);
                    typeInfos.italicText(labels.getLabel(NAME_COLUMN)).textLine(COLON + parameter.getName());
                    typeInfos.italicText(labels.getLabel(FLAGS_COLUMN))
                            .textLine(COLON + (BooleanUtils.isTrue(parameter.getRequired())
                                    ? labels.getLabel(FLAGS_REQUIRED).toLowerCase()
                                    : labels.getLabel(FLAGS_OPTIONAL).toLowerCase()));

                    if (!(type instanceof ObjectType)) {
                        typeInfos.italicText(labels.getLabel(TYPE_COLUMN))
                                .textLine(COLON + type.displaySchema(markupDocBuilder));
                    }

                    markupDocBuilder.paragraph(typeInfos.toString(), true);

                    if (type instanceof ObjectType) {
                        List<ObjectType> localDefinitions = new ArrayList<>();

                        propertiesTableComponent.apply(markupDocBuilder, PropertiesTableComponent.parameters(
                                ((ObjectType) type).getProperties(), operation.getId(), localDefinitions));

                        inlineDefinitions.addAll(localDefinitions);
                    }
                }
            }
        }
    }
    return markupDocBuilder;
}

From source file:de.seitenbau.govdata.edit.model.EditForm.java

/**
 * Checks if the edit form contains a new dataset.
 * /*  w  w  w  .j  av  a  2 s. c om*/
 * @return true, if the form contains a new dataset, otherwise false.
 */
public boolean isNewDataset() {
    return StringUtils.equals(getName(), Constants.NAME_NEW_DATASET);
}

From source file:io.wcm.testing.mock.aem.MockAssetTest.java

private boolean hasRendition(List<Rendition> renditions, String renditionName) {
    for (Rendition rendition : renditions) {
        if (StringUtils.equals(rendition.getName(), renditionName)) {
            return true;
        }/*  w  w  w. j  av a 2 s  .c om*/
    }
    return false;
}

From source file:net.dv8tion.jda.handle.ChannelUpdateHandler.java

@Override
protected String handleInternally(JSONObject content) {
    if (GuildLock.get(api).isLocked(content.getString("guild_id"))) {
        return content.getString("guild_id");
    }//from  w w w. java2 s.co  m

    String name = content.getString("name");
    int position = content.getInt("position");
    JSONArray permOverwrites = content.getJSONArray("permission_overwrites");
    ChannelType type = ChannelType.fromId(content.getInt("type"));
    switch (type) {
    case TEXT: {
        String topic = content.isNull("topic") ? null : content.getString("topic");
        TextChannelImpl channel = (TextChannelImpl) api.getChannelMap().get(content.getString("id"));
        if (channel == null) {
            EventCache.get(api).cache(EventCache.Type.CHANNEL, content.getString("id"), () -> {
                handle(allContent);
            });
            EventCache.LOG.debug(
                    "CHANNEL_UPDATE attemped to update a TextChannel that does not exist. JSON: " + content);
            return null;
        }

        //If any properties changed, update the values and fire the proper events.
        if (!StringUtils.equals(channel.getName(), name)) {
            String oldName = channel.getName();
            channel.setName(name);
            api.getEventManager().handle(new TextChannelUpdateNameEvent(api, responseNumber, channel, oldName));
        }
        if (!StringUtils.equals(channel.getTopic(), topic)) {
            String oldTopic = channel.getTopic();
            channel.setTopic(topic);
            api.getEventManager()
                    .handle(new TextChannelUpdateTopicEvent(api, responseNumber, channel, oldTopic));
        }
        if (channel.getPositionRaw() != position) {
            int oldPosition = channel.getPositionRaw();
            channel.setPosition(position);
            api.getEventManager()
                    .handle(new TextChannelUpdatePositionEvent(api, responseNumber, channel, oldPosition));
        }

        //Determines if a new PermissionOverride was created or updated.
        //If a PermissionOverride was created or updated it stores it in the proper Map to be reported by the Event.
        for (int i = 0; i < permOverwrites.length(); i++) {
            handlePermissionOverride(permOverwrites.getJSONObject(i), channel, content);
        }

        //Check if any overrides were deleted because of this event.
        //Get the current overrides. (we copy them to a new list because the Set returned is backed by the Map, meaning our removes would remove from the Map. Not good.
        //Loop through all of the json defined overrides. If we find a match, remove the User or Role from our lists.
        //Any entries remaining in these lists after this for loop is over will be removed from the Channel's overrides.
        List<Role> collect = channel.getRolePermissionOverridesMap().keySet().stream()
                .filter(role -> !containedRoles.contains(role)).collect(Collectors.toList());
        collect.forEach(role -> {
            changedRoles.add(role);
            channel.getRolePermissionOverridesMap().remove(role);
        });
        List<User> collect1 = channel.getUserPermissionOverridesMap().keySet().stream()
                .filter(user -> !containedUsers.contains(user)).collect(Collectors.toList());
        collect1.forEach(user -> {
            changedUsers.add(user);
            channel.getUserPermissionOverridesMap().remove(user);
        });

        //If this update modified permissions in any way.
        if (!changedRoles.isEmpty() || !changedUsers.isEmpty()) {
            api.getEventManager().handle(new TextChannelUpdatePermissionsEvent(api, responseNumber, channel,
                    changedRoles, changedUsers));
        }
        break; //Finish the TextChannelUpdate case
    }
    case VOICE: {
        VoiceChannelImpl channel = (VoiceChannelImpl) api.getVoiceChannelMap().get(content.getString("id"));
        int userLimit = content.getInt("user_limit");
        int bitrate = content.getInt("bitrate");
        if (channel == null) {
            EventCache.get(api).cache(EventCache.Type.CHANNEL, content.getString("id"), () -> {
                handle(allContent);
            });
            EventCache.LOG.debug(
                    "CHANNEL_UPDATE attemped to update a VoiceChannel that does not exist. JSON: " + content);
            return null;
        }
        //If any properties changed, update the values and fire the proper events.
        if (!StringUtils.equals(channel.getName(), name)) {
            String oldName = channel.getName();
            channel.setName(name);
            api.getEventManager()
                    .handle(new VoiceChannelUpdateNameEvent(api, responseNumber, channel, oldName));
        }
        if (channel.getPositionRaw() != position) {
            int oldPosition = channel.getPositionRaw();
            channel.setPosition(position);
            api.getEventManager()
                    .handle(new VoiceChannelUpdatePositionEvent(api, responseNumber, channel, oldPosition));
        }
        if (channel.getUserLimit() != userLimit) {
            int oldLimit = channel.getUserLimit();
            channel.setUserLimit(userLimit);
            api.getEventManager()
                    .handle(new VoiceChannelUpdateUserLimitEvent(api, responseNumber, channel, oldLimit));
        }
        if (channel.getBitrate() != bitrate) {
            int oldBitrate = channel.getBitrate();
            channel.setBitrate(bitrate);
            api.getEventManager()
                    .handle(new VoiceChannelUpdateBitrateEvent(api, responseNumber, channel, oldBitrate));
        }

        //Determines if a new PermissionOverride was created or updated.
        //If a PermissionOverride was created or updated it stores it in the proper Map to be reported by the Event.
        for (int i = 0; i < permOverwrites.length(); i++) {
            handlePermissionOverride(permOverwrites.getJSONObject(i), channel, content);
        }

        //Check if any overrides were deleted because of this event.
        //Get the current overrides. (we copy them to a new list because the Set returned is backed by the Map, meaning our removes would remove from the Map. Not good.
        //Loop through all of the json defined overrides. If we find a match, remove the User or Role from our lists.
        //Any entries remaining in these lists after this for loop is over will be removed from the Channel's overrides.
        List<Role> collect = channel.getRolePermissionOverridesMap().keySet().stream()
                .filter(role -> !containedRoles.contains(role)).collect(Collectors.toList());
        collect.forEach(role -> {
            changedRoles.add(role);
            channel.getRolePermissionOverridesMap().remove(role);
        });
        List<User> collect1 = channel.getUserPermissionOverridesMap().keySet().stream()
                .filter(user -> !containedUsers.contains(user)).collect(Collectors.toList());
        collect1.forEach(user -> {
            changedUsers.add(user);
            channel.getUserPermissionOverridesMap().remove(user);
        });

        //If this update modified permissions in any way.
        if (!changedRoles.isEmpty() || !changedUsers.isEmpty()) {
            api.getEventManager().handle(new VoiceChannelUpdatePermissionsEvent(api, responseNumber, channel,
                    changedRoles, changedUsers));
        }
        break; //Finish the TextChannelUpdate case
    }
    default:
        throw new IllegalArgumentException(
                "CHANNEL_UPDATE provided an unrecognized channel type JSON: " + content);
    }
    return null;
}

From source file:com.glaf.mail.web.springmvc.MailAccountController.java

@RequestMapping
public ModelAndView list(HttpServletRequest request, ModelMap modelMap) {
    RequestUtils.setRequestParameterToAttribute(request);
    String x_query = request.getParameter("x_query");
    if (StringUtils.equals(x_query, "true")) {
        Map<String, Object> paramMap = RequestUtils.getParameterMap(request);
        String x_complex_query = JsonUtils.encode(paramMap);
        x_complex_query = RequestUtils.encodeString(x_complex_query);
        request.setAttribute("x_complex_query", x_complex_query);
    } else {//from  www . j a  v  a2  s  .c om
        request.setAttribute("x_complex_query", "");
    }
    String view = request.getParameter("view");
    if (StringUtils.isNotEmpty(view)) {
        return new ModelAndView(view, modelMap);
    }

    String x_view = CustomProperties.getString("mailAccount.list");
    if (StringUtils.isNotEmpty(x_view)) {
        return new ModelAndView(x_view, modelMap);
    }

    return new ModelAndView("/modules/mail/mailAccount/list", modelMap);
}