当前位置: 首页>>代码示例>>Java>>正文


Java Objects.equal方法代码示例

本文整理汇总了Java中libcore.util.Objects.equal方法的典型用法代码示例。如果您正苦于以下问题:Java Objects.equal方法的具体用法?Java Objects.equal怎么用?Java Objects.equal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在libcore.util.Objects的用法示例。


在下文中一共展示了Objects.equal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: equals

import libcore.util.Objects; //导入方法依赖的package包/类
/**
 * Returns true if two chains of PropertyChangeListenerProxies have the same
 * names in the same order and bottom out in the same event listener. This
 * method's signature is asymmetric to avoid allocating a proxy: if
 * non-null, {@code aName} represents the first property name and {@code a}
 * is its listener.
 */
private boolean equals(String aName, EventListener a, EventListener b) {
    /*
     * Each iteration of the loop attempts to match a pair of property names
     * from a and b. If they don't match, the chains must not be equal!
     */
    while (b instanceof PropertyChangeListenerProxy) {
        PropertyChangeListenerProxy bProxy = (PropertyChangeListenerProxy) b; // unwrap b
        String bName = bProxy.getPropertyName();
        b = bProxy.getListener();
        if (aName == null) {
            if (!(a instanceof PropertyChangeListenerProxy)) {
                return false;
            }
            PropertyChangeListenerProxy aProxy = (PropertyChangeListenerProxy) a; // unwrap a
            aName = aProxy.getPropertyName();
            a = aProxy.getListener();
        }
        if (!Objects.equal(aName, bName)) {
            return false; // not equal; a and b subscribe to different properties
        }
        aName = null;
    }
    return aName == null && Objects.equal(a, b);
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:32,代码来源:PropertyChangeSupport.java

示例2: firePropertyChange

import libcore.util.Objects; //导入方法依赖的package包/类
/**
 * Publishes a property change event to all listeners of that property. If
 * the event's old and new values are equal (but non-null), no event will be
 * published.
 */
public void firePropertyChange(PropertyChangeEvent event) {
    String propertyName = event.getPropertyName();
    Object oldValue = event.getOldValue();
    Object newValue = event.getNewValue();
    if (newValue != null && oldValue != null && newValue.equals(oldValue)) {
        return;
    }

    notifyEachListener:
    for (PropertyChangeListener p : listeners) {
        // unwrap listener proxies until we get a mismatched name or the real listener
        while (p instanceof PropertyChangeListenerProxy) {
            PropertyChangeListenerProxy proxy = (PropertyChangeListenerProxy) p;
            if (!Objects.equal(proxy.getPropertyName(), propertyName)) {
                continue notifyEachListener;
            }
            p = (PropertyChangeListener) proxy.getListener();
        }
        p.propertyChange(event);
    }
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:27,代码来源:PropertyChangeSupport.java

示例3: readResolve

import libcore.util.Objects; //导入方法依赖的package包/类
/**
 * Serialization helper method to maintain singletons and add any new
 * levels.
 *
 * @return the resolved instance.
 */
private Object readResolve() {
    synchronized (levels) {
        for (Level level : levels) {
            if (value != level.value) {
                continue;
            }
            if (!name.equals(level.name)) {
                continue;
            }
            if (Objects.equal(resourceBundleName, level.resourceBundleName)) {
                return level;
            }
        }
        // This is a new value, so add it.
        levels.add(this);
        return this;
    }
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:25,代码来源:Level.java

示例4: equals

import libcore.util.Objects; //导入方法依赖的package包/类
@Override public boolean equals(Object other) {
    if (other instanceof CopyOnWriteArrayList) {
        return this == other
                || Arrays.equals(elements, ((CopyOnWriteArrayList<?>) other).elements);
    } else if (other instanceof List) {
        Object[] snapshot = elements;
        Iterator<?> i = ((List<?>) other).iterator();
        for (Object o : snapshot) {
            if (!i.hasNext() || !Objects.equal(o, i.next())) {
                return false;
            }
        }
        return !i.hasNext();
    } else {
        return false;
    }
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:18,代码来源:CopyOnWriteArrayList.java

示例5: containsMapping

import libcore.util.Objects; //导入方法依赖的package包/类
/**
 * Returns true if this map contains the specified mapping.
 */
private boolean containsMapping(Object key, Object value) {
    if (key == null) {
        HashMapEntry<K, V> e = entryForNullKey;
        return e != null && Objects.equal(value, e.value);
    }

    int hash = Collections.secondaryHash(key);
    HashMapEntry<K, V>[] tab = table;
    int index = hash & (tab.length - 1);
    for (HashMapEntry<K, V> e = tab[index]; e != null; e = e.next) {
        if (e.hash == hash && key.equals(e.key)) {
            return Objects.equal(value, e.value);
        }
    }
    return false; // No entry for key
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:20,代码来源:HashMap.java

示例6: equals

import libcore.util.Objects; //导入方法依赖的package包/类
@Override
public final boolean equals(Object o) {
    if (!mEntryValid) {
        throw new IllegalStateException(
                "This container does not support retaining Map.Entry objects");
    }
    if (!(o instanceof Map.Entry)) {
        return false;
    }
    Map.Entry<?, ?> e = (Map.Entry<?, ?>) o;
    return Objects.equal(e.getKey(), colGetEntry(mIndex, 0))
            && Objects.equal(e.getValue(), colGetEntry(mIndex, 1));
}
 
开发者ID:Gracker,项目名称:Android-Framework-Tools-Utils,代码行数:14,代码来源:MapCollections.java

示例7: contains

import libcore.util.Objects; //导入方法依赖的package包/类
@Override
public boolean contains(Object o) {
    if (!(o instanceof Map.Entry))
        return false;
    Map.Entry<?, ?> e = (Map.Entry<?, ?>) o;
    int index = colIndexOfKey(e.getKey());
    if (index < 0) {
        return false;
    }
    Object foundVal = colGetEntry(index, 1);
    return Objects.equal(foundVal, e.getValue());
}
 
开发者ID:Gracker,项目名称:Android-Framework-Tools-Utils,代码行数:13,代码来源:MapCollections.java

示例8: equals

import libcore.util.Objects; //导入方法依赖的package包/类
/**
 * Checks the two objects for equality by delegating to their respective
 * {@link Object#equals(Object)} methods.
 *
 * @param o the {@link Pair} to which this one is to be checked for equality
 * @return true if the underlying objects of the Pair are both considered
 *         equal
 */
@Override
public boolean equals(Object o) {
    if (!(o instanceof Pair)) {
        return false;
    }
    Pair<?, ?> p = (Pair<?, ?>) o;
    return Objects.equal(p.first, first) && Objects.equal(p.second, second);
}
 
开发者ID:Gracker,项目名称:Android-Framework-Tools-Utils,代码行数:17,代码来源:Pair.java

示例9: sameFile

import libcore.util.Objects; //导入方法依赖的package包/类
/**
 * Returns true if {@code a} and {@code b} have the same protocol, host,
 * port and file.
 */
protected boolean sameFile(URL a, URL b) {
    return Objects.equal(a.getProtocol(), b.getProtocol())
            && hostsEqual(a, b)
            && a.getEffectivePort() == b.getEffectivePort()
            && Objects.equal(a.getFile(), b.getFile());
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:11,代码来源:URLStreamHandler.java

示例10: getSequenceLength

import libcore.util.Objects; //导入方法依赖的package包/类
@Override public void getSequenceLength(ASN1Sequence sequence) {
    ASN1Type[] type = sequence.type;

    Object[] values = new Object[type.length];
    int[] compLens = new int[type.length];

    sequence.getValues(content, values);

    push(compLens, values);

    int seqLen = 0;
    for (int i = 0; i < type.length; i++) {
        // check optional types
        if (values[i] == null) {
            if (sequence.OPTIONAL[i]) {
                continue;
            } else {
                throw new RuntimeException();//FIXME type & message
            }
        }

        if (Objects.equal(sequence.DEFAULT[i], values[i])) {
            values[i] = null;
            continue;
        }

        content = values[i];

        type[i].setEncodingContent(this);

        compLens[i] = length;

        // in case if we get content bytes while getting its length
        // FIXME what about remove it: need redesign
        values[i] = content;

        seqLen += type[i].getEncodedLength(this);
    }
    length = seqLen;
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:41,代码来源:DerOutputStream.java

示例11: indexOfAttributeNS

import libcore.util.Objects; //导入方法依赖的package包/类
private int indexOfAttributeNS(String namespaceURI, String localName) {
    for (int i = 0; i < attributes.size(); i++) {
        AttrImpl attr = attributes.get(i);
        if (Objects.equal(namespaceURI, attr.getNamespaceURI())
                && Objects.equal(localName, attr.getLocalName())) {
            return i;
        }
    }

    return -1;
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:12,代码来源:ElementImpl.java

示例12: getPropertyChangeListeners

import libcore.util.Objects; //导入方法依赖的package包/类
/**
 * Returns the subscribers to be notified when {@code propertyName} changes.
 * This includes both listeners subscribed to all property changes and
 * listeners subscribed to the named property only.
 */
public PropertyChangeListener[] getPropertyChangeListeners(String propertyName) {
    List<PropertyChangeListener> result = new ArrayList<PropertyChangeListener>();
    for (PropertyChangeListener p : listeners) {
        if (p instanceof PropertyChangeListenerProxy && Objects.equal(
                propertyName, ((PropertyChangeListenerProxy) p).getPropertyName())) {
            result.add(p);
        }
    }
    return result.toArray(new PropertyChangeListener[result.size()]);
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:16,代码来源:PropertyChangeSupport.java

示例13: indexOfAttribute

import libcore.util.Objects; //导入方法依赖的package包/类
private int indexOfAttribute(String name) {
    for (int i = 0; i < attributes.size(); i++) {
        AttrImpl attr = attributes.get(i);
        if (Objects.equal(name, attr.getNodeName())) {
            return i;
        }
    }

    return -1;
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:11,代码来源:ElementImpl.java

示例14: equals

import libcore.util.Objects; //导入方法依赖的package包/类
/**
 * Returns true if {@code object} is a cookie with the same domain, name and
 * path. Domain and name use case-insensitive comparison; path uses a
 * case-sensitive comparison.
 */
@Override public boolean equals(Object object) {
    if (object == this) {
        return true;
    }
    if (object instanceof HttpCookie) {
        HttpCookie that = (HttpCookie) object;
        return name.equalsIgnoreCase(that.getName())
                && (domain != null ? domain.equalsIgnoreCase(that.domain) : that.domain == null)
                && Objects.equal(path, that.path);
    }
    return false;
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:18,代码来源:HttpCookie.java

示例15: varyMatches

import libcore.util.Objects; //导入方法依赖的package包/类
/**
 * Returns true if none of the Vary headers on this response have changed
 * between {@code cachedRequest} and {@code newRequest}.
 */
public boolean varyMatches(Map<String, List<String>> cachedRequest,
        Map<String, List<String>> newRequest) {
    for (String field : varyFields) {
        if (!Objects.equal(cachedRequest.get(field), newRequest.get(field))) {
            return false;
        }
    }
    return true;
}
 
开发者ID:Mobideck,项目名称:appdeck-android,代码行数:14,代码来源:ResponseHeaders.java


注:本文中的libcore.util.Objects.equal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。