• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Objects类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



Objects类属于libcore.util包,在下文中一共展示了Objects类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


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


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


示例18: equals

import libcore.util.Objects; //导入依赖的package包/类
@Override public boolean equals(Object other) {
    if (other instanceof Address) {
        Address that = (Address) other;
        return Objects.equal(this.proxy, that.proxy)
                && this.uriHost.equals(that.uriHost)
                && this.uriPort == that.uriPort
                && this.requiresTunnel == that.requiresTunnel;
    }
    return false;
}
 
开发者ID:Mobideck,项目名称:appdeck-android,代码行数:11,代码来源:HttpConnection.java


示例19: toString

import libcore.util.Objects; //导入依赖的package包/类
@Override public String toString() {
    return Objects.toString(this);
}
 
开发者ID:google,项目名称:conscrypt,代码行数:4,代码来源:StructTimeval.java


示例20: equals

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GzipParameters类代码示例发布时间:2022-05-22
下一篇:
Java IPageParametersEncoder类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap