本文整理汇总了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);
}
示例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);
}
}
示例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;
}
}
示例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;
}
}
示例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
}
示例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));
}
示例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());
}
示例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);
}
示例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());
}
示例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;
}
示例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;
}
示例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()]);
}
示例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;
}
示例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;
}
示例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;
}