本文整理了Java中java.lang.ref.Reference.get
方法的一些代码示例,展示了Reference.get
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Reference.get
方法的具体详情如下:
包路径:java.lang.ref.Reference
类名称:Reference
方法名:get
[英]Returns the referent of the reference object.
[中]返回引用对象的引用对象。
代码示例来源:origin: netty/netty
private V unfold(Reference<V> ref) {
if (ref == null) {
return null;
}
return ref.get();
}
代码示例来源:origin: redisson/redisson
private V unfold(Reference<V> ref) {
if (ref == null) {
return null;
}
return ref.get();
}
代码示例来源:origin: greenrobot/greenDAO
@Override
public T getNoLock(K key) {
Reference<T> ref = map.get(key);
if (ref != null) {
return ref.get();
} else {
return null;
}
}
代码示例来源:origin: square/okhttp
/** Remove this allocation from the connection's list of allocations. */
private void release(RealConnection connection) {
for (int i = 0, size = connection.allocations.size(); i < size; i++) {
Reference<StreamAllocation> reference = connection.allocations.get(i);
if (reference.get() == this) {
connection.allocations.remove(i);
return;
}
}
throw new IllegalStateException();
}
代码示例来源:origin: nostra13/Android-Universal-Image-Loader
@Override
public Bitmap get(String key) {
Bitmap result = null;
Reference<Bitmap> reference = softMap.get(key);
if (reference != null) {
result = reference.get();
}
return result;
}
代码示例来源:origin: nostra13/Android-Universal-Image-Loader
@Override
public Bitmap remove(String key) {
Reference<Bitmap> bmpRef = softMap.remove(key);
return bmpRef == null ? null : bmpRef.get();
}
代码示例来源:origin: stackoverflow.com
public class DataHolder {
Map<String, WeakReference<Object>> data = new HashMap<String, WeakReference<Object>>();
void save(String id, Object object) {
data.put(id, new WeakReference<Object>(object));
}
Object retrieve(String id) {
WeakReference<Object> objectWeakReference = data.get(id);
return objectWeakReference.get();
}
}
代码示例来源:origin: nostra13/Android-Universal-Image-Loader
@Override
public int getId() {
View view = viewRef.get();
return view == null ? super.hashCode() : view.hashCode();
}
代码示例来源:origin: prestodb/presto
/** Remove this allocation from the connection's list of allocations. */
private void release(RealConnection connection) {
for (int i = 0, size = connection.allocations.size(); i < size; i++) {
Reference<StreamAllocation> reference = connection.allocations.get(i);
if (reference.get() == this) {
connection.allocations.remove(i);
return;
}
}
throw new IllegalStateException();
}
代码示例来源:origin: spring-projects/spring-framework
private Object readResolve() {
Reference<?> ref = serializableFactories.get(this.id);
if (ref != null) {
Object result = ref.get();
if (result != null) {
return result;
}
}
// Lenient fallback: dummy factory in case of original factory not found...
DefaultListableBeanFactory dummyFactory = new DefaultListableBeanFactory();
dummyFactory.serializationId = this.id;
return dummyFactory;
}
}
代码示例来源:origin: alibaba/fastjson
@SuppressWarnings("rawtypes")
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
Object item;
if (object instanceof AtomicReference) {
AtomicReference val = (AtomicReference) object;
item = val.get();
} else {
item = ((Reference) object).get();
}
serializer.write(item);
}
代码示例来源:origin: greenrobot/greenDAO
public T get2NoLock(long key) {
Reference<T> ref = map.get(key);
if (ref != null) {
return ref.get();
} else {
return null;
}
}
代码示例来源:origin: redisson/redisson
@Override
public V getValue() {
super.getValue();
return ref.get();
}
代码示例来源:origin: greenrobot/greenDAO
public T get2(long key) {
lock.lock();
Reference<T> ref;
try {
ref = map.get(key);
} finally {
lock.unlock();
}
if (ref != null) {
return ref.get();
} else {
return null;
}
}
代码示例来源:origin: redisson/redisson
@Override
public V getValue() {
super.getValue();
return ref.get();
}
代码示例来源:origin: google/guava
private static <T> @Nullable T getReference(@Nullable Reference<T> reference) {
return (reference == null) ? null : reference.get();
}
}
代码示例来源:origin: google/guava
private static <T> @Nullable T getReference(@Nullable Reference<T> reference) {
return (reference == null) ? null : reference.get();
}
}
代码示例来源:origin: prestodb/presto
@NullableDecl
private static <T> T getReference(@NullableDecl Reference<T> reference) {
return (reference == null) ? null : reference.get();
}
}
代码示例来源:origin: prestodb/presto
@NullableDecl
private static <T> T getReference(@NullableDecl Reference<T> reference) {
return (reference == null) ? null : reference.get();
}
}
代码示例来源:origin: nostra13/Android-Universal-Image-Loader
@Override
public ViewScaleType getScaleType() {
ImageView imageView = (ImageView) viewRef.get();
if (imageView != null) {
return ViewScaleType.fromImageView(imageView);
}
return super.getScaleType();
}
内容来源于网络,如有侵权,请联系作者删除!