Example usage for java.util.function Predicate isEqual

List of usage examples for java.util.function Predicate isEqual

Introduction

In this page you can find the example usage for java.util.function Predicate isEqual.

Prototype

static <T> Predicate<T> isEqual(Object targetRef) 

Source Link

Document

Returns a predicate that tests if two arguments are equal according to Objects#equals(Object,Object) .

Usage

From source file:Main.java

License:asdf

public static void main(String[] args) {
    Predicate<String> i = Predicate.isEqual("asdf");

    System.out.println(i.test("java2s.com "));
}

From source file:com.uber.hoodie.common.table.timeline.HoodieActiveTimeline.java

protected HoodieActiveTimeline(FileSystem fs, String metaPath, String[] includedExtensions) {
    // Filter all the filter in the metapath and include only the extensions passed and
    // convert them into HoodieInstant
    try {//from ww  w. j  av a  2  s  .c om
        this.instants = Arrays.stream(HoodieTableMetaClient.scanFiles(fs, new Path(metaPath), path -> {
            // Include only the meta files with extensions that needs to be included
            String extension = FSUtils.getFileExtension(path.getName());
            return Arrays.stream(includedExtensions).anyMatch(Predicate.isEqual(extension));
        })).sorted(Comparator.comparing(
                // Sort the meta-data by the instant time (first part of the file name)
                fileStatus -> FSUtils.getInstantTime(fileStatus.getPath().getName())))
                // create HoodieInstantMarkers from FileStatus, which extracts properties
                .map(HoodieInstant::new).collect(Collectors.toList());
        log.info("Loaded instants " + instants);
    } catch (IOException e) {
        throw new HoodieIOException("Failed to scan metadata", e);
    }
    this.fs = fs;
    this.metaPath = metaPath;
    // multiple casts will make this lambda serializable - http://docs.oracle.com/javase/specs/jls/se8/html/jls-15.html#jls-15.16
    this.details = (Function<HoodieInstant, Optional<byte[]>> & Serializable) this::getInstantDetails;
}

From source file:org.apache.lens.cube.metadata.CubeFactTable.java

public boolean hasColumn(String column) {
    Set<String> validColumns = getValidColumns();
    if (validColumns != null) {
        return validColumns.contains(column);
    } else {//from www  . ja  v  a2s . co  m
        return getColumns().stream().map(FieldSchema::getName).anyMatch(Predicate.isEqual(column));
    }
}

From source file:org.fenixedu.academic.ui.struts.action.academicAdministration.executionCourseManagement.CreateExecutionCoursesDispatchAction.java

public ActionForward chooseDegreeCurricularPlans(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response) throws FenixServiceException {

    try {/*  ww  w . j  a v  a  2  s.c  om*/

        DynaActionForm actionForm = (DynaActionForm) form;
        String degreeType = (String) actionForm.get("degreeType");

        if (StringUtils.isEmpty(degreeType)) {
            degreeType = request.getParameter("degreeType");
        }

        if (StringUtils.isEmpty(degreeType)) {
            throw new DomainException("error.selection.noDegreeType");
        }

        Collection<InfoDegreeCurricularPlan> degreeCurricularPlans = ReadActiveDegreeCurricularPlansByDegreeType
                .runForAcademicAdmin(Predicate.isEqual(FenixFramework.getDomainObject(degreeType)));
        List<InfoExecutionPeriod> executionPeriods = ReadNotClosedExecutionPeriods.run();

        request.setAttribute("degreeCurricularPlans", degreeCurricularPlans);
        request.setAttribute("executionPeriods", executionPeriods);
        request.setAttribute("degreeType", degreeType);
    } catch (DomainException e) {
        addActionMessage("error", request, e.getMessage());
        return chooseDegreeType(mapping, form, request, response);
    }

    return mapping.findForward("chooseDegreeCurricularPlans");

}

From source file:org.apache.lens.cube.parse.CubeQueryContext.java

boolean isColumnAnAlias(String col) {
    return selectPhrases.stream().map(SelectPhraseContext::getActualAlias).anyMatch(Predicate.isEqual(col));
}

From source file:org.fenixedu.academic.domain.Alumni.java

public static List<Registration> readAlumniRegistrations(AlumniSearchBean bean) {

    if (StringUtils.isEmpty(bean.getName())) {
        return new ArrayList<Registration>();
    }//from  w w  w  .  j a v  a 2s .  c o m

    ExecutionYear firstYear = bean.getFirstExecutionYear() == null ? ExecutionYear.readFirstExecutionYear()
            : bean.getFirstExecutionYear();
    ExecutionYear finalYear = bean.getFinalExecutionYear() == null ? ExecutionYear.readLastExecutionYear()
            : bean.getFinalExecutionYear();

    List<Registration> resultRegistrations = new ArrayList<Registration>();
    for (Person person : Person.readPersonsByNameAndRoleType(bean.getName(), RoleType.ALUMNI)) {
        if (person.getStudent() != null) {

            if (bean.getStudentNumber() == null
                    || person.getStudent().getNumber().equals(bean.getStudentNumber())) {
                for (Registration registration : (bean.getDegreeType() == null
                        ? person.getStudent().getRegistrationsSet()
                        : person.getStudent()
                                .getRegistrationsMatchingDegreeType(Predicate.isEqual(bean.getDegreeType())))) {

                    if (registration.isConcluded()) {
                        if (bean.getDegree() != null) {
                            if (registration.hasStartedBetween(firstYear, finalYear)
                                    && registration.getDegree().equals(bean.getDegree())) {
                                resultRegistrations.add(registration);
                            }
                        } else {

                            if (registration.hasStartedBetween(firstYear, finalYear)) {
                                resultRegistrations.add(registration);
                            }
                        }
                    }
                }
            }
        }
    }

    return resultRegistrations;
}

From source file:com.github.larsq.spring.embeddedamqp.SimpleAmqpMessageContainer.java

/**
 * Return exchange given its name//from   w  w  w  .  j  av  a  2  s  .c  om
 *
 * @param name the exchange name
 * @return the first instance that matches the name. It is assumed that the
 * exchange should be unique on its name
 */
Optional<ExchangeWrapper> exchange(String name) {
    return exchanges.stream().filter(Predicates.compose(Predicate.isEqual(name), ExchangeWrapper::name))
            .findFirst();
}

From source file:com.github.larsq.spring.embeddedamqp.SimpleAmqpMessageContainer.java

Optional<Queue> queue(String name) {
    return consumers.keySet().stream().filter(Predicates.compose(Predicate.isEqual(name), Queue::getName))
            .findFirst();
}

From source file:io.fabric8.kubernetes.api.Controller.java

public boolean checkNamespace(String namespaceName) {
    if (Strings.isNullOrBlank(namespaceName)) {
        return false;
    }//ww w .  ja  va2  s.c  o  m
    OpenShiftClient openshiftClient = getOpenShiftClientOrNull();
    if (openshiftClient != null && openshiftClient.supportsOpenShiftAPIGroup(OpenShiftAPIGroups.PROJECT)) {
        // It is preferable to iterate on the list of projects as regular user with the 'basic-role' bound
        // are not granted permission get operation on non-existing project resource that returns 403
        // instead of 404. Only more privileged roles like 'view' or 'cluster-reader' are granted this permission.
        return openshiftClient.projects().list().getItems().stream()
                .map(project -> project.getMetadata().getName()).anyMatch(Predicate.isEqual(namespaceName));
    } else {
        return kubernetesClient.namespaces().withName(namespaceName).get() != null;
    }
}