Example usage for java.util Set equals

List of usage examples for java.util Set equals

Introduction

In this page you can find the example usage for java.util Set equals.

Prototype

boolean equals(Object o);

Source Link

Document

Compares the specified object with this set for equality.

Usage

From source file:de.tudarmstadt.ukp.dkpro.wsd.candidates.SenseClusterer.java

/**
 * Given a set of sense IDs, determine whether they are all in the same
 * cluster./*from   w w w . ja va 2s .com*/
 *
 * @return true if all sense IDs are in the same cluster
 */
public boolean inSameCluster(Set<String> senses) {
    if (senses.size() <= 1) {
        return true;
    }
    Set<String> cluster = null;
    for (String sense : senses) {
        if (cluster == null) {
            cluster = clusterMap.get(sense);
            continue;
        }
        if (!cluster.equals(clusterMap.get(sense))) {
            return false;
        }
    }
    return true;
}

From source file:org.kontalk.model.KonThread.java

public void setUser(Set<User> user) {
    if (user.equals(mUserMap.keySet()))
        return;//from   w ww.  j av  a2 s.  c om

    this.setUserMap(user);
    this.changed(user);
}

From source file:edu.wisc.my.redirect.PortalUrlRedirectController.java

@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    final String serverName = request.getServerName();
    final PortalUrl portalUrl = this.portalUrlProvider.getPortalUrl(serverName);

    if (this.portletFunctionalName != null) {
        portalUrl.setTargetPortlet(this.portletFunctionalName);
    }//from w  w  w .j  a v  a 2  s .  co m

    if (this.tabIndex != null) {
        portalUrl.setTabIndex(this.tabIndex);
    }

    //If strict param matching only run if the request parameter keyset matches the mapped parameter keyset
    final Set<?> requestParameterKeys = request.getParameterMap().keySet();
    if (this.strictParameterMatching && !requestParameterKeys.equals(this.parameterMappings.keySet())) {
        if (this.logger.isInfoEnabled()) {
            this.logger.info("Sending not found error, requested parameter key set " + requestParameterKeys
                    + " does not match mapped parameter key set " + this.parameterMappings.keySet());
        }

        response.sendError(HttpServletResponse.SC_NOT_FOUND);
        return null;
    }

    //Map static parameters
    logger.debug("Mapping " + staticParameters.size() + " static parameters");
    for (final Map.Entry<String, List<String>> parameterMappingEntry : this.staticParameters.entrySet()) {
        final String name = parameterMappingEntry.getKey();
        final List<String> values = parameterMappingEntry.getValue();

        if (this.logger.isDebugEnabled()) {
            this.logger.debug("Adding static parameter '" + name + "' with values: " + values);
        }

        portalUrl.setParameter(name, values.toArray(new String[values.size()]));
    }

    //Map request parameters
    logger.debug("Mapping " + parameterMappings.entrySet().size() + " request parameters");
    for (final Map.Entry<String, Set<String>> parameterMappingEntry : this.parameterMappings.entrySet()) {
        final String name = parameterMappingEntry.getKey();
        logger.debug("Mapping parameter " + name);
        final String[] values = request.getParameterValues(name);

        if (values != null) {
            for (final String mappedName : parameterMappingEntry.getValue()) {
                if (this.logger.isDebugEnabled()) {
                    this.logger.debug("Mapping parameter '" + name + "' to portal parameter '" + mappedName
                            + "' with values: " + Arrays.asList(values));
                }

                portalUrl.setParameter(mappedName, values);
            }

            //Add any conditional parameters for the URL parameter
            final Map<String, List<String>> conditionalParameters = this.conditionalParameterMappings.get(name);
            if (conditionalParameters != null) {
                for (final Map.Entry<String, List<String>> conditionalParameterEntry : conditionalParameters
                        .entrySet()) {
                    final String condName = conditionalParameterEntry.getKey();
                    final List<String> condValues = conditionalParameterEntry.getValue();

                    if (this.logger.isDebugEnabled()) {
                        this.logger.debug(
                                "Adding conditional parameter '" + condName + "' with values: " + condValues);
                    }

                    portalUrl.setParameter(condName, condValues.toArray(new String[condValues.size()]));
                }
            }
        } else if (this.logger.isDebugEnabled()) {
            this.logger.debug(
                    "Skipping mapped parameter '" + name + "' since it was not specified on the original URL");
        }
    }

    //Set public based on if remoteUser is set
    final String remoteUser = request.getRemoteUser();
    final boolean isAuthenticated = StringUtils.isNotBlank(remoteUser);
    portalUrl.setPublic(!isAuthenticated);

    if (this.windowState != null) {
        portalUrl.setWindowState(this.windowState);
    }

    if (this.portletMode != null) {
        portalUrl.setWindowState(this.portletMode);
    }

    portalUrl.setType(RequestType.ACTION);

    final String redirectUrl = portalUrl.toString();
    if (this.logger.isInfoEnabled()) {
        this.logger.info("Redirecting to: " + redirectUrl);
    }

    return new ModelAndView(new RedirectView(redirectUrl, false));
}

From source file:com.edmunds.etm.rules.impl.UrlTokenMonitor.java

private void processTokenDtos(Set<UrlTokenDto> dtos) {

    // load default tokens at startup if none are defined
    if (!tokensInitialized && dtos.isEmpty()) {
        loadDefaultTokens();/*from ww w.  java  2s. c  om*/
        return;
    }

    // don't proceed if tokens are unchanged
    if (tokensInitialized && dtos.equals(previousTokenDtos)) {
        return;
    }
    previousTokenDtos = dtos;

    // update the token dictionary and notify listeners
    List<UrlToken> tokens = Lists.newArrayListWithCapacity(dtos.size());
    for (UrlTokenDto dto : dtos) {
        UrlToken token = UrlToken.readDto(dto);
        tokens.add(token);
    }
    tokenDictionary.clear();
    tokenDictionary.addAll(tokens);

    processChangeEvent();
    tokensInitialized = true;
}

From source file:uniol.apt.analysis.synthesize.separation.KBoundedSeparation.java

/**
 * Construct a new instance for solving separation problems.
 * @param utility The region utility to use.
 * @param properties Properties that the calculated region should satisfy.
 * @param locationMap Mapping that describes the location of each event.
 * @throws UnsupportedPNPropertiesException If the requested properties are not supported.
 *//*  www  .  j ava 2 s. co m*/
public KBoundedSeparation(RegionUtility utility, PNProperties properties, String[] locationMap)
        throws UnsupportedPNPropertiesException {
    this.utility = utility;
    this.pure = properties.isPure();

    // Are we the right Separation implementation for the task?
    if (!properties.isKBounded())
        throw new UnsupportedPNPropertiesException();

    PNProperties supported = new PNProperties().requireKBounded(properties.getKForKBounded()).setPure(true);
    if (!supported.containsAll(properties))
        throw new UnsupportedPNPropertiesException();

    // We do not support locations, so no locations may be specified
    if (Collections.frequency(Arrays.asList(locationMap), null) != locationMap.length)
        throw new UnsupportedPNPropertiesException();

    // Check our preconditions
    TransitionSystem ts = utility.getTransitionSystem();
    if (!new TotallyReachable(ts).isTotallyReachable())
        throw new UnsupportedPNPropertiesException();
    Set<Event> events = new HashSet<>();
    for (Arc arc : ts.getEdges())
        events.add(arc.getEvent());
    if (!events.equals(ts.getAlphabetEvents()))
        throw new UnsupportedPNPropertiesException();

    // Ok, we can do it. Now do it.
    if (properties.getKForKBounded() == 0)
        // There are no 0-bounded regions that solve any kind of separation problem.
        // (Except if the alphabet has events that do not occur on any arc, which is not supported)
        return;
    generateAllRegions(properties.getKForKBounded());
}

From source file:br.usp.poli.lta.cereda.nfa2dfa.utils.Conversion.java

public Triple<Integer, Set<Integer>, List<SimpleTransition>> convert() {

    List<ETransition> T = new ArrayList<>();
    Set<Integer> q0 = eclosure(initial);
    Set<Set<Integer>> Q = new HashSet<>();
    Set<Set<Integer>> F;
    Q.add(q0);/*from  w  w  w .j  a va  2 s  .  c  om*/

    List<Set<Integer>> worklist = new ArrayList<>();
    Set<Integer> q;
    Set<Integer> t;

    worklist.add(q0);

    Set<Token> sigma = alphabet();

    while (!worklist.isEmpty()) {
        q = worklist.remove(0);

        for (Token c : sigma) {
            t = eclosure(delta(q, c));
            if (!t.isEmpty()) {
                T.add(new ETransition(q, c, t));
                if (!Q.contains(t)) {
                    Q.add(t);
                    worklist.add(t);
                }
            }
        }
    }

    F = acceptingStates(Q);

    Map<Set<Integer>, Integer> names = new HashMap<>();
    int counter = 0;

    names.put(q0, counter);
    for (Set<Integer> e : Q) {
        if (!e.equals(q0)) {
            counter++;
            names.put(e, counter);
        }
    }

    List<SimpleTransition> converted = new ArrayList<>();
    for (ETransition etransition : T) {
        SimpleTransition transition = new SimpleTransition(names.get(etransition.getSource()),
                etransition.getSymbol(), names.get(etransition.getTarget()));
        converted.add(transition);
    }

    Triple<Integer, Set<Integer>, List<SimpleTransition>> result = new Triple<>();
    result.setFirst(names.get(q0));
    result.setThird(converted);

    Set<Integer> FF = new HashSet<>();
    for (Set<Integer> f : F) {
        FF.add(names.get(f));
    }
    result.setSecond(FF);

    return result;

}

From source file:org.mifosplatform.organisation.holiday.domain.Holiday.java

public boolean update(final Set<Office> newOffices) {
    if (newOffices == null) {
        return false;
    }/*w w w .java 2s  . c  om*/

    boolean updated = false;
    if (this.offices != null) {
        final Set<Office> currentSetOfOffices = new HashSet<Office>(this.offices);
        final Set<Office> newSetOfOffices = new HashSet<Office>(newOffices);

        if (!(currentSetOfOffices.equals(newSetOfOffices))) {
            updated = true;
            this.offices = newOffices;
        }
    } else {
        updated = true;
        this.offices = newOffices;
    }
    return updated;
}

From source file:com.gst.organisation.holiday.domain.Holiday.java

public boolean update(final Set<Office> newOffices) {
    if (newOffices == null) {
        return false;
    }//from   w ww .  j av a  2  s. co m

    boolean updated = false;
    if (this.offices != null) {
        final Set<Office> currentSetOfOffices = new HashSet<>(this.offices);
        final Set<Office> newSetOfOffices = new HashSet<>(newOffices);

        if (!(currentSetOfOffices.equals(newSetOfOffices))) {
            updated = true;
            this.offices = newOffices;
        }
    } else {
        updated = true;
        this.offices = newOffices;
    }
    return updated;
}

From source file:org.batoo.jpa.core.jdbc.adapter.JdbcTable.java

/**
 * Returns if primary key drop is required.
 * //from w ww  .  j  a v a 2 s.  c  om
 * @param pkColumnNames
 *            the set of required primary keys
 * @return true if primary key drop is required, false otherwise
 * 
 * @since $version
 * @author hceylan
 */
public boolean requiresPkDrop(Set<String> pkColumnNames) {
    if (this.pkColumns.isEmpty()) {
        return false;
    }

    final Set<String> pkColumnNames2 = Sets.newHashSet();
    for (final String columnName : pkColumnNames) {
        pkColumnNames2.add(columnName.toUpperCase());
    }

    return !pkColumnNames2.equals(this.pkColumns);
}

From source file:org.alfresco.repo.domain.audit.AbstractAuditDAOImpl.java

@SuppressWarnings("unchecked")
public void updateAuditApplicationDisabledPaths(Long id, Set<String> disabledPaths) {
    AuditApplicationEntity entity = getAuditApplicationById(id);
    if (entity == null) {
        throw new DataIntegrityViolationException("No audit application exists for ID " + id);
    }//from w  w w.  java 2s.c o  m
    // Resolve the current set
    Long disabledPathsId = entity.getDisabledPathsId();
    Set<String> oldDisabledPaths = (Set<String>) propertyValueDAO.getPropertyById(disabledPathsId);
    if (oldDisabledPaths.equals(disabledPaths)) {
        // Nothing changed
        return;
    }
    // Update the property
    propertyValueDAO.updateProperty(disabledPathsId, (Serializable) disabledPaths);
    // Do a precautionary update to ensure that the application row is locked appropriately
    updateAuditApplication(entity);
}