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:net.malisis.advert.advert.ServerAdvert.java

@Override
public void setInfos(String name, String url) {
    boolean newUrl = this.url != null && !StringUtils.equals(this.url, url);
    if (newUrl && file != null) {
        file.delete();// w  ww.j a  v a 2s  .c  o m
        file = null;
    }

    super.setInfos(name, url);

    if (newUrl)
        downloadFile();
}

From source file:com.glaf.core.service.impl.MxSystemPropertyServiceImpl.java

public List<SystemProperty> getAllSystemProperties() {
    SystemPropertyQuery query = new SystemPropertyQuery();
    List<SystemProperty> list = this.list(query);
    List<SystemProperty> rows = new ArrayList<SystemProperty>();
    if (list != null && !list.isEmpty()) {
        for (SystemProperty p : list) {
            if (!StringUtils.equals("TOKEN", p.getId())) {
                rows.add(p);/*w w  w. jav  a  2 s  .co  m*/
            }
        }
    }
    return rows;
}

From source file:com.glaf.oa.optional.web.springmvc.OptionalController.java

@ResponseBody
@RequestMapping("/delete")
public void delete(HttpServletRequest request, ModelMap modelMap) {
    LoginContext loginContext = RequestUtils.getLoginContext(request);
    Integer optionalId = RequestUtils.getInteger(request, "optionalId");
    String optionalIds = request.getParameter("optionalIds");
    if (StringUtils.isNotEmpty(optionalIds)) {
        StringTokenizer token = new StringTokenizer(optionalIds, ",");
        while (token.hasMoreTokens()) {
            String x = token.nextToken();
            if (StringUtils.isNotEmpty(x)) {
                Optional optional = optionalService.getOptional(Integer.valueOf(x));
                /**//from   w w  w  .j  a v a2s.  c o m
                 * 
                 */
                optionalService.deleteById(Integer.valueOf(x));
                if (optional != null && (StringUtils.equals(optional.getCreateBy(), loginContext.getActorId())
                        || loginContext.isSystemAdministrator())) {
                    optionalService.save(optional);
                }
            }
        }
    } else if (optionalId != null) {
        Optional optional = optionalService.getOptional(Integer.valueOf(optionalId));
        /**
         * 
         */

        optionalService.deleteById(Integer.valueOf(optionalId));
        if (optional != null && (StringUtils.equals(optional.getCreateBy(), loginContext.getActorId())
                || loginContext.isSystemAdministrator())) {
            optionalService.save(optional);
        }
    }
}

From source file:com.inkubator.hrm.web.workingtime.LeaveImplementationApprovalFormController.java

@PostConstruct
@Override/*w w w . j a  va2  s. c om*/
public void initialization() {
    try {
        super.initialization();
        String id = FacesUtil.getRequestParameter("execution");
        selectedApprovalActivity = approvalActivityService.getEntiyByPK(Long.parseLong(id.substring(1)));
        isWaitingApproval = selectedApprovalActivity
                .getApprovalStatus() == HRMConstant.APPROVAL_STATUS_WAITING_APPROVAL;
        isApprover = StringUtils.equals(UserInfoUtil.getUserName(), selectedApprovalActivity.getApprovedBy());
        isRequester = StringUtils.equals(UserInfoUtil.getUserName(), selectedApprovalActivity.getRequestBy());

        Gson gson = JsonUtil.getHibernateEntityGsonBuilder().create();
        JsonObject jsonObject = gson.fromJson(selectedApprovalActivity.getPendingData(), JsonObject.class);
        isCancellationProcess = jsonObject.get("isCancellationProcess") != null;
        if (isCancellationProcess) {
            List<LeaveImplementationDate> cancellationDates = gson.fromJson(jsonObject.get("cancellationDates"),
                    new TypeToken<List<LeaveImplementationDate>>() {
                    }.getType());
            List<LeaveImplementationDate> actualDates = gson.fromJson(jsonObject.get("actualDates"),
                    new TypeToken<List<LeaveImplementationDate>>() {
                    }.getType());
            //sort by actual date
            cancellationDates = Lambda.sort(cancellationDates,
                    Lambda.on(LeaveImplementationDate.class).getActualDate());
            actualDates = Lambda.sort(actualDates, Lambda.on(LeaveImplementationDate.class).getActualDate());

            leaveDatesDualModel = new DualListModel<LeaveImplementationDate>(actualDates, cancellationDates);
            cancellationDescription = jsonObject.get("cancellationDescription").getAsString();
        }
        selectedLeaveImplementation = gson.fromJson(selectedApprovalActivity.getPendingData(),
                LeaveImplementation.class);
        EmpData empData = empDataService.getByIdWithDetail(selectedLeaveImplementation.getEmpData().getId());
        selectedLeaveImplementation.setEmpData(empData);

        if (selectedLeaveImplementation.getTemporaryActing() != null) {
            EmpData temporaryActing = empDataService
                    .getByIdWithDetail(selectedLeaveImplementation.getTemporaryActing().getId());
            selectedLeaveImplementation.setTemporaryActing(temporaryActing);
        }
    } catch (Exception ex) {
        LOGGER.error("Error", ex);

    }
}

From source file:com.jaeksoft.searchlib.util.map.TargetField.java

@Override
final public boolean equals(Object o) {
    if (o == null)
        return false;
    if (!(o instanceof TargetField))
        return false;
    TargetField tf = (TargetField) o;/*from  www .j  a v  a2 s  .c om*/
    return StringUtils.equals(tf.name, this.name);
}

From source file:io.wcm.wcm.commons.util.Template.java

/**
 * Lookup a template by the given template path.
 * @param templatePath Path of template/*ww  w .j  a  v  a 2s  . c om*/
 * @return The {@link TemplatePathInfo} instance or null for unknown template paths
 */
public static TemplatePathInfo forTemplatePath(String templatePath, TemplatePathInfo... templates) {
    if (templatePath == null || templates == null || templates.length == 0) {
        return null;
    }
    for (TemplatePathInfo template : templates) {
        if (StringUtils.equals(template.getTemplatePath(), templatePath)) {
            return template;
        }
    }
    return null;
}

From source file:ch.cyberduck.core.b2.B2FileidProvider.java

@Override
public String getFileid(final Path file, final ListProgressListener listener) throws BackgroundException {
    if (StringUtils.isNotBlank(file.attributes().getVersionId())) {
        return file.attributes().getVersionId();
    }/*  www  .j  a  va2s .co  m*/
    if (containerService.isContainer(file)) {
        final AttributedList<Path> list;
        if (!cache.isCached(file.getParent())) {
            list = new B2ListService(session, this).list(file.getParent(), new DisabledListProgressListener());
            cache.put(file.getParent(), list);
        } else {
            list = cache.get(file.getParent());
        }
        final Path found = list.filter(new NullFilter<>()).find(new SimplePathPredicate(file));
        if (null == found) {
            throw new NotfoundException(file.getAbsolute());
        }
        return found.attributes().getVersionId();
    }
    try {
        final B2ListFilesResponse response = session.getClient().listFileNames(
                this.getFileid(containerService.getContainer(file), listener), containerService.getKey(file),
                2);
        for (B2FileInfoResponse info : response.getFiles()) {
            if (StringUtils.equals(containerService.getKey(file), info.getFileName())) {
                return info.getFileId();
            }
        }
        throw new NotfoundException(file.getAbsolute());
    } catch (B2ApiException e) {
        throw new B2ExceptionMappingService().map(e);
    } catch (IOException e) {
        throw new DefaultIOExceptionMappingService().map(e);
    }
}

From source file:ch.cyberduck.core.sds.SDSMoveFeature.java

@Override
public Path move(final Path file, final Path renamed, final TransferStatus status,
        final Delete.Callback callback, final ConnectionCallback connectionCallback)
        throws BackgroundException {
    try {//from w  w  w.  j  av  a 2s.com
        if (status.isExists()) {
            new SDSDeleteFeature(session).delete(Collections.singletonList(renamed), connectionCallback,
                    callback);
        }
        if (!new SimplePathPredicate(file.getParent()).test(renamed.getParent())) {
            // Change parent node
            new NodesApi(session.getClient()).moveNodes(StringUtils.EMPTY,
                    Long.parseLong(new SDSNodeIdProvider(session).getFileid(renamed.getParent(),
                            new DisabledListProgressListener())),
                    new MoveNodesRequest().resolutionStrategy(MoveNodesRequest.ResolutionStrategyEnum.OVERWRITE)
                            .addNodeIdsItem(Long.parseLong(new SDSNodeIdProvider(session).getFileid(file,
                                    new DisabledListProgressListener()))),
                    null);
        }
        if (!StringUtils.equals(file.getName(), renamed.getName())) {
            if (containerService.isContainer(file)) {
                new NodesApi(session.getClient()).updateRoom(StringUtils.EMPTY,
                        Long.parseLong(new SDSNodeIdProvider(session).getFileid(file,
                                new DisabledListProgressListener())),
                        new UpdateRoomRequest().name(renamed.getName()), null);
            }
            // Rename
            else if (file.isDirectory()) {
                new NodesApi(session.getClient()).updateFolder(StringUtils.EMPTY,
                        Long.parseLong(new SDSNodeIdProvider(session).getFileid(
                                new Path(renamed.getParent(), file.getName(), file.getType()),
                                new DisabledListProgressListener())),
                        new UpdateFolderRequest().name(renamed.getName()), null);
            } else {
                new NodesApi(session.getClient()).updateFile(StringUtils.EMPTY,
                        Long.parseLong(new SDSNodeIdProvider(session).getFileid(
                                new Path(renamed.getParent(), file.getName(), file.getType()),
                                new DisabledListProgressListener())),
                        new UpdateFileRequest().name(renamed.getName()), null);
            }
        }
        return new Path(renamed.getParent(), renamed.getName(), renamed.getType(),
                new PathAttributes(renamed.attributes()).withVersionId(file.attributes().getVersionId()));
    } catch (ApiException e) {
        throw new SDSExceptionMappingService().map("Cannot rename {0}", e, file);
    }
}

From source file:com.spartasystems.holdmail.domain.HeaderValue.java

public boolean hasValue(String value) {
    return value != null && StringUtils.equals(this.value, value);
}

From source file:com.dipesan.miniatm.miniatm.services.RiskManagementTask.java

private void end(byte[] tvr) {
    this.tvr = tvr;

    EMVApplicationDescriptor selectedApplication = paymentContext.getSelectedApplication();
    if (selectedApplication != null) {
        String selectedAID = Tools.bytesToHex(selectedApplication.getAid()).substring(0, 10);

        if (StringUtils.equals("A000000003", selectedAID)) {
            paymentContext.setApplicationVersion(140);

        } else if (StringUtils.equals("A000000004", selectedAID)) {
            paymentContext.setApplicationVersion(202);

        } else if (StringUtils.equals("A000000042", selectedAID)) {
            paymentContext.setApplicationVersion(203);

        }/*from   w  ww.  j a  v a  2s. c o m*/
    }

    new Thread(new Runnable() {
        @Override
        public void run() {
            monitor.handleEvent(TaskEvent.SUCCESS);
        }
    }).start();
}