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


Java Objects类代码示例

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


Objects类属于libcore.util包,在下文中一共展示了Objects类的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: 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:thahn0720,项目名称:agui_framework,代码行数:11,代码来源:ElementImpl.java

示例10: 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:thahn0720,项目名称:agui_framework,代码行数:12,代码来源:ElementImpl.java

示例11: 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

示例12: hasListeners

import libcore.util.Objects; //导入依赖的package包/类
/**
 * Returns true if there are listeners registered to the property with the
 * given name.
 *
 * @param propertyName
 *            the name of the property
 * @return true if there are listeners registered to that property, false
 *         otherwise.
 */
public boolean hasListeners(String propertyName) {
    for (PropertyChangeListener p : listeners) {
        if (!(p instanceof PropertyChangeListenerProxy) || Objects.equal(
                propertyName, ((PropertyChangeListenerProxy) p).getPropertyName())) {
            return true;
        }
    }
    return false;
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:19,代码来源:PropertyChangeSupport.java

示例13: equals

import libcore.util.Objects; //导入依赖的package包/类
@Override public final boolean equals(Object o) {
    if (!(o instanceof Entry)) {
        return false;
    }
    Entry<?, ?> e = (Entry<?, ?>) o;
    return Objects.equal(e.getKey(), key)
            && Objects.equal(e.getValue(), value);
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:9,代码来源:HashMap.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: 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


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