Example usage for org.apache.commons.httpclient.util LangUtils equals

List of usage examples for org.apache.commons.httpclient.util LangUtils equals

Introduction

In this page you can find the example usage for org.apache.commons.httpclient.util LangUtils equals.

Prototype

public static boolean equals(final Object obj1, final Object obj2) 

Source Link

Usage

From source file:com.eviware.soapui.impl.wsdl.support.http.SoapUIHostConfiguration.java

public synchronized boolean equals(final Object o) {

    boolean result = super.equals(o);
    if (result && o instanceof SoapUIHostConfiguration) {
        SoapUIHostConfiguration that = (SoapUIHostConfiguration) o;
        return LangUtils.equals(getParams().getParameter(SOAPUI_SSL_CONFIG),
                that.getParams().getParameter(SOAPUI_SSL_CONFIG));
    } else {/*  w ww  .j  a va2  s . co  m*/
        return false;
    }
}

From source file:com.gargoylesoftware.htmlunit.util.NameValuePair.java

/**
 * {@inheritDoc}//from   w w w.j a v  a 2s .  co  m
 */
@Override
public boolean equals(final Object object) {
    if (!(object instanceof NameValuePair)) {
        return false;
    }
    final NameValuePair other = (NameValuePair) object;
    return LangUtils.equals(name_, other.name_) && LangUtils.equals(value_, other.value_);
}

From source file:com.cerema.cloud2.lib.common.network.BearerCredentials.java

/**
 * These credentials are assumed equal if accessToken is the same.
 *
 * @param   o   The other object to compare with.
 *
 * @return      'True' if the object is equivalent.
 *//*from ww  w  .  j a v a2 s  .c  o  m*/
public boolean equals(Object o) {
    if (o == null)
        return false;
    if (this == o)
        return true;
    if (this.getClass().equals(o.getClass())) {
        BearerCredentials that = (BearerCredentials) o;
        if (LangUtils.equals(mAccessToken, that.mAccessToken)) {
            return true;
        }
    }
    return false;
}

From source file:org.geoserver.gwc.layer.CatalogLayerEventListener.java

/**
 * Handles changes of interest to GWC on a {@link LayerInfo}.
 * <ul>//from  w  w  w. j  a  v a  2 s. c  o m
 * <li>If the name of the default style changed, then the layer's cache for the default style is
 * truncated. This method doesn't check if the contents of the styles are equal. That is handled
 * by {@link CatalogStyleChangeListener} whenever a style is modified.
 * <li>If the tile layer is {@link GeoServerTileLayerInfo#isAutoCacheStyles() auto caching
 * styles} and the layerinfo's "styles" list changed, the tile layer's STYLE parameter filter is
 * updated to match the actual list of layer styles and any removed style is truncated.
 * </ul>
 * 
 * @param changedProperties
 * @param oldValues
 * @param newValues
 * @param li
 * @param tileLayerInfo
 */
private void handleLayerInfoChange(final List<String> changedProperties, final List<Object> oldValues,
        final List<Object> newValues, final LayerInfo li, final GeoServerTileLayerInfo tileLayerInfo) {
    checkNotNull(tileLayerInfo);

    final String layerName = tileLayerName(li);

    boolean save = false;
    boolean defaultStyleChanged = false;

    final String defaultStyle;

    /*
     * If default style name changed
     */
    if (changedProperties.contains("defaultStyle")) {
        final int propIndex = changedProperties.indexOf("defaultStyle");
        final StyleInfo oldStyle = (StyleInfo) oldValues.get(propIndex);
        final StyleInfo newStyle = (StyleInfo) newValues.get(propIndex);

        final String oldStyleName = oldStyle.getName();
        defaultStyle = newStyle.getName();
        if (!Objects.equal(oldStyleName, defaultStyle)) {
            save = true;
            defaultStyleChanged = true;
            log.info("Truncating default style for layer " + layerName + ", as it changed from " + oldStyleName
                    + " to " + defaultStyle);
            mediator.truncateByLayerAndStyle(layerName, oldStyleName);
        }
    } else {
        StyleInfo styleInfo = li.getDefaultStyle();
        defaultStyle = styleInfo == null ? null : styleInfo.getName();
    }

    if (tileLayerInfo.isAutoCacheStyles()) {
        Set<String> styles = new HashSet<String>();
        for (StyleInfo s : li.getStyles()) {
            styles.add(s.getName());
        }
        ImmutableSet<String> cachedStyles = tileLayerInfo.cachedStyles();
        if (!styles.equals(cachedStyles)) {
            // truncate no longer existing cached styles
            Set<String> notCachedAnyMore = Sets.difference(cachedStyles, styles);
            for (String oldCachedStyle : notCachedAnyMore) {
                log.info("Truncating cached style " + oldCachedStyle + " of layer " + layerName
                        + " as it's no longer one of the layer's styles");
                mediator.truncateByLayerAndStyle(layerName, oldCachedStyle);
            }
            // reset STYLES parameter filter
            final boolean createParamIfNotExists = true;
            TileLayerInfoUtil.updateStringParameterFilter(tileLayerInfo, "STYLES", createParamIfNotExists,
                    defaultStyle, styles);
            save = true;
        }
    }

    // check the caching settings, have they changed?
    boolean cachingInfoChanged = false;
    int metadataIdx = changedProperties.indexOf("metadata");
    if (metadataIdx >= 0) {
        MetadataMap oldMetadata = (MetadataMap) oldValues.get(metadataIdx);
        MetadataMap newMetadata = (MetadataMap) newValues.get(metadataIdx);
        boolean cachingEnabledChanged = LangUtils.equals(
                oldMetadata.get(ResourceInfo.CACHING_ENABLED, Boolean.class),
                newMetadata.get(ResourceInfo.CACHING_ENABLED, Boolean.class));
        boolean cachingMaxAgeChanged = LangUtils.equals(
                oldMetadata.get(ResourceInfo.CACHE_AGE_MAX, Boolean.class),
                newMetadata.get(ResourceInfo.CACHE_AGE_MAX, Boolean.class));
        // we do we don't need to truncate the layer, but we need to update
        // its LayerInfo so that the resulting caching headers get updated
        if (cachingEnabledChanged || cachingMaxAgeChanged) {
            cachingInfoChanged = true;
            save = true;
        }
    }

    if (save) {
        GridSetBroker gridSetBroker = mediator.getGridSetBroker();
        GeoServerTileLayer tileLayer = new GeoServerTileLayer(li, gridSetBroker, tileLayerInfo);
        mediator.save(tileLayer);
    }
    // caching info and default style changes affect also the layer groups containing the layer 
    if (cachingInfoChanged || defaultStyleChanged) {
        List<LayerGroupInfo> groups = catalog.getLayerGroups();
        for (LayerGroupInfo lg : groups) {
            GeoServerTileLayer tileLayer = mediator.getTileLayer(lg);
            if (tileLayer != null) {
                LayerGroupHelper helper = new LayerGroupHelper(lg);
                int idx = helper.allLayers().indexOf(li);
                if (idx >= 0) {
                    // we need to save in case something changed in one of the layer
                    GridSetBroker gridSetBroker = mediator.getGridSetBroker();
                    GeoServerTileLayerInfo groupTileLayerInfo = tileLayer.getInfo();
                    GeoServerTileLayer newTileLayer = new GeoServerTileLayer(lg, gridSetBroker,
                            groupTileLayerInfo);
                    mediator.save(newTileLayer);

                    // we also need to truncate the group if the layer default style changed,
                    // and the layer group was using 
                    if (defaultStyleChanged && lg.getStyles().get(idx) == null) {
                        mediator.truncate(groupTileLayerInfo.getName());
                    }
                }
            }
        }

    }
}